ID:144529
 
Code:
mob/npc/var/target = 0
var/mob/npc/last_target = new()
var/mob/npc/same_target = new()
mob/npc
DblClick()
if(last_target)
if(src.target)
src.overlays -= image('blinking_cursor.dmi')
usr << "[src] [src.target] [last_target.target]" //debuging code
usr << "<font color =red>[src] is no longer your target.</font>"
src.target = 0
usr << "[src] [src.target] [last_target.target]"
return
else
last_target.overlays -= image('blinking_cursor.dmi')
last_target.target = 0
src.overlays += image('blinking_cursor.dmi')
last_target = src
src.target = 1
usr << "[src] [src.target] [last_target.target]"
usr << "<font color =red><strike>[src]</strike> has been set to your target.</font>"
else
src.overlays += image('blinking_cursor.dmi')
last_target = src
src.target = 1
usr << "[src] [src.target] [last_target.target]"
usr << "<font color =red><strike>[src]</strike> has been set to your target.</font>"
..()


Problem description:Ok, first off, everything works fine with this code. There is nothing wrong with it at all. The point of this question however is how do I make it so that the target and the icon overlays is only visible to the client.screen, meaning only visible to the player and not the world?

Edit: Beh, See Jt's post (I didn't actually looked fully on your code >_>' Or partially for that matter) Otherwise I would've said about the HTML too >_>'

<font size=1>
Instead of client.screen, you want to use images (Make sure you read about the arguments /image has.

it should be straight foward of how to use images to show only to the user but if you want, you can check out my demos on them .

(To see if it actually does only show to one player, host the game locally and join it with another key. What one will see the other won't (or it'll be different))</font>

- GhostAnime
The trick here is not to use the overlays list, but instead to use the "loc" argument of the image proc.

You will need:

1) A mob variable used to store the resulting data produced from the image() proc. var/image/selection_cursor, for example.
2) The image proc with the format image('icon.dmi',loc=src), where src is the object being clicked.
3) To display the image to the player by using "usr << variable", where variable is the place you are storing the image (see above).

You'll also want to fix your HTML tags in the code -- the word "red" should be flush against the "color=" in the font tag. =)


[edit]GhostAnime said pretty much everything I've said, and provided links too! But he didn't complain about your HTML. ;-)[/edit]
In response to Jtgibson
Hey man I tried this out and it's still not working. See the thing is that the cursor can not belong to one static object's property, being it the loc=src. It also has to belong the the last_target, which in this case is the last_target that was clicked before the new target was clicked. That's because when you click another target even though you have your last target still set as the target, the last target will lose the properties of being the target including the icon indicating that it was previously the target. There are two variables here:


<font color =blue>last_target</font>: which is equivalent to src once instantiated
<font color =green>src</font>: which is the first target ever set


Oh yea, in regards to the HTML format thing, it really doesn't even matter, I usually right the HTML code like so: "color = red", just to distinguish myself. However, it being flush like "color=red" would also work.

But there are bigger problems, so, whoever can help me out with this please do. And make sure to really review the code since each line of it is of intense significance to how it is supposed to work exactly.

<font color =red>Note: I'd also like to add that this is really all a matter of visual effects that are intended to make the game much more user-friendly. Usually, it is nice for the person to see which target exactly is the current target!</font>