JS serialization is confounding, also ref/val confusion
I notice almost none of the included JS effects ever save state beyond the slider settings. I can't figure out how to get presets to work at all for state information beyond the UI.
Here's a simple test effect that sets a single state variable. Set state, save it, hide it, then save the preset. Clear state and load the preset ... no state gets loaded. Why not?
Another very confusing thing is that if the comment is removed [in the (slider2 == 3) block] the state doesn't even get set -- x doesn't persist outside of that block. I think this means that within that block at least, x is just a reference to slider1. Is there a way to valuify x inside that block? Confusing!
Are these two weirdnesses related?
////
desc:serialization test
slider1:0<0,10,1>x
slider2:0<0,5,1{-,show state,hide state,save state,clear state}>action
@init
x = 0;
@serialize
file_var(0, x);
@slider
(slider2 == 1) ? (
slider1 = x;
slider2 = 0;
);
(slider2 == 2) ? (
slider1 = 0;
slider2 = 0;
);
(slider2 == 3) ? (
x = slider1;
// slider1 = 0;
slider2 = 0;
);
(slider2 == 4) ? (
x = 0;
slider1 = 0;
slider2 = 0;
);
Last edited by schwa; 03-16-2007 at 09:33 PM.
Reason: clarified
|