0 votes
by (1.1k points)
reopened by

I am new to JS and would like to ask a way to modify a variable of an object from an array of objects in twine using javascript.

<<set $testArray = []>>

<<set $testArray.push( {
    name: '',
    ID: 12
} )>>

So it's time for JS and HTML textbox.

1 Answer

0 votes
by (66.1k points)
selected by
 
Best answer

I answered your original question explaining what's wrong and how to work around it.

As far as your question here goes.  You may use State.variables to access your story variables within JavaScript.  For example, $myArray would be:

State.variables.myArray

Similarly, temporary variables may be accessed via State.temporary. For example, _myTempValue would be:

State.temporary.myTempValue

 

by (1.1k points)
Sorry I had not seen this before.
by (66.1k points)

Well, I had just answered, so it hadn't been there long. :)

PS: I edited my answer above to add some of the information you're looking for.

 

...