Select Menu

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
bokuman
Regular
Posts: 33
Joined: Tue May 23, 2017 1:08 pm
Projects: VN 789
Deviantart: bokuman
Contact:

Select Menu

#1 Post by bokuman » Tue Aug 06, 2019 6:28 pm

Hello,

I'm trying to make a select menu, for each arc story, like a megaman level screen, i need to save some data if you complete each arc to show on select menu(changing the color buton and changing the image tooltip) how i do to save this info? im using imageswap on select menu.

User avatar
Amethysts
Newbie
Posts: 17
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
itch: amethysts
Contact:

Re: Select Menu

#2 Post by Amethysts » Tue Aug 06, 2019 7:36 pm

If you want to save data outside of the game (outside from the "saves" kinda), use this pattern:

Code: Select all

persistent.custom_variable = value
persistent.arc1 = "completed"
persistent.arc1_completed = True
It will be accessible from everywhere, and is equal to None by default (do not abuse of persistent variables).

Crazy Li
Regular
Posts: 112
Joined: Fri Jan 03, 2014 3:35 pm
Contact:

Re: Select Menu

#3 Post by Crazy Li » Tue Aug 06, 2019 8:00 pm

Seeing this answer actually makes me curious... if I have multiple characters in a game and you can choose which character's path to play... this method would then be a valid way to flag whether or not a particular character's path had been completed at the end of the game, right? So then I could check and see if they've finished all characters and show some sorta bonus "true ending" type thingy?

I've kinda been wondering about the best way to store completion data and this sounds like it... though the warning about abusing it does have me a little cautious. How much is too much use of the persistent variables?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 2933
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Select Menu

#4 Post by Imperf3kt » Tue Aug 06, 2019 8:34 pm

Crazy Li wrote:
Tue Aug 06, 2019 8:00 pm
Seeing this answer actually makes me curious... if I have multiple characters in a game and you can choose which character's path to play... this method would then be a valid way to flag whether or not a particular character's path had been completed at the end of the game, right? So then I could check and see if they've finished all characters and show some sorta bonus "true ending" type thingy?
Yes that's easily possible.

A recent thread I commented in has an example of how to use persistent variables for unlocking things at the end of a route and checking if things are unlocked mid-game.
viewtopic.php?f=8&t=56406

It does require you have basic knowledge of screens and conditional statements, so if you aren't sure how to use it, just say and I can alter it to something a bit more beginner friendly.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Free Android GUI - Updated occasionally

Crazy Li
Regular
Posts: 112
Joined: Fri Jan 03, 2014 3:35 pm
Contact:

Re: Select Menu

#5 Post by Crazy Li » Tue Aug 06, 2019 8:44 pm

Imperf3kt wrote:
Tue Aug 06, 2019 8:34 pm
Crazy Li wrote:
Tue Aug 06, 2019 8:00 pm
Seeing this answer actually makes me curious... if I have multiple characters in a game and you can choose which character's path to play... this method would then be a valid way to flag whether or not a particular character's path had been completed at the end of the game, right? So then I could check and see if they've finished all characters and show some sorta bonus "true ending" type thingy?
Yes that's easily possible.

A recent thread I commented in has an example of how to use persistent variables for unlocking things at the end of a route and checking if things are unlocked mid-game.
viewtopic.php?f=8&t=56406

It does require you have basic knowledge of screens and conditional statements, so if you aren't sure how to use it, just say and I can alter it to something a bit more beginner friendly.
Oh no, I've made my own screens tons of times. Really, just the small example in this thread on how to set persistent variables is kinda enough for me to figure out how to approach it for my own game with regards to tracking completed paths. Your example helps provide more context though, so thanks for that!

bokuman
Regular
Posts: 33
Joined: Tue May 23, 2017 1:08 pm
Projects: VN 789
Deviantart: bokuman
Contact:

Re: Select Menu

#6 Post by bokuman » Thu Aug 15, 2019 3:29 pm

Not sure if is the thing that im searching... xD

im using this on my Select Charcter screen

Code: Select all

    
    
screen select:
    tag menu

    imagemap:
        ground 'gui/imagemap_select_idle.jpg'
        hover 'gui/imagemap_select_hover.jpg'

        if $ cheelai_points >= 4:
        hotspot (430, 33, 238, 213) action [Hide("image_float"), Jump('cheelai_chapter')] hovered [ Play ("test_one", "sfx/click.wav"), Show("image_float", my_picture="gui/cs_cheelai_clothes_A.png", my_tt_xpos=0, my_tt_ypos=0) ] unhovered [Hide("image_float")]
        if $ cheelai_points <= 1:
        hotspot (430, 33, 238, 213) action [Hide("image_float"), Jump('cheelai_chapter')] hovered [ Play ("test_one", "sfx/click.wav"), Show("image_float", my_picture="gui/cs_cheelai_B.png", my_tt_xpos=0, my_tt_ypos=0) ] unhovered [Hide("image_float")]
and on my character script im using this on start.

Code: Select all

label cheelai_chapter:

init:
    $ cheelai_points = 0


menu:
    "Haha, good joke.":
        jump cheelaijokes
    "I see...":
        $ cheelai_points += 1
        jump iseecheelaiisee


this thing works? or i need other method? actually doesnt works...lol

User avatar
Alex
Lemma-Class Veteran
Posts: 2472
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Select Menu

#7 Post by Alex » Thu Aug 15, 2019 3:55 pm

Some tips:
- $-sign is used only at the very beginning of code line to show that it's a single line of python code.

Code: Select all

if cheelai_points >= 4:
- indentation do matters. The first line of code block ends with colon, and other lines of that block have an extra indentation (otherwise you'll get an error).

Code: Select all

label cheelai_chapter:
    menu:
        "Haha, good joke.":
            jump cheelaijokes
        "I see...":
            $ cheelai_points += 1
            jump iseecheelaiisee
- code is run line by line in order it's writen (with exceptions) - viewtopic.php?f=51&t=39572#p422964
The 'init' block will be executed at init phase of game and not when player has reached the 'cheelai_chapter'.

Code: Select all

label cheelai_chapter:
    "blah-blah"

init:
    $ cheelai_points = 0
- if you need to change the variable mid-game and properly store it, then use 'dafault' statement, 'cause everytime you run your game, variables in an init block are reset to their initial values.

Code: Select all

default cheelai_points = 0
instead of

Code: Select all

init:
    $ cheelai_points = 0
https://www.renpy.org/doc/html/python.h ... -statement
https://www.renpy.org/doc/html/save_load_rollback.html


- append brackets after screen name when you create it - it's neccessary for best performance - https://www.renpy.org/doc/html/screen_optimization.html

Code: Select all

screen select():

bokuman
Regular
Posts: 33
Joined: Tue May 23, 2017 1:08 pm
Projects: VN 789
Deviantart: bokuman
Contact:

Re: Select Menu

#8 Post by bokuman » Mon Aug 19, 2019 8:44 pm

oh! thanks! i did all changes and is working, but i noted that when i back to select screen, the button is blocked, or doesnt works now, cheelai_points = 0 on this point, but when is 30 the image shows correctly.

im using this code.

Code: Select all


screen select():
    tag menu

    imagemap:
        ground 'gui/imagemap_select_idle.jpg'
        hover 'gui/imagemap_select_hover.jpg'

        if cheelai_points <= 0:
            hotspot (430, 33, 238, 213) action [Hide("image_float"), Jump('cheelai_chapter')] hovered [ Play ("test_one", "sfx/click.wav"), Show("image_float", my_picture="gui/cs_cheelai_clothes.png", my_tt_xpos=0, my_tt_ypos=0) ] unhovered [Hide("image_float")]
        if cheelai_points >= 30:
            hotspot (430, 33, 238, 213) action [Hide("image_float"), Jump('cheelai_chapter')] hovered [ Play ("test_one", "sfx/click.wav"), Show("image_float", my_picture="gui/cs_cheelai_clothes_b.png", my_tt_xpos=0, my_tt_ypos=0) ] unhovered [Hide("image_float")]

User avatar
Alex
Lemma-Class Veteran
Posts: 2472
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Select Menu

#9 Post by Alex » Tue Aug 20, 2019 3:11 pm

Try it like

Code: Select all

if cheelai_points < 1:
    ...
elif cheelai_points >= 30:
    ....
else:
    hotspot (430, 33, 238, 213) action NullAction()

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]