ID:150074
 
I have an obj that only the user can see, but when clicked, nothing happens. Here is the code:

obj
option1
var/img
New(l,mob/M)
..()
var/mylocx5 = usr.x+3
var/mylocy5 = usr.y+1
img=image ('menu.dmi',locate(mylocx5,mylocy5,usr.z),"color",2)
M << img

Del()
if(img) del(img)

Click()
var/color = input("What color do you want to be?") in list ("Blue","Yellow")
usr.icon_state = color


Although this gives away what my demo is about, I still need to finish it.

Also, i create the obj like this:
 new/obj/option1(mylocx5,mylocy5,usr.z)


Thanks,

-Rcet
Rcet wrote:
var/mylocx5 = usr.x+3
var/mylocy5 = usr.y+1
img=image ('menu.dmi',locate(mylocx5,mylocy5,usr.z),"color",2)

This is the problem. You'll notice the source I presented attaches img to the object itself (src), not to the same location. You're attaching the image to the turf, not the object, so the object is useless; since the image is located in the turf, the turf receives the Click() proc.
img=image (icon='menu.dmi',loc=src,icon_state="color",layer=2)

By attaching the image to an object, the object can be made unique for each player and can be given a name that doesn't match the turf around it. (The object's name will show when you mouseover the image.)

I would avoid using usr in the object creation process unless there's some particular reason that's better. Since you have M available, if you want this interface to be for M, use M.x, M.y, and M.z instead for the obj's location. But the image should be located in the obj; otherwise the obj is useless.

Lummox JR
In response to Lummox JR
I`m having the same problem,

    var/attack = image (/obj/Attack,locate(25,30,3),,5)
usr << attack

I make the obj like this:

obj/Attack
icon = 'chip2.dmi'
icon_state = "Attack"
Click()
usr << "It worked."


I cant for the life of me, figure out wht its not working
In response to Pillsverry
Pillsverry wrote:
var/attack = image (/obj/Attack,locate(25,30,3),,5)

You don't specify which is the location of the image: /obj/Attack (which is just a type, not an actual object, until you use "new"), or the turf returned by locate(). What I think you want is something more like this:
var/attack = image (loc=new /obj/Attack(locate(25,30,3)),icon='attack.dmi',layer=5)

Lummox JR
In response to Lummox JR
that kinda works, but it shows it to everyone, and its only clickable when i use the code you gave me,

I dont see what the problem is, if i could show only one object to a certain player i could do that

ugh
In response to Pillsverry
Pillsverry wrote:
that kinda works, but it shows it to everyone, and its only clickable when i use the code you gave me,

The only way it could be shown to everyone would be if you gave the object an icon, which you're not supposed to do in this case.

Lummox JR