One of the really cool features I've discovered is being able to use a loop to set data for an array. However, I seem to have hit a road block with something that seems logical but just isn't working.
Scenario: I have several "suspects" in my game and that all have a set of eleven attributes. So I have set each of these attributes as an array and am using a loop to add data to each them as an action in a setup task.
So, this works:
- adrift Code: Select all
FOR %Loop% = 1 to 7:
SET susGender[%Loop%] = EITHER("female","male"):
NEXT %Loop%
Next, I want to choose a random first name based on each gender. So, I set this action:
- adrift Code: Select all
FOR %Loop% = 1 to 7:
SET susName[%Loop%] = IF(%susGender[%Loop]%="female",%femaleNames[RAND(1,30)]%,%maleNames[RAND(1,30)]%):
NEXT %Loop%
When I run this code I either get a hung Runner or sometimes I would get this message:
BAD EXPRESSION: If (susGender[1]="female","Cheryl","Peter")
I've checked syntax structure for IF expressions and ensured that the arrays have initial data so they are correct. From the above message, I'm assuming that I have the syntax correct, so am I missing something?
