ID:1877366
 
(See the best response by Lummox JR.)
My problem is I'm creating a roulette, and it's dependent on the animation starting at the same point every time. For some reason, the firs time I do it, it starts at the right point. But any time after that, the animation starts at a different frame. Is there a way to make an animation start at the first frame every time?


mob/var/tmp/roulette=0
mob/proc
Roulette()
if(roulette == 1)
roulette = 0
for(var/obj/Roulette/M in client.screen)
client.screen -= M
del M
return
roulette = 1
var/obj/Roulette/L=new()
client.screen += L


This is a small example I put together to get my point across.

The problem is, it's creating the roulette, with starting points at random frames. I need it to start on it's first frame every time, or the roulette time is off.

I want the roulette is stay there forever until it's used again to delete it.


Edit: Make it go through the animation only once makes it start at the beginning every time. But I need it to go indefinitely, while starting at the beginning every time
Best response
Are you talking about an animated icon with a fixed loop?

If the icon does not loop a fixed number of times, that is if it loops indefinitely, it will not take the creation time of the obj into account. But if it is a fixed-loop animation, and obviously the obj is new every time, I would expect the new creation time to apply each time. It's possible (though premature to say for sure) that a bug could be in play.

Incidentally, the ==0 and ==1 tests on vars that can only be true or false is bad form. Just use if(roulette), not if(roulette==1). Likewise you'd use if(!roulette) in place of if(roulette==0). It's a good habit to be in because it makes your code more robust.
Normally that is how I would do it. This was just a quick example to show what I was trying to do. I do appreciate the help on this. Putting it on a fixed loop fixed it to my satisfaction
Ah, if it wasn't on a fixed loop it definitely wouldn't have behaved the way you want. Glad you got it working as you wanted it.
Indeed. Thank you