[Solved] Continue game from last save

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
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

[Solved] Continue game from last save

#1 Post by kostek00 »

I wanted to make "Continue" button to load last saved game. After checking forum I found this and used it in my game which works as intendet. The problem is that button "Continue" is always in selected state and hovering on it doesn't change it's state nor it goes to idle state. Any solution for that?

Here is whole code:

Code: Select all

screen main_menu:
    tag menu
    add "images/gui/gui_ground.png"
    add "images/gui/title.png" anchor(1.0, 0.0) pos(787,18)

    imagemap:
        ground Null()
        idle "images/gui/main_menu_idle.png"
        hover "images/gui/main_menu_hover.png"
        selected_idle "images/gui/main_menu_selected.png"
        selected_hover "images/gui/main_menu_selected.png"

        alpha False

        $ lastsave=renpy.newest_slot(r"\d+")
        if lastsave is not None:
            $ name, page = lastsave.split("-")
            hotspot(622,275,150,45) action FileLoad(name, page)
        hotspot(622,325,150,45) action Start()
        hotspot(622,375,150,45) action ShowMenu("load")
        hotspot(622,425,150,45) action ShowMenu("extra")
        hotspot(622,475,150,45) action ShowMenu("options")
        hotspot(622,525,150,45) action Quit(confirm=True)

    key "K_ESCAPE" action Quit(confirm=True)
Last edited by kostek00 on Fri Sep 28, 2018 11:40 am, edited 3 times in total.

User avatar
Qlara
Regular
Posts: 80
Joined: Fri Nov 28, 2014 10:22 am
Completed: Carmilla
Skype: kantonija
itch: visualgothic
Location: Berlin
Contact:

Re: Continue game from last save with imagemap

#2 Post by Qlara »

Do you perhaps have a screenshot?
Do the other buttons work as they should?
Is it okay to have just one hover image? I always have one for each button.

User avatar
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Re: Continue game from last save with imagemap

#3 Post by kostek00 »

Qlara wrote: Fri Sep 14, 2018 6:07 pm Do you perhaps have a screenshot?
It's nsfw, I can't put it here.
Qlara wrote: Fri Sep 14, 2018 6:07 pm Do the other buttons work as they should?
Yes.
Qlara wrote: Fri Sep 14, 2018 6:07 pm Is it okay to have just one hover image? I always have one for each button.
Yes, I did that.


So yesteryday at night I tried some other thing and now I understand what happens but I don't know why. It appears as this code always prefers "selected" state. So I moved them to imagebutton and used only idle and hover states and that worked.

Code: Select all

screen main_menu:
    tag menu
    add "images/gui/gui_ground.png"
    add "images/gui/title.png" anchor(1.0, 0.0) pos(787,18)

    $ lastsave=renpy.newest_slot(r"\d+")
    if lastsave is not None:
        $ name, page = lastsave.split("-")
        imagebutton:
            idle im.Crop("images/gui/main_menu_idle.png", (622,275,150,45))
            hover im.Crop("images/gui/main_menu_hover.png", (622,275,150,45))
            action FileLoad(name, page)
            pos(622,275)
            focus_mask None

    imagemap:
        ground Null()
        idle "images/gui/main_menu_idle.png"
        hover "images/gui/main_menu_hover.png"
        selected_idle "images/gui/main_menu_selected.png"
        selected_hover "images/gui/main_menu_selected.png"

        alpha False


        hotspot(622,325,150,45) action Start()
        hotspot(622,375,150,45) action ShowMenu("load")
        hotspot(622,425,150,45) action ShowMenu("extra")
        hotspot(622,475,150,45) action ShowMenu("options")
        hotspot(622,525,150,45) action Quit(confirm=True)

    key "K_ESCAPE" action Quit(confirm=True)
Now I see different bug with this code. It looks like it's only loading normal saves and ignores quick saves.


User avatar
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Re: Continue game from last save with imagemap

#5 Post by kostek00 »

You know there is always that time when you search extensively for something but don't find too much about it. Then you ask somewhere for help and he/she links you to answer like it's nothing. Thanks :D

Zetsubou's code fixes all issues I had with continue button.

Post Reply

Who is online

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