- Code: Select all
fireworkNode = props.globals.getNode("/scenery/fireworks/firework[0]");
heightNode = fireworkNode.getNode("height");
activeNode = fireworkNode.getNode("active");
var update = func() {
activeNode.setDoubleValue(0);
interpolate(heightNode, 500, 5);
print(heightNode.getValue());
heightNode.setDoubleValue(0);
print(heightNode.getValue());
print("1 ", activeNode.getValue());
interpolate(activeNode, 1, 3);
print("2 ", activeNode.getValue());
activeNode.setDoubleValue(0);
print("3 ", activeNode.getValue());
}
t = maketimer(10, update);
t.singleShot = 0;
t.simulatedTime = 1;
t.start()
The code resides inside a <load> section in the firework's XML file.
This is the expected behaviour:
- active = 0
- height = 0
- height changes to 500 in 5 seconds
- height = 0
- active changes to 1 in 3 seconds (effectively, bool(active) is true for (almost) 3 seconds)
- active = 0
The height stays at 500 for ten seconds, jumps to 0 and immediately interpolates to 500 again. The active property is 1 all the time, then when height is 500 it jumps to 0 and changes linearly to 1 again where it stays until height is 500 again, where the thing begins again. I don't understand that. But the worst is - all three prints output a value of 0 for height all the time ! Please help quickly.
You can test the behaviour by pasting the code above into the Nasal console and observing the properties in /scenery/fireworks/firework - i.e. it's standalone.