Menu options changing or triggering when location is clicked
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.
Menu options changing or triggering when location is clicked
I have been progressing quite well on my VN with the help of some people here and I greatly appreciate that.
What I would like to do next is learn how to indicate an object or area of the screen that if clicked in that "scene" will trigger a jump to a new label.
For example, lets say I have a character that the player has just met and through the course of the scene they can simply just talk to the person as normal, following the story or making menu selections. However, if the player clicks on something in the scene (Lets say, a tree in the back ground or a bracelet the character is wearing) the script will jump to a label.
The intention is to allow the player to change the direction of the story by clicking things in the back ground to investigate them, possibly even just reloading the current menu with a new choice based on what they found or changing a flag to direct the flow of the story later.
Can anyone help with this?
What I would like to do next is learn how to indicate an object or area of the screen that if clicked in that "scene" will trigger a jump to a new label.
For example, lets say I have a character that the player has just met and through the course of the scene they can simply just talk to the person as normal, following the story or making menu selections. However, if the player clicks on something in the scene (Lets say, a tree in the back ground or a bracelet the character is wearing) the script will jump to a label.
The intention is to allow the player to change the direction of the story by clicking things in the back ground to investigate them, possibly even just reloading the current menu with a new choice based on what they found or changing a flag to direct the flow of the story later.
Can anyone help with this?
- chocoberrie
- Veteran
- Posts: 254
- Joined: Wed Jun 19, 2013 10:34 pm
- Projects: Marshmallow Days
- Contact:
Re: Menu options changing or triggering when location is cli
You could make a certain location on the screen into a hotspot using imagemap coding, then call that imagemap using screen language in the script. When the player clicks on the hotspot, you could include a label jump using if/elif.
For example (the code is from this page in the Ren'Py documentation):
The numbers are the hotspot coordinates for the variables labeled "eileen" and "lucy." So the ground image has "eileen" on it (and would show the Eileen sprite as a part of the ground image itself) and the selected image has "lucy" on it. Then, you could call either "eileen" or "lucy" in the script using if/elif. Within that, you can include label jumps, like this:
I'm pretty sure the $ result portion goes in the init block before label start, and the if/elif portion goes in the script, after label start.
I hope this helps!
For example (the code is from this page in the Ren'Py documentation):
Code: Select all
$ result = renpy.imagemap("ground.png", "selected.png", [
(100, 100, 300, 400, "eileen"),
(500, 100, 700, 400, "lucy")
])
if result == "eileen":
e "You picked me!"
elif result == "lucy":
e "It looks like you picked Lucy."Code: Select all
if result == "eileen":
e "You picked me!"
jump label1
elif result == "lucy":
e "It looks like you picked Lucy."
jump label2
label1:
# code here
label2:
# more code hereI hope this helps!
Re: Menu options changing or triggering when location is cli
Excellent!
I imagine I could just put a flag into the code after the if statement or the jump in order to add or cull choices from menus based on the state of the flag.
Something like:
My only follow up question is that now that the player has clicked the area of the game, do I just hide the bracelet? I am assuming that I just hide that layer, and make sure the sprite of Eileen in this case has the bracelet on in her default sprite.
I imagine I could just put a flag into the code after the if statement or the jump in order to add or cull choices from menus based on the state of the flag.
Something like:
Code: Select all
if result == "bracelet":
"My eyes flicked to the golden bracelet clasped about her wrist and back to her face."
jump bracelet
label bracelet:
$ bracelet = True
menu:
"Would you care to walk with me?"
e "Of course."
"That bracelet looks familiar." if bracelet = True
e "Do you like it? I was my mother's."
mc "I do like it. My mother had one like it as well."
"You have a boring face and your feet are too large."
e "Is that so? Well, your eyes are too far apart and you smell of rancid meat!
e "Good day!"
- chocoberrie
- Veteran
- Posts: 254
- Joined: Wed Jun 19, 2013 10:34 pm
- Projects: Marshmallow Days
- Contact:
Re: Menu options changing or triggering when location is cli
Hmmm... Yeah! That sounds about right! You can use the hide statement for the image of the bracelet, and then make the next sprite, wearing the bracelet, appear on the screen.antowas wrote:My only follow up question is that now that the player has clicked the area of the game, do I just hide the bracelet? I am assuming that I just hide that layer, and make sure the sprite of Eileen in this case has the bracelet on in her default sprite.
Who is online
Users browsing this forum: _ticlock_