Tool Twine(SugarCube) cheat script

Yanrishatum

New Member
Jun 4, 2018
10
34
This is a fairly simple script for Twine/SugarCube games that let you modify and freeze game variables.
I used it for a while with a few rewrites, and now it looks more or less presentable to release into the wild.

download.png
On example of Degrees of Lewdity table I use

Features
  • Lookup and editing of the Twine variables.
  • Freeze the variable to prevent it from changing
  • Additionally it's possible to freeze variable to only increase or decrease if it's a numeric value.
  • Prefixing value with _ will enable lookup in the temporary variable storage (in case primary storage have variables starting from _ - use $ prefix to specify it's a primary storage).
  • Supported types are: Numbers, text, dates, booleans.
  • Ability to save your table into local storage so you don't have to re-insert them on new sessions.
  • Additionally lets you share the table data as JSON.
  • When writing the variable names, lookup provides autocomplete and current value of the variables. Press tab to cycle through them.
  • Minor UX: Using mouse wheel while hovering over the numeric value will increment/decrement it.
  • Minor UX: When panel is minimized, it's still possible to toggle freeze state of the variables, and they will show their current value when hovered over.
Known issues/future plans
  • Uses Twine debug panel as a basis, and can break in some games due to lack of debug CSS or game author absolutely demolishing the general CSS that breaks the panel. I'll need to rewrite entire CSS part to make it work.
  • Some games do weird obfuscation and rename State.variables, for example I've seen it being changed to State.__getUpperName__, not much I can do about it other than add an exception lookup.
  • Finicky to launch, since you need to copy the script text, open console, and paste it here, and only then you get the panel. I may end up making it a userscript with wildcard loading rules, and then attempt to scan if it's a twine game, but I frankly don't want to do that, since it would cause it being loaded to every single website you visit, which is not good. I'm open to suggestions.
  • If I will find such a case, I'll add a limited support to function types.
  • May not work with old Twine versions that don't expose State.variables and instead use State.current.variables.
  • I probably will add some extra controls such as how much history snapshots Twine will hold (as that heavily impacts performance), and back/forward buttons regardless if they are enabled by game settings.
Installation
  1. Copy the script text into your clipboard (Ctrl+C)
  2. Open the developer console in your browser (Ctrl+Shift+I for Chrome / Ctrl+Shift+J for Firefox)
  3. Paste your script into the console and press Enter.
  4. Done! Enjoy your cheating experience. If I am to cheat, I'm doing so with comfort.
Download script:
Beta V2 version with new features/better compat: Changelog post

Usage
  • Write variable path in the input field and press Enter/plus button to add it to watch list.
  • Modify the variable from here. Not all variable types are supported.
  • Click on snowflake button to freeze/unfreeze the value.
  • Click the button near the snowflake to toggle between full freeze or to allow value to increase/decrease while frozen.
  • Press red cross to delete value from watch list.
  • Don't forget to press Save as to not loose your table on next session ;)
  • Press bug icon to toggle compact and full panel.
  • While in compact mode, you still can toggle the freeze state of the variables.
  • Cog button shows extra settings as well as sharing buttons.
    • Press Copy button to copy current table into clipboard.
    • Press Paste button and allow access to clipboard in order to load table from clipboard (it will use prompt if it won't get access)
    • Press Clear button to wipe the watch list clean.
    • Press Load button to load previously saved table from local storage.

You don't have permission to view the spoiler content. Log in or register now.
 
Last edited:

bonzz

Newbie
Mar 17, 2018
87
42
Pretty cool man, I was just looking into this, a bit tired of F12 so I looked into how sugarcube writes variables

I noticed a twine userscript for saving, right next where I was hoping to make a button, and I was thinking, this must have been done yet.. So I startpaged twine userscript and this post is on 2nd page 1st result :cool:

Cheers mate!

jupiler.jpeg


EDIT: Just tried it with Secretary, and works fine!

Screenshot_2020-11-13_17-57-47.png

Only thing I hoped for was creating new entries in sugarcube.state.variables.inventory, by copying a similar one. I'm missing 3 drugs, and I was hoping to create the entries..


Screenshot_2020-11-13_17-58-45.png


EDIT2: Nevermind I solved it like this:

Screenshot_2020-11-13_18-20-34.png

Bimbo gave me drugs like it was candy :D
 
Last edited:
  • Like
Reactions: dfman

fzdudesome

Member
Mar 9, 2018
430
316
So I tried to fiddle with the settings and it disappeared off to the right side. I can see the buttons on the edge, but I can't get it back into position
 

Yanrishatum

New Member
Jun 4, 2018
10
34
So I tried to fiddle with the settings and it disappeared off to the right side. I can see the buttons on the edge, but I can't get it back into position
What do you mean "off to the right side" exactly? It may break on some twine games because they heavily customize the CSS, so until its a reliable issue on specific game, I can't really help much here.
 

fzdudesome

Member
Mar 9, 2018
430
316
I tried it on Life Choices, made that post, and then tried it on a different game, so my understanding is a bit clearer now. Basically for some reason when I put it in Life Choices there's no bug icon/button to the left of the "watch" switch, instead it's below the "watch" switch (forcing the whole bar one line higher, for some reason) and it's a little blue square. When you mouse over it, it still says "toggle bar" but since it doesn't stick out to the left, when the bar moves off screen to the right, it doesn't stick back into the screen, so you can't click it to get the bar back.
 

konabwo

Engaged Member
Sep 19, 2020
2,480
711
eh...i need more guidance... when to press ctrl+c? nothing seem to happen...and i cannot download that .js script...(saved as .html)
 

bonzz

Newbie
Mar 17, 2018
87
42
eh...i need more guidance... when to press ctrl+c? nothing seem to happen...and i cannot download that .js script...(saved as .html)
Either copy paste the code into a new file, or just download it from gh raw

then open file with your favorite editor (I use atom) and select all, copy. when in game hit f12 > console tab and in the console paste + enter
 

Some Guy

New Member
Aug 6, 2016
9
21
Gave this a shot and liked what I saw, so I threw it into a userscript. It's currently set to load on every scope, but there's sanity checks to both ensure its a twine html, and that its using SugarCube. If you want to limit where it loads, just add @match in the header and set it to something like a root folder where you have all your twine games (file:///insertdriveletterhere:/folder/*). I personally use Violentmonkey for my userscripts, but it *should* work in the userscript extension/addon of your choice. Let me know if there's any issues with my implementation.
Edit: Just realized I screwed up the scope there, should be good now.
Yanrishatum, feel free to take my modifications for your own use if you develop this further.
 
Last edited:

depechedNode

Well-Known Member
Oct 10, 2017
1,779
3,717
Very useful script, I wish I had found it sooner, some games became even more enjoyable. Thank you very much for sharing.
 

Shagmonkey

Newbie
Jul 29, 2017
45
5
can you add a vid walkthrough or a few images with like a text file saying the step and maybe adding a pointer arrow as to what i need to insert this into like what tab??.
 

fzdudesome

Member
Mar 9, 2018
430
316
Beetle button to hide/bring out doesn't appear anymore when playing Life Choices again, though I'm not sure if that's a function of that game, or twine being updated. The rest works fine, but as soon as you collapse it you can't bring it back out again. It was working fine for a while though, not sure what might have changed.
 

malboroman

New Member
Aug 8, 2016
10
1
Still works but for some games I'm guessing the CSS messes with it so that once you add a value the new entry is cut in half.
 

malboroman

New Member
Aug 8, 2016
10
1
Gave this a shot and liked what I saw, so I threw it into a userscript. It's currently set to load on every scope, but there's sanity checks to both ensure its a twine html, and that its using SugarCube. If you want to limit where it loads, just add @match in the header and set it to something like a root folder where you have all your twine games (file:///insertdriveletterhere:/folder/*). I personally use Violentmonkey for my userscripts, but it *should* work in the userscript extension/addon of your choice. Let me know if there's any issues with my implementation.
Edit: Just realized I screwed up the scope there, should be good now.
Yanrishatum, feel free to take my modifications for your own use if you develop this further.
Tried using it with Tampermonkey on Chrome but doesn't seem to work. Is there a button combo I need to make it turn on?
 

sonicboomlast

New Member
Aug 16, 2017
3
0
@Yanrishatum:

Sorry to brother you but could you update the code since with the recent update of chrome there is an error on line 613: document.head.appendChild(fa); so it breaks the stylesheet and won´t load the buttons correctly.
The Error log says:
"Refused to load the stylesheet ' ' because it violates the following Content Security Policy directive: "default-src 'self' 'unsafe-eval' 'unsafe-inline'". Note that 'style-src-elem' was not explicitly set, so 'default-src' is used as a fallback."
 

Yanrishatum

New Member
Jun 4, 2018
10
34
sonicboomlast:
I guess you tried to use the script with an online version? Since error is fairly explicit (i.e. CORS being CORS).
Issue is caused because I attempt to embed the font-awesome icon font to get some of its icons (depending on Twine version - those icons can be present, but from my experience it's often not the case, and some even strip out debugger CSS, breaking the script completely).

tijger08:
I have a full rewrite of the script in the works for a while that would bring better compatibility with various games by not relying on Twine internal debugger styling, but no ETA when it'd be done. Issue you experienced just now is likely due to this particular game customizing their CSS (and a lot of twine devs are complete code monkeys when it comes to CSS).

I will also look into fixing the CORS issue by embedding the icons script uses, making it completely self-isolated. Again, no ETA on when I can finish the rewrite. It's about 80% done, but I'm more busy with other projects and primary work lately.
 

tijger08

Newbie
May 6, 2018
80
50
sonicboomlast:
I guess you tried to use the script with an online version? Since error is fairly explicit (i.e. CORS being CORS).
Issue is caused because I attempt to embed the font-awesome icon font to get some of its icons (depending on Twine version - those icons can be present, but from my experience it's often not the case, and some even strip out debugger CSS, breaking the script completely).

tijger08:
I have a full rewrite of the script in the works for a while that would bring better compatibility with various games by not relying on Twine internal debugger styling, but no ETA when it'd be done. Issue you experienced just now is likely due to this particular game customizing their CSS (and a lot of twine devs are complete code monkeys when it comes to CSS).

I will also look into fixing the CORS issue by embedding the icons script uses, making it completely self-isolated. Again, no ETA on when I can finish the rewrite. It's about 80% done, but I'm more busy with other projects and primary work lately.

Yanrishatum
Thanks for your message. I'll wait patiently.