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.
ID:158479
![]() Aug 18 2009, 12:40 am
|
|
![]() Aug 18 2009, 1:06 am
|
|
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.
|
Then you can do something like this:
image I didn't test that but I'm pretty sure it works. Modify it in order for it to compliment your game. |
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. |
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. |