Regarding Scenario 3.7, I can't really see how Scenario variables are more useful than JS ones since they're set before the scene is run instead of during, which makes them equivalent to regular variables, no?[snip...]If set() accepted a function instead of a value, then it could call the function at scene run time to produce the value. scene.variables could be a function that accepts the name of a variable and returns a function that returns the value of the variable. Other scenelets could then accept that function and get the variable's value. In code,Code: (javascript) [Select]scene.movePerson('hero', 'north', 5 * GetTileHeight(), 1, true) .set('heroX', function () { return GetPersonX('hero'); }) .set('heroY', function () { return GetPersonY('hero'); }) .panTo(scene.variables('heroX'), scene.variables('heroY'), 1) .run();
scene.movePerson('hero', 'north', 5 * GetTileHeight(), 1, true) .set('heroX', function () { return GetPersonX('hero'); }) .set('heroY', function () { return GetPersonY('hero'); }) .panTo(scene.variables('heroX'), scene.variables('heroY'), 1) .run();
Yeah, I really only added variable support to get loops to work. To be fair though, scenelets can modify variables as well (via the scene.variables object), but your lambda method is certainly better. But really, this is the a good case in point for why I want to do a dedicated scene language, as it illustrates a use case where the intuitive method of doing things doesn't work properly.
So anyway, I do know that adding the new features is going to majorly increase the size of Scenario's codebase, which is why I was thinking of making it an optional component. If you just include Scenario.js, you get exactly what you do now (plus whatever other new features make it into 4.0), and then you could also require 'SceneLanguage.js' or something to get the new scene language parser.
By the way, the call scenelet is broken: it should be [].slice.call(arguments, 2) since state isn't an explicit argument anymore.
Code: (javascript) [Select]scene.movePerson('hero', 'north', 5 * GetTileHeight(), 1, true) .set('heroX', function () { return GetPersonX('hero'); }) .set('heroY', function () { return GetPersonY('hero'); }) .panTo(scene.variables('heroX'), scene.variables('heroY'), 1) .run();
scene.movePerson('hero', 'north', 5 * GetTileHeight(), 1, true) .focusOnPerson('hero', 1.0) .run();
I just realized, your above code could be done much more simply with the focusOnPerson scenelet. I know it was just an example, but I don't know if you were aware or not:Code: (javascript) [Select]scene.movePerson('hero', 'north', 5 * GetTileHeight(), 1, true) .focusOnPerson('hero', 1.0) .run();
This is where a dedicated scene language would be a big win.
var loopCount = 0;new Scenario() .doUntil(function() { return loopCount++ < 3; }) // loop 3 times // add scenelet calls here .end() .run();