0 votes
by (8.8k points)

Dear Twinelords,

So I've built this array:

/* define a new array */
<<set $decisionLinkArray = []>>

/* populate the array with the correct value */
<<set $decisionLinkArray.push("setup.orcAttackDescriptions")>>

I test it's working with:


Which prints:  setup.orcAttackDescriptions

So far, so good!  Now I'd like to have my game print a random value from $decisionLinkArray[0].

I tried:

<<set $decision.linkText to Array.random($decisionLinkArray[0])>>

But when I test it with $decision.linkText, the game just prints a random character from the string setup.orcAttackDescriptions instead of printing a random value from setup.orcAttackDescriptions.  Is there a way to make it do the latter?

1 Answer

+1 vote
by (62.7k points)
selected by
Best answer
Is it literally printing "setup.orcAttackDescriptions"? Because that's probably not what you want. Lose the quotes around the setup variables in the push() call and see if that helps.
by (8.8k points)
Bingo!  Thank you.  :-)
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.