ID:139643
 
Code:
turf
DblClick()
for(var/obj/bigball/K in world)
if(K.Gowner == usr)
walk_towards(K,src,0)
if(get_step(K,src) > 1)
K.overlays += new/obj/ball


Problem description:
but the obj dont change when it reaches the turf the usr dblclicked.
some idea on how can i make the code?
i want the code to change the icon of the obj when it reached the turf.
Thanks

There are at least 2 ways to do this, but here is one, made by adding on to your current code.

turf
DblClick()
for(var/obj/bigball/K in world)
if(K.Gowner == usr)
while(get_dist(K,src) >= 1)
walk_towards(K,src,0)
K.icon='whatever.dmi'


That is probably the simplest way to do it. Knowing the masters here like Garthor, though, there is a 99.9% chance that there is a better way to do it, and they will not hesitate to post here after myself. Anyways, this modification just uses while(), so that it checks that so long as the bigball is 1 or more tiles away from the turf, it will walk_towards() it. Once the distance is less than 1 (meaning it is on top), it changes the icon to whatever.dmi.
In response to Albro1
Albro1 wrote:
That is probably the simplest way to (...)

...cause lag?
A loop that is going to run constantly without delay is always a great way to screw up the game experience for your customers. Not to mention that calling a procedure that automatically continues by itself in a loop doesn't exactly make much sense.

Garthor actually presented a proper suggestion[link] for the problem, the original poster just doesn't know enough about the language to translate it into a code snippet.
In response to Albro1
Albro1 wrote:
Knowing the masters here like Garthor, though, there is a 99.9% chance that there is a better way to do it, and they will not hesitate to post here after myself.

Toldja.