Page 1 of 1

Select Menu

Posted: Tue Aug 06, 2019 6:28 pm
by bokuman
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.

Re: Select Menu

Posted: Tue Aug 06, 2019 7:36 pm
by Amethysts
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).

Re: Select Menu

Posted: Tue Aug 06, 2019 8:00 pm
by Crazy Li
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?

Re: Select Menu

Posted: Tue Aug 06, 2019 8:34 pm
by Imperf3kt
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.

Re: Select Menu

Posted: Tue Aug 06, 2019 8:44 pm
by Crazy Li
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!

Re: Select Menu

Posted: Thu Aug 15, 2019 3:29 pm
by bokuman
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

Re: Select Menu

Posted: Thu Aug 15, 2019 3:55 pm
by Alex
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():

Re: Select Menu

Posted: Mon Aug 19, 2019 8:44 pm
by bokuman
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")]

Re: Select Menu

Posted: Tue Aug 20, 2019 3:11 pm
by Alex
Try it like

Code: Select all

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