Okay, this is more a matter of opinion, I guess. So my games tend to rely on Javascript functions to do a lot of the repeating calculation. So how do people do this?
One time, I put them into the master section (the one with [[]]:). That worked well enough but I wasn't sure if doing that slows execution down, since every screen has to sweep the functions again.
The next time, I put them all in the first few sections. I made a couple of sections (named encounter, combat, board, etc) so that all similar functions could be included in the same section (and easily located).
I keep thinking I'm not doing this clean. Are there any good standards to follow on how to carry functions in squiffy code?
Hello.
I do it like this. (Not sure if it's the most efficient way or not.)
set("dumbVar",1);
squiffy.tstFunct = function(){ set("dumbVar",get("dumbVar") + 1); };
@title Setup JS
Hello.
dumbVar = {dumbVar}
[[test]]
[[test]]:
squiffy.tstFunct();
dumbVar = {dumbVar}
[[test2]]
[[test2]]:
squiffy.tstFunct();
dumbVar = {dumbVar}
[test3]
[test3]:
squiffy.tstFunct();
dumbVar = {dumbVar}
I do something like that (functions up front). One thing I've done in my last game is group functions so I can find them like this...
[[combat functions]]:
squiffy.com1 = function(){
//code goes here
};
squiffy.com2 = function(){
//code goes here
};
squiffy.story.go("map functions");
[[map functions]]:
squiffy.map1 = function(){
//code goes here
};
squiffy.map2 = function(){
//code goes here
};
squiffy.story.go("game start");
[[game start]]:
Okay, we're in the game with functions active
This way, I can pull the section menu open and see where my function groupings listed as "sections". But since some of the functions are pretty long, it dosn't pay off that well. Helps a little.