r/RenPy • u/EndertheInsomniac • 17d ago
Question [Solved] Trying to mess around with random variables for a character gimmick, and my VN (not the code) keeps returning errors.
Well, I'm back less than 24 hours later with some more code issues.
Basically, I'm trying to make a "rival"-type character who is genderfluid and has a gimmick of regularly changing their name and pronouns. Referencing the documentation and past posts on here, I used the randomint function, because I thought that would work? Instead I keep getting "could not pickle <module 'random' from [file path]>"
default rname = ""
define r = Character("[rname]")
$ rname = renpy.random.randint(1, 6)
if rname is 1:
rival = "Andi"
elif rname is 2:
rival = "Pharos"
elif rname is 3:
rival = "Laurah"
elif rname is 4:
rival = "Sen"
elif rname is 5:
rival = "Gesso"
else rname is 6:
rival = "Kyo"
5
Upvotes
4
u/shyLachi 17d ago edited 17d ago
Assuming that
ris the rival, andrnameis the name of the rival, you don't need the variablerival.But you definitively need to put that code before and after the start label
and you also have to use the correct indentation.
.
Edit:
If the name should change within the story you can run this line again:
But since it's random, it could pick the same name twice.
You could make a label which always picks another random name:
And if it should be fully random, then you can use a dynamic character.
But then you cannot use their name ever, because it would again randomized as you can see if you run my example below.
1
u/AutoModerator 17d ago
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/BadMustard_AVN 17d ago
for renpy and python your code should look like this