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

Eoin

The Bug Hunter
Moderator
Donor
Feb 21, 2017
1,232
4,830
Say, would you be able to help me do this for ? I don't think the methods discussed in this thread work :c
I'll see what I can do.

He's changed it round a bit, but if you type in to the console "SugarCube.Config.debug = true", it should give you a cheat mode. Or you can open the files using notepad++, copy and paste the code into a base64 decoder, and look for the variables yourself.
 
  • Like
Reactions: archoniq

archoniq

Newbie
Sep 14, 2017
69
107
I'll see what I can do.

He's changed it round a bit, but if you type in to the console "SugarCube.Config.debug = true", it should give you a cheat mode. Or you can open the files using notepad++, copy and paste the code into a base64 decoder, and look for the variables yourself.
I imagine he started encoding and obfuscating everything since cheats is a patreon thing haha. At one point i edited the files so that when i pressed the reset button on a skill it would return your points but also add 200 on top, he put anticheat in the non-cheat-patreon builds because that just gives you a false error about memory editing and a small thing at the bottom telling you not to use cheat engine because it can mess with the game in a wrong way, which isnt true if you know what you're doing.

When you say the base64 thing can I use the built-in plugin for Notepad++? It gives me some sort of error when i try:

upload_2018-10-6_14-29-30.png

Also, say I find these variables
How would I set them to a value I want with the console? Is it at all possible? I'm no coder but, i think the $ means it's jQuery, so can I even use the console for this at all?
 

HiEv

Member
Sep 1, 2017
384
778
When you say the base64 thing can I use the built-in plugin for Notepad++?
I don't know for sure what they're referring to as far as the base64 thing. I'm guessing it has to do with the save files, because it doesn't have anything to do with the HTML.

If you want to look in a Twine save file, it's probably easier to just open it here:


Also, say I find these variables
How would I set them to a value I want with the console? Is it at all possible? I'm no coder but, i think the $ means it's jQuery, so can I even use the console for this at all?
The "$" only means jQuery when it's by itself (i.e. "$(whatever)"). It normally means that it's a story variable. So "$PC.skill.sex" would be "SugarCube.variables.PC.skill.sex" in SugarCube v2 (NOTE: It's case sensitive, so "pc" isn't the same as "PC").
 

archoniq

Newbie
Sep 14, 2017
69
107
I don't know for sure what they're referring to as far as the base64 thing. I'm guessing it has to do with the save files, because it doesn't have anything to do with the HTML.

If you want to look in a Twine save file, it's probably easier to just open it here:



The "$" only means jQuery when it's by itself (i.e. "$(whatever)"). It normally means that it's a story variable. So "$PC.skill.sex" would be "SugarCube.variables.PC.skill.sex" in SugarCube v2 (NOTE: It's case sensitive, so "pc" isn't the same as "PC").
thanks for your reply! I see what you mean with the jQuery thing, although typing (As an example) SugarCube.variables.PC.skill.sex = 200 just returns an error, i dont think variables even is a thing under there anywhere upload_2018-10-7_13-23-18.png Must be ThaumX's custom obfuscation getting in the way :/

Both character presets and saves are obfuscated with something and I have no idea how to reverse it so, so don't think that one's viable.
 

HiEv

Member
Sep 1, 2017
384
778
thanks for your reply! I see what you mean with the jQuery thing, although typing (As an example) SugarCube.variables.PC.skill.sex = 200 just returns an error,
Sorry, that should have been "SugarCube.State.variables.PC.skill.sex", I forgot the ".State" part.

Both character presets and saves are obfuscated with something and I have no idea how to reverse it so, so don't think that one's viable.
Looks like he's encoding that data, but you should be able to get at the rest.
 

archoniq

Newbie
Sep 14, 2017
69
107
Sorry, that should have been "SugarCube.State.variables.PC.skill.sex", I forgot the ".State" part.


Looks like he's encoding that data, but you should be able to get at the rest.
upload_2018-10-7_16-13-33.png
Idk i think he also borked that on purpose
 

HiEv

Member
Sep 1, 2017
384
778
Idk i think he also borked that on purpose
I have the relatively ancient 0.04.1b version of "Accidental Woman", and "SugarCube.State.variables" works there. So if it doesn't work with your version, then yeah, he must have changed to using some other system.
 

TheGodUncle

Active Member
Dec 2, 2017
603
371
It may just be me but I always get an error using the console that says that sugarcube is not defined. Is there a way to fix this?
 

HiEv

Member
Sep 1, 2017
384
778
It may just be me but I always get an error using the console that says that sugarcube is not defined. Is there a way to fix this?
Well, first of all, it's "SugarCube", not "sugarcube". JavaScript is case sensitive, so capitalization matters.

Second, not all Twine games use the SugarCube story format. This means that for some Twine games, especially older ones, you can't use "SugarCube" to get or set the game's variables.

If it's telling you that "SugarCube" isn't defined, then that tells you it's using another Twine story format.
 

Shagmonkey

Newbie
Jul 29, 2017
45
5
You can also use this plug-in. Manually add it to your browser. Use CTRL+SHIFT+H while in-game to open it.
how would i add this to firefox kinda lost here and what do i add or do i just drag and drop the folder i extracked into it somewere.
 

HiEv

Member
Sep 1, 2017
384
778
how would i add this to firefox kinda lost here and what do i add or do i just drag and drop the folder i extracked into it somewere.
It doesn't appear to work well in Firefox. See .
 

Eoin

The Bug Hunter
Moderator
Donor
Feb 21, 2017
1,232
4,830
how would i add this to firefox kinda lost here and what do i add or do i just drag and drop the folder i extracked into it somewere.
It doesn't appear to work well in Firefox. See .
If you use firefox, you can manually change the elements via the console.
I made a video for a guy looking for help on how to do it using chrome. It works the same way on firefox (and any other browsers). That post is .
 
  • Like
Reactions: MisterHedonistic
Jul 3, 2017
41
24
I may suck and have very little idea what I am doing as I don't play many HDMI games and have no idea what I am doing with Javascript and the like. I'm having trouble activating Twine in and may need a little guidence on what I can do. Followed the guide, set everything up in extensions, went to my game, and... is there a menu of some sort that's supposed to open up? I did (CTRL+Shift+H) and saw on my elements (CTRL+Shift+I) that the extension was indeed activating every time I tried to open it, however I saw on the game no change. I'm not sure what's supposed to change since this is the first HTML game I am using Twine on, so a little help would be nice. Thank you.
 

HiEv

Member
Sep 1, 2017
384
778
Any known way to unlock the back button in games where it's disabled? It saves a lot of time.
Assuming it's a Twine game made using the SugarCube 2 story format, look for "Config.history.controls = false" and/or "Config.history.maxStates = 1" and delete those lines. For older SugarCube 1 games you'd remove "config.disableHistoryControls = true" and/or "config.disableHistoryTracking = true". (Covers options b and c in greyelf's list above.)
 
  • Like
Reactions: MisterHedonistic

xanthras

Newbie
Jan 4, 2018
35
1
Not too long ago my HTML games stopped working on Chrome. something about storage adaptors.
I downloaded the new chrome and still not working. I loaded Firefox and all the games work fine but now i cant modify anything in sugarcube.
How do i change it so i can modify the settings in Console for firefox.
OR how do i get my old Chrome version back so i can play HTML games on chrome?
 

greyelf

Well-Known Member
Nov 16, 2016
1,069
785
something about storage adaptors.
You need to state if you are running the web-browser on a Desktop or a mobile device, because mobile web-browsers have restrictions that desktop ones don't.

If you see that in Chrome then it's possible you have Cookies disabled, because for some stupid reason most web-browsers use that setting to also enable/disable Local Storage as well.

How do i change it so i can modify the settings in Console for firefox.
You should still be able to enter commands like SugarCube.State.variables.money = 10000 in Firefox's Console.