Random variable text?

Hello, I would like to insert a random name variable string.

I have it working with numbers (so it changes every game as part of a background story chosen by the user), but I cannot seem to get it to work with text.

I’m not exactly sure where to store a variable like this, or how to call it. I also want it to be randomly generated per game.

For example:

Player chooses an occupation for a background story (let’s use Engineer). Let’s say there are 3 sub-occupations involved that are randomly generated (eg; Electrical Engineer, Mechanical Engineer, Chemical Engineer). I would like the game to randomly choose one of the sub-groups when a player selects the Engineer occupation.

This would be purely aesthetic at the moment, but if possible, I would also like to make very slight attribute modifications depending on the randomized sub-category.

Any help would be appreciated,

Thanks!


*temp engineer_1 "I am a Mechanical Engineer"
*temp engineer_2 "I am a Chemical Engineer"
*temp engineer_3 "I am an Electrical Engineer"
*temp player_occupation
*temp player_sub_occupation

*choice
   #Engineer
     *gosub random_engineer_type
     *set player_occupation "Engineer"
     *goto what_am_i

*label random_engineer_type
*temp n
*rand n 1 3
*set player_sub_occupation {"engineer_"&n}
*return

*label what_am_i
I am an ${player_occupation}
*line_break
${player_sub_occupation}

Something along those lines?
Copy and paste that code into here if you want to see it working.

There are definitely several ways of achieving this.

I’ll spitball what I might do. (I’m assuming you’re using the most recent version.)

startup.txt


*create engineer false
*create soldier false
*create scout false
*create pilot false
*create field "Unknown"
*create chemical false
*create mechanical false
*create electrical false

Blah blah blah, you choose to become an engineer.


*set engineer true

CO: "As an engineer, you'll be assigned a random field of specialization!" 
(I find that weird, since you should only be somewhere you're equipped to be in.)
You: "Sir, yes, sir!" (You might not actually be doing military shtuff, but whatever.)

The CO picks a random piece of paper out of a bag. (Very bureaucratic, huh?)
*rand field 1 3
*if field=1
   *set field "Chemical"
   *set chemical true
*if field=2
   *set field "Mechanical"
   *set mechanical true
*if field=3
   *set field "Electrical"
   *set electrical true

He looks at it. He looks at you.

"You are now part of the $!{field} Engineering Division."

Yay! You've been assigned to $!{field} Engineering!

Blah blah blah, you come across a stat mod scene!


*if (engineer)
   *if (chemical)
      *set statA +10
   *if (mechanical)
      *set statB +10
   *if (electrical)
      *set statC +10 

That’s how I might do it, though, I’ll reiterate that there are probably plenty of different techniques.

1 Like

Perfect.

Thanks for the help, guys!