Animation Nodes: Trigger Action, Save Value if Frame Matches? I've created a simple stopwatch (Blender 2.79, Animation Nodes 2). I have certain frame ranges I want to time. I have a list which has two elements...a start frame, and a stop frame.

Upon reaching start frame I need to zero my stopwatch by setting a math "subtract" node equal to the current frame. I can easily detect a boolean compare of start frame and current frame, but then I need to push the value into my "subtract" node. I do not see a node for "if true alter some variable in another node, else leave the variable alone".

I'm good with detecting a true/false boolean condition...I'm lost on using that condition to trigger an event to save data for future use...to push data onto a queue or stack or array which I can refer to at the end of the video. Is there an animation node I can use to trigger a write to a math node or append to a list? Will I need to figure out how to link my boolean detection of start and stop frame to a python script, followed by the python updating the math node or list?
While I think it's possible to dynamically change the values of a node with a script, I assume the better option is to use a Script node to store an ID property, e.g. in the scene. For more complex data types than single float or int values you may have to define a custom bpy.propsproperty.

A script with a boolean for the reset as input and a single float for the time as output should work.



import bpy
scene = bpy.context.scene
frame = float(scene.frame_current)

if reset:
    scene['last_reset'] = frame

time = frame - scene.get('last_reset', 0.0)


N.B.: Interestingly, the ID property is only retained if the frame is manually converted to a float. If the float conversion is removed (frame = scene.current_frame), the property vanishes every time the reset flag is cleared.