ID:158479
 
Hey, I'm wondering how to code something like this:
mob/M in world is M.torch=1
someone uses 'Hougu' verb and M's icon changes to torch.dmi, but only usr can see that, when they click 'Hougu' again M's icon returns.

Could anyone help me?
Thanks for reading.
Look up image in the reference. Adding and removing an image overlay to M is easy. Changing M's icon (the way you want) is a little bit problematic.
In response to Jemai1
soz, but it can be an overlay, it needs to be whole icon
In response to FiveUSSJ
Then you can do something like this:
image
effects
torch
icon='torch.dmi'
mob
var/tmp/hougu
verb/Hougu()
hougu=!hougu
if(!hougu)
for(var/image/effects/torch/t in client&&client.images)
client.images -= t
return
for(var/mob/mob)
if(mob.torch)
src << new/image/effects/torch(loc=mob) // edit: oops! i forgot..


I didn't test that but I'm pretty sure it works. Modify it in order for it to compliment your game.
In response to Jemai1
It would have better if you checked if the mob has a client - otherwise you will get a runtime if accessing a non-client /mob (ex: NPCs).


Whats with the for(var/mob/mob)? That will loop through all /mob in the world!

If you looked up image(), you can see that a new instance of the said torch is displayed by outputting it to the reference.
In response to GhostAnime
GhostAnime wrote:
It would have better if you checked if the mob has a client - otherwise you will get a runtime if accessing a non-client /mob (ex: NPCs).

It won't cause any runtime errors because I did check if src has a client. If you didn't notice I used the && operator. If client is null, for(var/blahblah in client&&client.images) will be equivalent to for(var/blahblah in null). Otherwise, it will be equivalent to for(var/blahblah in client.images).

> Whats with the for(var/mob/mob)? That will loop through all /mob in the world!

I know. The OP didn't say that he wants to see torches only in his view or anything else. Besides, if he wants to, he could modify the code, like what I've told him. If his players are /mob/players, he could change that to /mob/players/mob.

> If you looked up image(), you can see that a new instance of the said torch is displayed by outputting it to the reference.

Yea, I forgot to output it. Thanks for mentioning it.
In response to Jemai1
Thank you, that works.