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

CrimsonCuck

Member
Jan 6, 2019
187
78
hello everyone, I recently had to format my pc, lost a great extension (sugarcubehacker) (for chrome) but that extension is now gone, i tried the one here, but Its weird , can't move the windows that open one on top of each other and makes the games reeeally slow, any chance anyone here has the files of the one i was talking about?
 

Lure of Chaos

Member
Apr 21, 2020
113
99
hello everyone, I recently had to format my pc, lost a great extension (sugarcubehacker) (for chrome) but that extension is now gone, i tried the one here, but Its weird , can't move the windows that open one on top of each other and makes the games reeeally slow, any chance anyone here has the files of the one i was talking about?
Please try my extension and write me if it has any problem too
 
  • Like
Reactions: netaj and user9733

CrimsonCuck

Member
Jan 6, 2019
187
78
Please try my extension and write me if it has any problem too
Don't know if i downloaded it right, I got the zip file, unzipped it and added the extension, but nothing happens. (playing with free cities).
 

Lure of Chaos

Member
Apr 21, 2020
113
99
Don't know if i downloaded it right, I got the zip file, unzipped it and added the extension, but nothing happens. (playing with free cities).
I've updated the extension - it was hanging on large amount of variables (as in Free Cities). Please download again.
Tested to work with Inheritance, Free Cities, An Unexpected New Life.

Preferrable way to report bugs is GitHub, anyway.
 
  • Like
Reactions: Comrade Anulnyat

MonteChristo

Member
Nov 20, 2017
132
60
I downloaded the twinehacker extension and loaded on Chrome, but I couldn't figure out how to make it work...
 

Jz

Member
Dec 5, 2016
120
50
I was able to add the extention, it loaded without errors, however it stays blank - I tried restarting, launching the twine game first, hitting F12 and then opening the extention. It has full permissions and developer mode is enabled.

Any ideas?

Edit: Nevermind- I followed the tutorial wrong, extention works great ! thanks a lot.
 

SomeIndolence

Newbie
Jul 29, 2020
33
40
isn't there a way to use the console to display all objects/variables under sugarcube.whatever.whatever?
 
Last edited:

greyelf

Well-Known Member
Nov 16, 2016
1,071
787
isn't there a way to use the console to display all objects/variables under sugarcube.whatever.whatever?
Yes. All SugarCube based stories/games include a special SugarCube debug object you can use to access the internals of the story format's JavaScript based engine.

For a SugarCube 1.x based story you use the following in the console to access all the Story Variables associated with the Passage being currently viewed. Note the letter casing of each property!
Code:
SugarCube.state.active.variables
For a SugarCube 2.x base story you would use the following instead. Again the letter casing is important!
Code:
SugarCube.State.variables
 

shizzlenizzle

Member
Aug 21, 2018
145
62
A little off topic: is it possible to run a console command like "SugarCube.State.active.variables.gameDate.setHours(10)" from an addon button? cant find info on this elsewhere.

im looking to make an addon that has 1 button that just sets the ingame time quick and easy.
 
Last edited:

Lure of Chaos

Member
Apr 21, 2020
113
99
is it possible to run a console command like "SugarCube.State.active.variables.gameDate.setHours(10)"
No, functions are not supported and can't be, due to dynamic nature of JavaScript (Okay, you can get "getHours" name, but you can call it with any arguments you like, no one knows which are right besides the author).
If you need this, please use console
 
  • Like
Reactions: shizzlenizzle

shizzlenizzle

Member
Aug 21, 2018
145
62
No, functions are not supported and can't be, due to dynamic nature of JavaScript (Okay, you can get "getHours" name, but you can call it with any arguments you like, no one knows which are right besides the author).
If you need this, please use console
thank you for clearing that up.
 

Lure of Chaos

Member
Apr 21, 2020
113
99
P.S. that would be possible only if one would create game-specific "trainer" with buttons such as "set Hours to ...", "set Money to 10000" and so on.
But generic solution, suitable for any game (and TwineHacker extension is that one), can only detect simple (maybe nested) values, exactly what it does: lists through all these "SugarCube.state.active.variables.***" and presents ability to edit it. My extension tries to present these variables more readable (so "twine_thisVariable" is shown as "Twine This Variable"), but who knows what means those "mcfapr" :rolleyes:

Another approach would be something like this, but it seems only waste of time to make cheat for every game while generic solution is suitable in many cases. Furthermore, in the most cases cheating money only (and enjoy game story while skipping grinding) is enough; I doubt someone alters whole game mechanics.