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

macewindoom

Newbie
Nov 28, 2017
74
123
My old mac had a version of Twine that was an extension on chrome. All I had to do was click the icon an a menu for the variables popped up that I could manually input.

Anyone know where I could find that version?
 

Lure of Chaos

Member
Apr 21, 2020
113
99
While it it technically possible to gain access to the variable State of a Harlowe based project, doing so requires a lot more effort than it does with a SugarCube based project. Because Harlowe's engine:

1. has been deliberately designed to restrict an Author's ability to use JavaScript to access its internals.
2. has no documented JavaScript API, nor a "debug" object like SugarCube does.
3. uses a different type of History system than SugarCube, and if you don't know what you're doing it is easy to corrupt the historical state of "collection" based objects like Array & Data-map.

So if you're willing to edit the contents of the generated Story HTML file, or to de-compile and re-create your own HTML file. Then adding the following Scope Escalation Hack code to the Story JavaScript area of the project...
Code:
if (!window.Harlowe){
    window.Harlowe = {"State": State};
}
...will allow you to use Harlowe.State within your web-browser's Console to access the engine's State object.

What you do once you have access to the State object is not totally clear, because its structure was changed in the most recent versions of the Story Format.
have you tried use my extension? Google keeps rejecting it, but Moziila Store has it
please feedback about your dislikes
 

Space_Cow99

Member
Jul 26, 2019
362
205
Or not, go use save editor online somewhere html save can be modified. I found I don't need to use cheats which is not bad. twine hacker if there was way to create method not cheats but level easier. You need a programmer help modify game to where story nightmare, harder, and to normal to easy and no grind? <would be method.
 

greyelf

Well-Known Member
Nov 16, 2016
1,076
787
There are a number of different Story Formats (think game engines) that be used when creating a Twine based project, and the developer of each Story Format decides what features its engine includes and what run-time debugging options (if any) are available to the end-user.

Besides SugarCube, none of the other major Story formats include a run-time "debug" JavaScript API, and even SugarCube's is undocumented and hidden. So unless the Author of a project (that uses something other that SugarCube) decided to implement such (a) then you'll likely need to manually edit the Story HTML file itself. Or use your web-browser's Web Developer Tools to discover if parts of the project or the engine were unintentually left exposed.

(a) it is possible for a Harlowe project's Author to use a JavaScript Scope escalation hack before they generate the Story HTML file, which will make (some) of the engine's internals available at run-time.
 
  • Like
Reactions: Virus~

Virus~

Newbie
Jan 31, 2020
78
22
There are a number of different Story Formats (think game engines) that be used when creating a Twine based project, and the developer of each Story Format decides what features its engine includes and what run-time debugging options (if any) are available to the end-user.

Besides SugarCube, none of the other major Story formats include a run-time "debug" JavaScript API, and even SugarCube's is undocumented and hidden. So unless the Author of a project (that uses something other that SugarCube) decided to implement such (a) then you'll likely need to manually edit the Story HTML file itself. Or use your web-browser's Web Developer Tools to discover if parts of the project or the engine were unintentually left exposed.

(a) it is possible for a Harlowe project's Author to use a JavaScript Scope escalation hack before they generate the Story HTML file, which will make (some) of the engine's internals available at run-time.
NEVER MIND I JUST EDIT IT WITH DEVELOPER TOOLS
( ctrl + Shift + I )
Thanks for your response,
but how can i edit the html file? The save-
 
Last edited:

sadiyaflux

Newbie
Oct 18, 2020
29
29
NEVER MIND I JUST EDIT IT WITH DEVELOPER TOOLS
( ctrl + Shift + I )
Exactly =)

I'm not a web developer, so I cannot say to have insight into what SugarCube & Harlow actually do (aside from facilitating all the different states and providing the features we enjoy so much during play) - so take my words with the necessary grains of salt: Some authors have probably reacted to manipulation vectors like this.

Some new SugarCube-based versions don't allow you to even call up the "SugarCube.State.active.*" instruction, simply and without some modifications. The Harlow Format - usually - works. If not consider Greyelf's cool hack - which can also be "injected" via the console inside the Web dev tools of your browser.
 
  • Like
Reactions: Virus~

greyelf

Well-Known Member
Nov 16, 2016
1,076
787
Some new SugarCube-based versions don't allow you to even call up the "SugarCube.State.active.*" instruction, simply and without some modifications.
There are two series of SugarCube:
- The 1.x series, which is no longer being worked on, and was the one that was developed to be used with the discontinued Twine 1.x GUI application project. This is the series where the state of the "current" Moment can be accessed using SugarCube.State.active within a web-browser's Console, and the "current" state of all known Story variables be using SugarCube.State.active.variables

- The 2.x series, which is the series that is activity being worked on, and the one that is compatible with the Twine 2.x GUI application project. In this series the "current" state of all known Story variables should accessed using SugarCube.State.variables.
note: there is no need to include the .active reference.

Some SugarCube 2.x project Authors use JavaScript to disable the undocumented SugarCube debug object, which is why accessing the current state of Story Variables within those projects is difficult. But manually editing the Story HTML file will generally overcome those Author's attempts.
 

Virus~

Newbie
Jan 31, 2020
78
22
Exactly =)

I'm not a web developer, so I cannot say to have insight into what SugarCube & Harlow actually do (aside from facilitating all the different states and providing the features we enjoy so much during play) - so take my words with the necessary grains of salt: Some authors have probably reacted to manipulation vectors like this.

Some new SugarCube-based versions don't allow you to even call up the "SugarCube.State.active.*" instruction, simply and without some modifications. The Harlow Format - usually - works. If not consider Greyelf's cool hack - which can also be "injected" via the console inside the Web dev tools of your browser.
Well to be honest i tried i thought that i was successed but turns out that also was fale,
so... now how can i change some stuff like skill base or some many.. not much think but how can i do it??

What is harlow format and how to use it??
 
Apr 27, 2017
135
53
My old mac had a version of Twine that was an extension on chrome. All I had to do was click the icon an a menu for the variables popped up that I could manually input.

Anyone know where I could find that version?
I had that too SugarHack the name, i formated my pc and now it doens't work anymore, when click it nothing happens, you can try, not sure if it will work for you.
 
Apr 27, 2017
135
53
Anyone here knows why the twine hack and sugarhack extensions dont work anyome? I tried the twine in both chrome and firefox and it just dont work for me, the sugarhack too i used to be so easy to use.
 
  • Like
Reactions: AFuckingFox

greyelf

Well-Known Member
Nov 16, 2016
1,076
787
Anyone here knows why the twine hack and sugarhack extensions dont work anyome? I tried the twine in both chrome and firefox and it just dont work for me, the sugarhack too i used to be so easy to use.
Which Twine based project were you trying to hack?

(Not all projects built with Twine use the SugarCube Story Format)
 

Eagle1900

Engaged Member
Oct 7, 2022
3,191
16,464
I didn't know him, definitely an important help. thank you so much for sharing it.
just one question: can I use it with other games too, or does it only work with this one (which is already a lot of stuff)
 
Nov 22, 2021
67
179
I didn't know him, definitely an important help. thank you so much for sharing it.
just one question: can I use it with other games too, or does it only work with this one (which is already a lot of stuff)
I use this extension with many HTML games, so yes, you can use it with other games.
 

meth8472

Newbie
May 1, 2017
78
24
having problems in some games. found a new one with the path being "char" and the subfolders 0-9(10 chars) with the variables to change. but when typing in Sugarcube....etc and then try typing 0 after the . or 1 for char selection nothing comes up.

any ideas how to work with that kind of coding? maybe some brackets or whatever!? any help appreciated