Help gang!
I know there has to be a way to do this but I'm too smart to figure this out.
What I'd like to do is have two image buttons from a list of characters so that you can click each one to jump to an event. I want to make these characters randomly picked when you come into the "room" and not pick the same character in both slots ever.
Example:
List one: Jessica, James, John, Mike, Robert, and Michelle
List two: Jessica, James, John, Mike, Robert, and Michelle
I want it to pick one from list one, and then one from list two, but never have Mike (or whoever) picked in BOTH lists, only one. These would appear as imagebuttons for each character as in:
imagebutton auto "maps/peaseyhouse/buttons/mike_%s.webp" action Jump ("mdiningroom") xalign 0.5 yalign 0.97
imagebutton auto "maps/peaseyhouse/buttons/jessica_%s.webp" action Jump ("jdiningroom") xalign 0.5 yalign 0.97
I'm certain there must be a way. Hope you can help!
Thanks in advance!
Problem: Random buttons or image buttons.
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.
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.
-
- Newbie
- Posts: 9
- Joined: Fri Aug 02, 2019 1:53 am
- Projects: the Neighborhood
- Contact:
- Per K Grok
- Miko-Class Veteran
- Posts: 882
- Joined: Fri May 18, 2018 1:02 am
- Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
- itch: per-k-grok
- Location: Sverige
- Contact:
Re: Problem: Random buttons or image buttons.
You can use this to pick random names where nameA and nameB will never be the same.LongHairRkr wrote: ↑Thu Apr 16, 2020 7:51 pm Help gang!
I know there has to be a way to do this but I'm too smart to figure this out.
What I'd like to do is have two image buttons from a list of characters so that you can click each one to jump to an event. I want to make these characters randomly picked when you come into the "room" and not pick the same character in both slots ever.
Example:
List one: Jessica, James, John, Mike, Robert, and Michelle
List two: Jessica, James, John, Mike, Robert, and Michelle
I want it to pick one from list one, and then one from list two, but never have Mike (or whoever) picked in BOTH lists, only one. These would appear as imagebuttons for each character as in:
imagebutton auto "maps/peaseyhouse/buttons/mike_%s.webp" action Jump ("mdiningroom") xalign 0.5 yalign 0.97
imagebutton auto "maps/peaseyhouse/buttons/jessica_%s.webp" action Jump ("jdiningroom") xalign 0.5 yalign 0.97
I'm certain there must be a way. Hope you can help!
Thanks in advance!
Code: Select all
default listA=["Jessica", "James", "John", "Mike", "Robert", "Michelle"]
default listB=[0,1,2,3,4,5]
default pickA=0
default pickB=0
default nameA=0
default nameB=0
label start:
$ listB=[0,1,2,3,4,5] ### reset listB
$ pickA=listB.pop(renpy.random.randint(0,5)) ### pick random from full list and remove chosen
$ pickB=listB.pop(renpy.random.randint(0,4)) ### pick random from decimated list
$ nameA=listA[pickA]
$ nameB=listA[pickB]
"[nameA]:[nameB]" ### show result
jump start
Code: Select all
if pickA==0:
imagebutton auto "maps/peaseyhouse/buttons/jessica_%s.webp" action Jump ("mdiningroom") xalign 0.5 yalign 0.97
elif pickA==1:
imagebutton auto "maps/peaseyhouse/buttons/james_%s.webp" action Jump ("mdiningroom") xalign 0.5 yalign 0.97
-----
-
- Newbie
- Posts: 9
- Joined: Fri Aug 02, 2019 1:53 am
- Projects: the Neighborhood
- Contact:
Re: Problem: Random buttons or image buttons.
That worked beautifully! Thank you SO much!!
Who is online
Users browsing this forum: Google [Bot]