Using Array.push/pluck for Status Effects

Twine Version: Online Version
Story Format: SugarCube

In StoryInit Ive already set up a Status area.
<<set $stats = []>>

Now I’m trying to assign a Stat for the Character when they drink Alcohol in the Game by using the Push function.
<<set $stats.push(“Tipsy”)>>

I end up getting the same Error.
Error: <<set>>: bad evaluation: State.variables.stats.push is not a function. (In 'State.variables.stats.push("Tipsy")', 'State.variables.stats.push' is undefined)

Help LOL? Probably a noobish Question

This is probably because you have curly quotes in your example, which are invalid in Twine.You should change them to straight quotes: <<set $stats.push("Tipsy")>>.

Interestingly, when I tested your original example in the online Twine editor, I got a different error message that clearly identified the curly quotes as the issue (Error: <<set>>: bad evaluation: illegal character U+201C). Is the code you’ve quoted exactly what you’re using in your game?

(Also, a hint - best put only the code part of your post inside the “preformatted text” tags, it makes it easier to read, esp. on mobile.)

1 Like

Thank You!
I realized what I was doing wrong after reading your comment.

And also thanks for the Hint. I Code and type these Questions on a IPad