I'm trying to add a loop into my target system while will scan for if the target attacks, and if so it changes the reticle icon_state. I doing so, I've created an infinite loop, but it also doesn't do what I want it to. I'm wondering if it's even possible to change the icon state of an image.
Code:
mob/player/proc
Target(mob/T)
var/image/I = image('Target Reticle.dmi', T,"Neutral")
//If no target, target normally.
if(!usr.targeting)
usr.targeting = 1
usr.target = T
usr.client.images += I
view()<< "[usr] [pick(targettext1, targettext2, targettext3, targettext4)] [T]."
//If player has a target already, then drop it, and target new selection.
else
for(I in usr.client.images)
del(I)
usr.targeting = 1
usr.target = T
usr.client.images += I
view()<< "[usr] [pick(targettext1, targettext2, targettext3, targettext4)] [T]."
while(usr.target == T)
if(T.attack())
I.icon_state= "Hostile"
That's the loop I'm trying to run, and I understand why it's an infinite loop, but what's the best way to mitigate this and also get it to work?
So instead of
use
Also, what exactly is the problem? You only mentioned that it doesn't do what it is supposed to do. I might be able to help with that if I know what exactly it isn't accomplishing.