Create and Fuck your AI Slut -70% OFF
x

Tutorial HTML How To Debug(Or Cheat) Twine{SugarCube} Variables

MrBlack ✌

Member
Jun 4, 2017
428
435
268
Yeah I just tried them now, but the first one is hard to set up (in my opinion) and the second one is not as clear to find stuff
I'll stick to using the console for now but thank you for pointing these out.
If you're willing to use the console, you can also use the script to enter the variable (the part after "SugarCube.State.active.variables") into the tool. After entering the first two letters, a preview filter will appear until the next dot, if there is one, and you can click it. If the variable continues after a possible dot, enter two or more letters again to see the possible list and click it... Finally, add the variable to your list with the plus icon. Then, switch the leftmost icon to freeze the variable, if you like so. You can then switch up or down to freeze only one direction. For example, switch to green down to prevent something like money or energy from decreasing, but allow it to increase. I don't think saving works with files. Maybe with cookies? In some circumstances, you can reload the variable table. However, after several weeks waiting for a game update, usually my lists are gone.
 
  • Like
Reactions: Mori369

Redlightsart

Newbie
Oct 19, 2022
19
23
70
Is there a way to cheat on mobile? I tried with the Lemure Browser. Tried SucarCube.State on console and SugarMelt from store. Nothing works.
 

Elo91

Newbie
Apr 21, 2024
85
104
119
So umm just a quick question (I think): Is there a way to print all variables & their current value? Like, everything under "SugarCube.State.variables.*" ?

Basically it's not the editing that's the problem for me, it's finding the vars themselves & telling what all really changes when you add a stat / feat etc. in-game. It's not always just 1 var after all, but several and in different places with some being vars and others arrays even. If I could just print them all it would be easy to paste it onto Notepad++ and go over & compare them there. Without taking unnecessary risks installing and running random tools, scripts or extensions. :)

Oh and also, if I did make scripts of my own, is there a way to save & run them for when you need to do the same thing several times? Right now I just use an AHK script that just taps F12 > arrow up (last cmd) > enter > F12 again to close, bound to a single keybind.
 
  • Like
Reactions: Troll55

greyelf

Well-Known Member
Nov 16, 2016
1,104
824
340
Is there a way to print all variables & their current value?
The variables property of the references a Generic Object, whose keys represent each of the currently active Story Variables.
eg. The value of a variable named $apples can be accessed via the "apples" key
Code:
/* From within the project's own code */
State.variables["apples"]

or

/* From a web-browser's Console, via the undocumented debugging interface */
SugarCube.State.variables["apples"]
JavaScript's method can be used to obtain an Array of the names of all the keys that are contained within an Object, and the method can be used to iterate through that list of key names.
Code:
/* From within the project's own code */
Object.keys(State.variables).forEach(key => {
    console.log(key, State.variables[key]);
});

or

/* From a web-browser's Console, via the undocumented debugging interface */
Object.keys(SugarCube.State.variables).forEach(key => {
    console.log(key, SugarCube.State.variables[key]);
});
 
  • Like
Reactions: Troll55 and Elo91