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

junito

Member
May 27, 2017
333
60
able to install but nothing happen when activated, I know that is working because if in another page "Failed to load Twinehacker. Reason: SugarCube not found". Any tips?
 

junito

Member
May 27, 2017
333
60
So I downloaded an extension from a user in the fresh start game's page, also have tried using the chrome F12 developer console to try to edit sugarcube variables in twine games, however any time I make a change/cheat the game stats, they immediately revert to their original states after I have edited them whenever I take literally any action or switch any screen. They're just not wanting to stay edited. Is there any way I can force them to stay cheated? Am I not taking another important step to force my changes to stick in the game?
 

HiEv

Member
Sep 1, 2017
384
778
So I downloaded an extension from a user in the fresh start game's page, also have tried using the chrome F12 developer console to try to edit sugarcube variables in twine games, however any time I make a change/cheat the game stats, they immediately revert to their original states after I have edited them whenever I take literally any action or switch any screen. They're just not wanting to stay edited. Is there any way I can force them to stay cheated? Am I not taking another important step to force my changes to stick in the game?
It should stick if you're setting the right variable.
If it's a Twine2 game and you're setting it through the console, it should be something like this: SugarCube.State.variables.VariableName = whatever
If that doesn't work, name the game and show exactly what you're typing in.
 
  • Like
Reactions: MerlinWizard01

IdleGuy

Member
Aug 7, 2016
401
521
I can't get anything posted here working with the latest Firefox.
Nothing even shows up in the console tab. Is it language dependant? Because my native Firefox ain't in english.
 

John Diggle

New Member
Jul 30, 2017
3
0
yeah this hasnt worked on any game for me using chrome in a week or two. tried my mac and pc. thought it was just me doing something wrong though.
 

HiEv

Member
Sep 1, 2017
384
778
to cheat is that there is an equivalent of SugarCube.State.active.variables for games made by twine 2
The version of Twine and the version of its story format can be different. The important thing here is the version of SugarCube, not Twine.
For SugarCube v1 you change the variables on "SugarCube.state.active.variables".
For SugarCube v2 you change the variables on "SugarCube.State.variables".
(These are case sensitive, so note the capitalization of "state".)

There are other story formats, such as Harlowe and Snowman, the above won't work for these story formats.
 

Silver1

Active Member
Feb 7, 2017
627
386
I got a problem: my Firefox auto updated to the Quantum version, the F12 still works, along with the SugarCube.State.variables command, but i can´t edit anything anymore, anyone with experience with this version could help me please?Thank you.
 

HiEv

Member
Sep 1, 2017
384
778
I got a problem: my Firefox auto updated to the Quantum version, the F12 still works, along with the SugarCube.State.variables command, but i can´t edit anything anymore, anyone with experience with this version could help me please?Thank you.
If you know the name of the variable, then if it's a story variable (one that starts with "$") you open the console and do this:
Code:
SugarCube.State.variables.variableName = "value"
If the value is a number, don't include the quotes.

If it's a temporary variable (one that starts with "_"), you do the same thing, except instead of "variables" you put "temporary", like this:
Code:
SugarCube.State.temporary.variableName = "value"
That should be the same regardless of browser or version.

(Note: That assumes that the Twine game is using SugarCube v2. Other story formats have different ways of storing variables.)
 

Silver1

Active Member
Feb 7, 2017
627
386
If you know the name of the variable, then if it's a story variable (one that starts with "$") you open the console and do this:
Code:
SugarCube.State.variables.variableName = "value"
If the value is a number, don't include the quotes.

If it's a temporary variable (one that starts with "_"), you do the same thing, except instead of "variables" you put "temporary", like this:
Code:
SugarCube.State.temporary.variableName = "value"
That should be the same regardless of browser or version.

(Note: That assumes that the Twine game is using SugarCube v2. Other story formats have different ways of storing variables.)
Thank you for answering, i got some error messages form what you told me, but from that i managed to make it work, the browser actually find variables for you. Still, i cant make the "SugarCube.State.variables" work, only the "SugarCube.state.active" does and it does not work for every game.
 

HiEv

Member
Sep 1, 2017
384
778
Thank you for answering, i got some error messages form what you told me, but from that i managed to make it work, the browser actually find variables for you. Still, i cant make the "SugarCube.State.variables" work, only the "SugarCube.state.active" does and it does not work for every game.
That's correct. As I stated above, "SugarCube.State.variables" only works for Twine games using the SugarCube v2 story format (which is probably the most common story format for modern Twine games).

If the game is using SugarCube v1 you'll need to use "SugarCube.state.active.variables" instead.

There are other story formats as well, such as Harlowe, Sugarcane, Snowman, and others, each of which have their own system for storing the data. I don't know what those ones use.

If you go to the console and enter "SugarCube.version" then if some data appears there, you can look at the major version number to see if it's SugarCube v1 or v2. If you instead get an error message saying that it's not defined, then it's some other story format.
 
  • Like
Reactions: Silver1

yearhyearh

New Member
May 10, 2017
13
3
I'm really not savvy with this, anyone know how to get this working in Queen of The Seas? or know what the problem is
 

sakuyas_mmaster

Well-Known Member
Feb 12, 2018
1,143
1,409
I'm really not savvy with this, anyone know how to get this working in Queen of The Seas? or know what the problem is
What do you mean? Just press F12 and do what's written in OP. If for example you want to change money write SugarCube.State.variables.Player.Money=12345 and it's done. You may have to refresh the interface by for example opening and closing the inventory or walking to another location to see the change.

Stats are stored in SugarCube.State.variables.Player.CoreStats (just write the line in the console and you'll see the an object with the stats. If you want to change one, let's say health you change it by writing SugarCube.State.variables.Player.CoreStats.Health=100
 

yearhyearh

New Member
May 10, 2017
13
3
What do you mean? Just press F12 and do what's written in OP. If for example you want to change money write SugarCube.State.variables.Player.Money=12345 and it's done. You may have to refresh the interface by for example opening and closing the inventory or walking to another location to see the change.

Stats are stored in SugarCube.State.variables.Player.CoreStats (just write the line in the console and you'll see the an object with the stats. If you want to change one, let's say health you change it by writing SugarCube.State.variables.Player.CoreStats.Health=100
Okay I kinda made this work but it's borderline file editing levels of cumbersome sometimes to find what I want, although I guess I'll get an eye for it. How come the twinehacker doesn't work, though?
 

HiEv

Member
Sep 1, 2017
384
778
How come the twinehacker doesn't work, though?
Chrome added some extra security features back in January (due to the major "Spectre" and "Meltdown" vulnerabilities), which was about the same time TwineHacker broke. So, if I had to guess, I'd bet it was related to that security fix.

Chrome has been pretty good and proactive about dealing with security risks. This is great for consumers, but for web developers it can be a bit of a pain to deal with, as it breaks some code. The developer will likely have to modify their code to deal with the security changes.
 

archoniq

Newbie
Sep 14, 2017
69
107
If ye need a video guide, use this:
It's for the game Enchanted, but ye'll probably get the drift.

Guide:

You don't have permission to view the spoiler content. Log in or register now.
Say, would you be able to help me do this for ? I don't think the methods discussed in this thread work :c