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

James009

The Gravewalker
Jun 4, 2018
793
3,645
While the web-browser addon you're using is called "Twinehacker" it really should be named "SugarCubeHacker", because it really only supports one of the Story Formats that a Twine based project can be built with. eg. SugarCube.

Unfortunately for you the Twine project you're trying to hack was built using Harlowe, which doesn't include a JavaScript based debugging API like SugarCube does.
ok
 

kryanBR

Member
Jan 18, 2019
441
186
guys, how do i add sugar cube as an extension?
the files I am downloading are not working: the manifest file is missing.
I had got it on the notebook but on the pc it's difficult...
 

Davox

Well-Known Member
Jul 15, 2017
1,517
2,271
I'm playing The Company and when you dose characters the games gives you a choice between 2 outcomes. When you pick one outcome it becomes a variable, but the other one doesn't. I'm trying to figure out a way to swap the choice.

How can i add the other variable i.e. first choice is between coffe or a kiss. If I chose coffee I get the variable:

SugarCube.State.variables.mom.dosed.coffee=true

but the variable SugarCube.State.variables.mom.dosed.kiss does not show up in the console.

I tried this but it said kiss is not defined.
SugarCube.State.variables.mom.dosed.add(kiss)

Presumably its somehting to do with this:
You don't have permission to view the spoiler content. Log in or register now.
 

greyelf

Well-Known Member
Nov 16, 2016
1,072
787
but the variable SugarCube.State.variables.mom.dosed.kiss does not show up in the console.
warning: the following code examples have not been tested, they may contain syntax errors.

Based on the information you supplied the mom variable contains a JavaScript Generic Object with a dosed property, which in turn references a Generic Object with either a coffee or kiss property set to Boolean true.

Adding a new Boolean kiss property to the dosed Generic Object should be as simple as doing the following...

Code:
SugarCube.State.variables.mom.dosed.kiss = true
...however, depending on how the condition logic is structured in the game the above may not be enough to allow you to see the 'kiss' related outcomes.
eg. if the conditional code in the looks something like...
Code:
<<if $mom.dosed.coffee>>Do the "coffee" related thing...<<else>>Do the "kiss" released thing<</if>>
If the above situation you would need to remove the coffee property from the dosed object to achieve the "kiss" outcome, which you can do by using the JavaScript within the Console like so...
Code:
delete SugarCube.State.variables.mom.dosed.coffee
note: Some might suggest that you could also change the value of the coffee property to Boolean false, and that might work too depending on what condition logic the game's author has included in their project. However you stated in your original post that normally only one of the two different properties exists on the dosed object, and if the author used conditional code like the following...
Code:
<<if def $mom.dosed.coffee>>Do the "coffee" related thing...<<else>>Do the "kiss" released thing<</if>>
... then the "coffee" outcome would still be shown even though there is a kiss property set to true.
 
  • Like
Reactions: Davox

aiman35

Member
Sep 28, 2018
185
27
does anybody know theres one extension for like if we click on the extension it is will come out something like a cheat where you can edit some of the it name had a cube or something i can remember the extension is something like a red cube
 

BitterDevil

Newbie
Apr 6, 2017
76
32
can someone post the sugarcube hacker cxr here? I changed my PC and now i can't find it anywhere on the web :(
 

Teshay

Newbie
Aug 14, 2017
42
79
Here is my copy of sugar cube hacker. Just extract and drag the 3.0.2_0 to you extension page. I hope this helps.
I'm using opera and when I tag that to my extension page it just makes a new tab, I've never done this before is that what is supposed to happen?
 

Lizard2214

Member
Feb 8, 2020
138
120
"The " Game" is very poor. Working everyday 12hours 8am-20pm stores are open from 9 to 18 and can buy only 3 items.
Nothing really interesting exept events at work ( notoriously repeated )
 

tijger08

Newbie
May 6, 2018
80
50
Dear people. I've tried everything discussed here in this thread. But nothing seems to work I use chrome as browser. thanks for the support
 

greyelf

Well-Known Member
Nov 16, 2016
1,072
787
Dear people. I've tried everything discussed here in this thread. But nothing seems to work I use chrome as browser. thanks for the support
Which game are you playing, and what exactly are you trying to alter?
 

Davox

Well-Known Member
Jul 15, 2017
1,517
2,271
I'm playing https://f95zone.to/threads/a-photographers-lies-v1-40-0-skullcam37.52597

In chapter 7 there is a a new mechanic to unlock pictures however it appears to be RNG whether you see anew image of not, so its a massive pain to unlock new new images. When you see a new image it gets dropped in as a variable undera new collection attribute

If i was unlocking an image for the third time the collection id would be [2] (starts from 0) and the img value would be 1-6 (they don't unlock in order) Collection 2 doesn't exist until the new image is triggered.

This is what i was trying:

SugarCube.State.variables.newStudio.contacts.cassidy.shoots.porn.housewife.collection[2].value=100 (amount doesn't mater)
SugarCube.State.variables.newStudio.contacts.cassidy.shoots.porn.housewife.collection[2].img=2

and this is the resulting error.
Uncaught TypeError: Cannot set properties of undefined (setting 'value')

This is the chain of variables under .housewife

housewife:
additionalContent: 12
cf: 50
collection: Array(6)
0: {img: 3, value: 500}
1: {img: 1, value: 436}
length: 2
[[Prototype]]: Array(0)

How do I cheat the variables to make it look like i've seen the new pictures?
 

Alcahest

Engaged Member
Donor
Game Developer
Jul 28, 2017
3,122
4,027
I'm playing https://f95zone.to/threads/a-photographers-lies-v1-40-0-skullcam37.52597

In chapter 7 there is a a new mechanic to unlock pictures however it appears to be RNG whether you see anew image of not, so its a massive pain to unlock new new images. When you see a new image it gets dropped in as a variable undera new collection attribute

If i was unlocking an image for the third time the collection id would be [2] (starts from 0) and the img value would be 1-6 (they don't unlock in order) Collection 2 doesn't exist until the new image is triggered.

This is what i was trying:

SugarCube.State.variables.newStudio.contacts.cassidy.shoots.porn.housewife.collection[2].value=100 (amount doesn't mater)
SugarCube.State.variables.newStudio.contacts.cassidy.shoots.porn.housewife.collection[2].img=2

and this is the resulting error.
Uncaught TypeError: Cannot set properties of undefined (setting 'value')

This is the chain of variables under .housewife

housewife:
additionalContent: 12
cf: 50
collection: Array(6)
0: {img: 3, value: 500}
1: {img: 1, value: 436}
length: 2
[[Prototype]]: Array(0)

How do I cheat the variables to make it look like i've seen the new pictures?
Index 2 doesn't exist, so you can't set properties for it. But I think this should work:
SugarCube.State.variables.newStudio.contacts.cassidy.shoots.porn.housewife.collection[2] = { img:2, value:100 }
 
  • Like
Reactions: Davox

greyelf

Well-Known Member
Nov 16, 2016
1,072
787
How do I cheat the variables to make it look like i've seen the new pictures?
I don't know the specifics of the game you're trying to alter the variables of but based on the information you've provider the data-type of the collection property is a JavaScript , which means you need to use the function to add additional elements to it.

So if the rest of your SugarCube debug object reference is correct, then the end of it should look something like...
Code:
collection.push( { img:2, value:100 } )
note: Often simply using the web-browser's 'page refresh' feature/key is enough to change the result of a RNG determined outcome in a SugarCube based project. Have you tried doing that when the Passage that shows the images is displayed?
 
Last edited:
  • Like
Reactions: Alcahest

thebumpinthenight

New Member
Jan 20, 2018
2
0
What is the format to remove a value from an array? I want to see what happens when I remove a value but can't get the syntax correct. :-/
 

greyelf

Well-Known Member
Nov 16, 2016
1,072
787
What is the format to remove a value from an array?
Normally deleting an element from a JavaScipt is more complex that you'd expect, however the developer of the SugarCube story format has been nice enough to add a number of 'delete' element related functions to its variation of that Array data-type, one of them is the function.

So if the project has an Array variable named $list that contains initialised as follows...
Code:
<<set $list to ["one", "two", "three"]>>
...then you could use a command like the following within your web-browser's Console to delete the "two" value from the array...
Code:
SugarCube.State.variables.list.delete("two")
 
  • Like
Reactions: thebumpinthenight

itsmbk

New Member
Jan 20, 2022
5
0
Hey everyone,
I`m playing x-change life for a while now and i'm trying different inputs in the console but none of them seems to work.
Any help is appreciated. :D Thanks in advance
 

greyelf

Well-Known Member
Nov 16, 2016
1,072
787
I`m playing x-change life...trying different inputs in the console but none of them seems to work.
Twine supports a number of different Story Formats, SugarCube being one of them, and each story format is a self contained mini web-application that defines the features available to the Author.

Based on the meta-data stored in the project's <tw-storydata> element it was built using the Harlowe story format...
Code:
<tw-storydata name="X-Change Life" ... creator="Twine" creator-version="2.3.16" ... format="Harlowe" format-version="3.2.3" ...>
...which unfortunately doesn't include an equivalent of the SugarCube debug object/interface, nor does it have a documented JavaScript API.

There is a scope escalation hack that an Author can use to expose the Story Variable State/History in the Console, however after doing a quick review of the custom JavaScript included with this project it doesn't appear that the Author hasn't done that.