ID:2001341
 
Resolved
Non-named arguments on calls to animate() when no object was included (i.e., a later stage of the animation) were not interpreted correctly. Now it is not necessary to explicitly name the time argument.
BYOND Version:509
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Chrome 47.0.2526.80
Applies to:Dream Daemon
Status: Resolved (509.1318)

This issue has been resolved.
Descriptive Problem Summary:

animate() without an Object is suppose to append a step to the animation, but it only seems to do so if the animation's loop is higher than 1.

I was hoping to make a client/pixel_x/y style screen shake system, abusing animate()

It would queue up steps to the screen shake with mutiple animate() calls, with only the first having the client.

But this seems to only show the final step.

Every example showing the use of this format in the ref has a loop var, so i'm guessing that that is why.

I'm not sure if the ref is wrong for not listing this requirement, or if this is a bug with animate()

The loop arg is never needed on subsequent calls. But what does your code look like?
What i'm doing doesn't loop at all, i want to add steps to a single run animation

/proc/shake_camera(mob/M, duration, strength=1)
if(!M || !M.client)
return

var/client/C = M.client
var/oldx = C.pixel_x
var/oldy = C.pixel_y
var/max = (strength+1)*world.icon_size
var/min = 0-((strength+1)*world.icon_size)

for(var/i=0; i<duration, i++)
var/newx = rand(min,max)
var/newy = rand(min,max)
if (i == 0)
animate(C, pixel_x=newx, pixel_y=newy, 1)
else
animate(pixel_x=newx, pixel_y=newy, 1)
animate(pixel_x=oldx, pixel_y=oldy, 1)


try that with m,7,2 and it will be clear that only the final animate call actual does anything
If you name the time arg, does the issue go away?
Nope
What happens if you make the time arg longer, like 10?
Tried that (in my case, i had them all be duration+1 and did 10,2 thinking that maybe it made all steps take place in the same time frame as the first step), same thing, only the final step is animated. Or rather, it jumps to the final pixel offset, then animates returning back to the old x/y

I also tried changing C to M to see if it was just something odd with animating clients, but same result. The mob jumps to the final offset, then animates back to 0,0
Naming the time arg fixes it on my end;

// Jumps to second-last animate()'s coords, then animates to 0,0
/proc/shake_camera(mob/M)
animate(M.client, pixel_x=rand(-100,100), pixel_y=rand(-100,100), 10)
animate(pixel_x=rand(-100,100), pixel_y=rand(-100,100), 10)
animate(pixel_x=rand(-100,100), pixel_y=rand(-100,100), 10)
animate(pixel_x=0, pixel_y=0, 10)

// Animates all the way through
/proc/shake_camera2(mob/M)
animate(M.client, pixel_x=rand(-100,100), pixel_y=rand(-100,100), time=10)
animate(pixel_x=rand(-100,100), pixel_y=rand(-100,100), time=10)
animate(pixel_x=rand(-100,100), pixel_y=rand(-100,100), time=10)
animate(pixel_x=0, pixel_y=0, time=10)


edit:
Naming the time arg on the first call (with 'M.client') is not neccessary for it to work, but it is neccessary on all calls after that (i.e. the ones adding steps).
I think that was it. You need to name the time arg on the subsequent calls. This is a bug, though, because that shouldn't be necessary. The correct behavior as I see it is that once a named arg is encountered, animate() shouldn't expect an object anymore.
I'll try it again, see if maybe i ended up still running the unfixed version...
Ya, ok, so i figured it out, I had played around with the code after showing my version here, and did a version that abused sleep() to get around the issue, and had re-added the C, i removed the C, from one of the animate calls but not the final when i tested naming the time arg
Lummox JR resolved issue with message:
Non-named arguments on calls to animate() when no object was included (i.e., a later stage of the animation) were not interpreted correctly. Now it is not necessary to explicitly name the time argument.