Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
georgewbush
Newbie
Posts: 13 Joined: Fri Nov 30, 2018 5:14 pm
Contact:
#1
Post
by georgewbush » Sun Jan 13, 2019 11:32 pm
Hi, I searched on the forum for a solution but they didn't work. What I am looking for is something like this:
Code: Select all
$ choice = renpy.random.choice(("pon", "ken", "jan"))
if choice == "jan":
"Jan!"
elif choice == "ken":
"Ken!"
elif choice == "pon":
"Pon!"
I use that code, but it ALWAYS shows "jan" as the random choice. Basically the last choice in the renpy choice list gets chosen.
I figure the code is out of date.
Are there any working codes to randomize a scene?
Imperf3kt
Lemma-Class Veteran
Posts: 3785 Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:
#2
Post
by Imperf3kt » Sun Jan 13, 2019 11:53 pm
Havent got time to look into it properly, but I think "choice" is one of the renpy reserved words.
Try using a different word.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project:
GGD Mentor
Twitter
Remix
Eileen-Class Veteran
Posts: 1628 Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:
#3
Post
by Remix » Mon Jan 14, 2019 6:34 am
renpy.random.choice is designed to work with rollback/forward so it actually stores and remembers the random value
It would *potentially* choose a different value if you started a new game
georgewbush
Newbie
Posts: 13 Joined: Fri Nov 30, 2018 5:14 pm
Contact:
#4
Post
by georgewbush » Mon Jan 14, 2019 8:41 am
Ok then that choice is no use for me because I need it to be random whenever it is called. I want to rollback and each time be a random scene not have to start a new game to see the other choices be picked.
Any new code for such a thing?
georgewbush
Newbie
Posts: 13 Joined: Fri Nov 30, 2018 5:14 pm
Contact:
#6
Post
by georgewbush » Mon Jan 14, 2019 7:52 pm
Thanks guys for your help! This forum rocks!
Users browsing this forum: Ahrefs [Bot] , Google [Bot]