And then there is a passage titled “NamesArray” with a list of names, 1 per line.
Tagged ‘array’ not sure if that matters or if it’s just for documentation purposes.
This is my current error code:
Error: <<Names>>: error within widget code (Error: <<run>>: bad evaluation: Cannot read properties of undefined (reading 'random'))
At this point, I’ve tried multiple ways of calling this in, and don’t recall them all (lol), so I’m coming here hoping someone might see what I’m missing!
Ah, a passage isn’t an array. To create an array you’d need to do something like:
<<set $NamesArray to [ "Fred", "Linda", "Bill" ] >>
You probably want to put this in a passage named StoryInit so it’ll be run once when your game starts and will always be set.
And if the names never change, you might want to use the setup object (set with <<set setup.Names to [ ... ]>> and use with <<run setup.Names.random()>>) so it doesn’t get saved in the game’s history every turn. This doesn’t usually matter but if you have a really huge game sometimes they’ll slow down because there’s so much stuff in the history, so it’s not a bad habit to get into.