I am planning to do a similar thing to this a few times in my current (and first) project. Basically there is an invisible roll happening determining a variable that will influence some choices and outcomes for the player. This first one sets the player’s ‘‘homeland’’. The result will not be directly told to the player but revealed indirectly (with changes in the text).
But I can’t figure out the code to 1 do a diceroll for determining which of 6 nations is the homeland.
I have tried to phrase this in my script in several different ways but I keep getting error messages.
The error I’m currently getting is: ''invalid expression, couldn’t extract another token ‘‘USA’’. If I switch USA in the Create Homeland line with a number, the same error shows up later in the code when the Nation roll should be converted to the actual name.
My code now looks like this:
*create nation 1
*create homeland ‘‘USA’’
*rand nation 0 5
*if nation = 0 Set ${homeland} USA
*elseif nation = 1 Set ${homeland} Russia
*elseif nation = 2 Set ${homeland} UK
*elseif nation = 3 set ${homeland} France
*elseif nation = 4 set ${homeland} China
*elseif nation = 5 set ${homeland} India
I can’t figure out where my logic is faulty in interpreting the text, and the various tutorials I have found all seem to point to either purely using numbers, having the player choose from options or the player putting in text. I have tried several variations with quotation marks, brackets and a few other factors.
I’m sure the way to do this is fairly obvious, but after a few days of slamming my head against the door I really need some aimed pointers. How do I get the game to randomly choose one of several options?
Now I get ‘‘couldn’t extract another token’’ when ${homeland} gets checked and selected. It seems when I use ${homeland}, the problem is that (presumably) either $ or {} are not english alphabet letters, but removing them means the variable must be numeric.
It took significantly more trial and error then is reasonable. But it turns out my problem was in fact in how I type quotation marks. I am used to just pressing the button twice, leading to:‘’ but it needs to be shift+the button to make ". Yeah, I don’t see the difference either but the code sure does. For those curious this is what the code now looks like (for just three nations).