Hello.
I want something like this:
How can I use variables from SugarCube in JS? I need many small functions like get_hide_odds(). And I want use them without arguments like get_hide_odds(enemy,hero). Is it possible? Or I need big structure like "$game" with properties "enemies", "hero", "rooms" etc? And use it like get_hide_odds($game).
Maybe there is better organization of code for my problem (but without fanatism). Thank you.
I want something like this:
::StoryInit <<set $TRACKING["ENEMY_1"] = 40>> <<set $TRACKING["ENEMY_2"] = 50>> <<set $enemy["ROOM_1"] = "ENEMY_1">> <<set $hero_stealth = 10>> <<set $hero_location = "ROOM_1">> ::Main You can <<link `"hide (" + get_hide_odds() + "%)"` "Hide"`>><</link>>. ::JS window.get_hide_odds = function() { var odds = 0; stealth = 100 - $TRACKING[$enemy[$hero_location]] + $hero_stealth; return odds; }But "$TRACKING[$enemy[$hero_location]]" and "$hero_stealth" doesn't work in JS. They are not defined.
How can I use variables from SugarCube in JS? I need many small functions like get_hide_odds(). And I want use them without arguments like get_hide_odds(enemy,hero). Is it possible? Or I need big structure like "$game" with properties "enemies", "hero", "rooms" etc? And use it like get_hide_odds($game).
Maybe there is better organization of code for my problem (but without fanatism). Thank you.