I want to make one of my gender-interchangable characters random depending on a certain choice. How do I code it?
Although I never used it before, there is a command that could generate a random number. This is the *rand command. The structure of this command goes as follows:
*rand x y
x and y refer to the range. So, for example, your character is rolling dice, you can set it to “*rand 0 6.” It can be used in startup variables and *temp variables. I never used this command before and I only know how it works. For more information, try checking out it’s wiki page https://choicescriptdev.fandom.com/wiki/Rand
Since you want a random gender you can do *rand 0 1 and 0 can refer to male and 1 to female.
*rand gender 0 1
*if gender = 1
*set gender “female”
*if gender = “0”
*set gender “male”
There are a few ways to do this. One would be:
*create gender_number 2 *create gender "female" *rand gender_number 1 2 *if gender_number = 1 *set gender "male" *if gender = "female" She opens the door. *if gender = "male" He opens the door
Alternatively, create more variables for “she” “her” “hers” and have them switch. It all hinges on using the rand command.
Thank you both! Really appreciate it.
Since you said:
You could do something like this
What's your gender? *choice #Female *set friend_him "her" *set friend_he "she" *set friend_his "hers" *set friend_gender "female"" #Male *set friend_him "him" *set friend_he "he" *set friend_his "him" *set friend_gender "male"
You can change the following to your liking. It should allow you to change the gender accordingly.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.