CREATE YOUR AI CUM SLUT ON CANDY.AI TRY FOR FREE
x

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

xanthras

Newbie
Jan 4, 2018
40
1
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.
I am running on desktop, sorry for the confusion. And no i cannot still modify perameters with that command on firefox.
 

xanthras

Newbie
Jan 4, 2018
40
1
I am running on desktop, sorry for the confusion. And no i cannot still modify perameters with that command on firefox.
Also, i went through ALL my chrome settings and disabled anything that restricts cookies. still will not run
 

HiEv

Member
Sep 1, 2017
384
785
Also, i went through ALL my chrome settings and disabled anything that restricts cookies. still will not run
Really, it's "local storage" that needs to be enabled, not necessarily "cookies".

Also, make sure you're not opening the games in an "incognito" window, since that will prevent the game from using local storage.

Two things to try:
1) Disable all extensions you have to see if that fixes things. If so, then you'll need to go through and figure out which one(s) are causing the problem.
2) After opening a Twine game, take a look in the console window (F12 then pick "Console" from the menu) to see if there are any error messages which explain the problem(s).

For reference, I have no problems opening Twine games in Chrome on my desktop PC, so it's something peculiar to your setup.
 

Carrnage

New Member
Sep 30, 2017
10
5
the firefox console only has command and reading capability, you can't just select a value to change it you need to type out the command.
 

greyelf

Well-Known Member
Nov 16, 2016
1,088
817
how do you change the time on sugarcube?
That would depend on which game you are playing, because it's up to the game's developer to decide how they want to track things like 'time' within their project. But it is likely that they will be using one or more story variables to store it, however what the name(s) of the variable(s) is/are will likely be different for each game.

How you use use your web-browser's Console to access the game's variables depends on which series of SugarCube was used to create the game.

a. For a SugarCube 2.x based game
Code:
/* to access ALL variables. */

SugarCube.State.variables

/* to access the current value of a variable named 'hours' */

SugarCube.State.variables.hours

/* to change the current value of a variable named 'hours' to 12 */

SugarCube.State.variables.hours = 12
b. For a SugarCube 1.x based game
Code:
/* to access ALL variables. (note the letter casing of 'state') */

SugarCube.state.active.variables

/* to access the current value of a variable named 'hours' */

SugarCube.state.active.variables.hours

/* to change the current value of a variable named 'hours' to 12 */

SugarCube.state.active.variables.hours = 12
 

Carrnage

New Member
Sep 30, 2017
10
5
okay i've figured out you can change an array value by altering it as a big block (ex: =["123,456,789"]) but does anyone know how to edit a set?
 

HiEv

Member
Sep 1, 2017
384
785
okay i've figured out you can change an array value by altering it as a big block (ex: =["123,456,789"])
FYI - If you wanted three separate strings within that array, then you'd want =["123", "456", "789"]

but does anyone know how to edit a set?
You can add items to a set using SugarCube.State.variables.setName.add(value), delete items from a set using SugarCube.State.variables.setName.delete(value), and if you want to create a new set you can do SugarCube.State.variables.setName = new Set([value1, value2, value3]). (See the JavaScript documentation.)

Hope that helps! :)
 
  • Like
Reactions: Carrnage

lightpurple

Newbie
May 19, 2019
16
5
Is there a way to jump to a specific passage from the browser dev tool console?

I can find the passage names from SugarCube.Story IIRC or more easily by decompiling with tweego, but except for editing the html at some known location i.e. the Home passage/location and manually inserting something similar to [[Jump to interest|SceneA]][[$var = somevalue]] which is very tedious (but works), I am not sure what to do.

There is a SugarCube.Scripting.evalTwineCode function, or similarly named) but using "[[SceneA]]" as an argument doesn't work.

And seeing as this is about cheating variables, some are set in passages as they are interpreted i.e. <<set $var to random(5)>>, I'm guessing there is no way to affect that from the browser?

(Perhaps I could add everything directly to the decompiled file? but I haven't tried compiling one back and dev console seems like it should have the option. And knowing nothing of webdev trying to put breakpoint on event listeners didn't work, and the minified code is unreadable)

Thanks.
 

greyelf

Well-Known Member
Nov 16, 2016
1,088
817
Is there a way to jump to a specific passage from the browser dev tool console?
You can use the to force a Passage Navigation to occur. To access that API function (or any other) from the Console while running the game you will need to use the (undocumented) SugarCube debug object like so.
Code:
SugarCube.Engine.play("Visit therapist")
Obviously the game's logic may not behave as expected after you do such a navigation, possible due to the game's variable state being invalid for the target Passage. And you will need to know the correct Name of the target Passage.
 

LordAkkarin

New Member
Sep 23, 2018
5
1
Is there any way to cheat in an Harlowe game? I tried to edit the tags <tw-passagedata> but nothing happens, even though the same thing in SugarCube is enough. I have the feeling that it somehow preload everything. Of course editing the html works, but it's too annoying for me.
 

LordAkkarin

New Member
Sep 23, 2018
5
1
By "cheat" do you mean the ability to change the current value of a story variable?
Mainly that, but also the possibility to change everything else, like adding a link that wasn't there, change the logic flow of the program removing some if or changing the condition inside it, ecc...
 

greyelf

Well-Known Member
Nov 16, 2016
1,088
817
Mainly that
Harlowe doesn't have a documented JavaScript API and its engine has been deliberately designed to restrict what access an Author or Player has to its internals, it also doesn't have an equivalent of the SugarCube run-time (undocumented) "debug" JavaScript API.

This means that you would need to use JavaScript hacking techniques (like scope escalation) to be able to access those internals, and some of that hacking needs to be done within the contents of the project's Story JavaScript area so that you can use the results at run-time.
eg. before a story HTML file is created for the project.

... like adding a link that wasn't there, change the logic flow of the program removing some if or changing the condition inside it, etc...
These types of changes require modifying the contents of the Passage itself, and while it is possible to do that at run-time by using JavaScript to dynamically edit the contents of the <tw-passagedata> elements found within the story HTML file's <tw-storydata> element, it is far easier to first decompile the story HTML file back into your own Twine or TWEE project which you can then edit before compiling your own variation of the story HTML file.

How you do that decompiling depends on if you prefer to work with:

a. your own Text Editor

Use a TWEE command line utility like Tweego to generate a TWEE file from the story HTML, and to create a story HTML file once you've finished editing the TWEE file. This option works for both Twine 1.x and Twine 2.x based story HTML files.

b. with a Twine GUI based editor.

Harlowe is a Twine 2.x only story format so you would use the Import From File option of the Twine 2.x application to create a new project based on the existing story HTML file. If the story HTML file was creates using any other story format then you would need to first determine with series of Twine (1.x or 2.x) was used to generate it, because you need to use the association Twine application to import the contained metadata into a new projects.

eg. If it is a Twine 1.x series story HTML file then you need to use the Twine 1.x application, and the Twine 2.x application if it is a Twine 2.x series story HTML file.

(the Twine 2.x application is NOT a later version of the Twine 1.x application, they are two different applications that can be used to edit Twine projects and to generate story HTML files.)
 
  • Like
Reactions: LordAkkarin
Aug 24, 2017
92
53
Sorry to be a dunce right now but I'm not finding how I would add this to my browser.
Currently using Chrome and everything I look up says to add the .cxr file to my extensions but I'm not getting this to work.


Thanks
Last guy might never have done tech support.

First download, and unpack or extract the contents of that extension to a folder.

Next open Google Chrome and enter the following in to your address bar:

chrome://extensions/

Once you're at that page, make sure developer switch is toggled "on" at the top right. This will make the "load unpacked" extension button appear.

Click that button, then point it at the folder where you unpacked your extension.

And that should integrate the extension in to chrome for you. an icon appears for me at the top right of the screen. Doesn't work, but it is installed.

*shrugs*
 
  • Like
Reactions: MonteChristo

Lure of Chaos

Member
Apr 21, 2020
122
118
I've placed it at and i'll try keep it updated with this thread aside bugfixing it myself.

For now, i've changed to use common code base to work with Chrome and Firefox so no separate downloading.
Also there is minor fix to work with some games such as Inheritance
But i'm very disappointed that sometimes you have to scroll through object properties, which seems to be impossible as of small height (at least at Chrome) - maybe someone would point me how to fix it with CSS?..