Choosing more than one out of a list of several choices

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.
Post Reply
Message
Author
User avatar
sempersapiens
Regular
Posts: 47
Joined: Mon Jun 30, 2014 4:31 pm
Location: Canada
Contact:

Choosing more than one out of a list of several choices

#1 Post by sempersapiens » Tue Jul 29, 2014 1:24 am

I want to have a feature in my game where the the player chooses the character's schedule for the week, like in Long Live the Queen and other such games. I've been following Aleema's tutorial on using imagemaps, and I think I've gotten the hang of the hotspots and everything. But what I can't figure out how to do is allow the player to choose multiple hotspots on the map before it leads to the result, and also restrict which choices can and can't be selected at the same time.

Here is the ground file of my imagemap (I know it's kind of messy, but it's just for practice):
!ground.png
I want the player to be required to choose one of the two options for Monday during the day, one of the two options for Monday during the night, one of the two options for Tuesday during the day, etc. I want to make sure that you can't select both of one time period's options at once (e.g. you can't attend class on Monday morning while relaxing on Monday morning at the same time), and that you have to select one for each before continuing. Does anyone know how I should code this?

User avatar
akemicchi
Veteran
Posts: 465
Joined: Mon Dec 31, 2007 11:22 pm
Projects: Magicians of Delphine, Panaderia: Ensaimada, SweetTooth!, XOXO Droplets
Deviantart: littlebabyshoes
Contact:

Re: Choosing more than one out of a list of several choices

#2 Post by akemicchi » Tue Jul 29, 2014 1:53 am

Just wondering, but do you already have a working system for imagemaps with just one choice? Like, one action per day, as opposed to two actions per day?

The simplest way I can think of would be-- instead of returning results immediately-- you using SetVariable to change the values of certain variables. Once all the variables have values, you have a button appear to confirm and continue on to the next screen. You evaluate the variables as opposed to the Return.

Monday's hotspots, for example, would have variables monday_day, which would have the value of either 'Lit Class' or 'Relax', and monday_night, with the possible values of 'Study', and 'Relax'. You'd do this for all the days. You have a conditional statement evaluating that the variables monday_day, monday_night, tuesday_day, etc all don't return a value other than None, and have a button appear to continue. Hmm, let whip something up really fast.

Code: Select all

        hotspot (740, 232, 75, 73) clicked SetVariable("monday_day", "Lit Class")
        hotspot (832, 232, 75, 73) clicked SetVariable("monday_day", "Relax")

        hotspot (1074, 232, 75, 73) clicked SetVariable("monday_night", "Study")
        hotspot (1166, 232, 75, 73) clicked SetVariable("monday_night", "Study")
    
    if monday_day and monday_night: # If there's a value for monday_day and monday_night, show the button to continue
        window:
            xalign 0.8 yalign 0.8
            textbutton "Continue" action Return()
Like something like this, maybe? That's the general gist of it, anyway; I haven't tested it. If you already have a working system, though, it might be easier to think of more suitable code.

User avatar
sempersapiens
Regular
Posts: 47
Joined: Mon Jun 30, 2014 4:31 pm
Location: Canada
Contact:

Re: Choosing more than one out of a list of several choices

#3 Post by sempersapiens » Tue Jul 29, 2014 2:24 am

I didn't have a working system yet, so that seems to be exactly what I'm looking for! I'm getting an error message when I try it, though. Do you know what this means the problem is?
Attachments
renpyerror.png

User avatar
akemicchi
Veteran
Posts: 465
Joined: Mon Dec 31, 2007 11:22 pm
Projects: Magicians of Delphine, Panaderia: Ensaimada, SweetTooth!, XOXO Droplets
Deviantart: littlebabyshoes
Contact:

Re: Choosing more than one out of a list of several choices

#4 Post by akemicchi » Tue Jul 29, 2014 2:42 am

Ahh, it's not supposed to be clicked, but action.

Code: Select all

hotspot (85, 105, 70, 90) action SetVariable("monday_day", "Lit Class")
It should work now. :)

User avatar
sempersapiens
Regular
Posts: 47
Joined: Mon Jun 30, 2014 4:31 pm
Location: Canada
Contact:

Re: Choosing more than one out of a list of several choices

#5 Post by sempersapiens » Tue Jul 29, 2014 10:50 am

Oh of course! That makes sense. Thanks so much for your help!

Edit: Oh dammit. Changed that, and I'm still getting "'StoreModule' object has no attribute 'monday_day'."

Edit2: Figured it out, I was being an idiot and not setting the variables to 0 before calling the imagemap! It's working now! Thanks again.

Post Reply

Who is online

Users browsing this forum: Google [Bot]