CREATE YOUR AI CUM SLUT ON CANDY.AI TRY FOR FREE
x

Custom Save Names in Renpy

InfamousGuy

Member
Apr 4, 2019
226
835
Hello all,

I've been unable to figure out how to make it to where whenever the players choose to save their game, have a text box show up, ask the user "What would you like to name this save?", And then save it while displaying the save name. I've been racking my brain for about 2 days with this so I'd really appreciate any help!
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,260
You need only update the save_name variable. Whatever the value of that variable is at the moment of the save will be stored and shown on the "normal" save/load screens (assuming you haven't customized them too much).

If you want a button that you click to open a dialogue box where you type the value in. Sure.
If you just want a text field on the save screen that updates the value. Sure.

Basically, anyway you can think to update a string variable... will work here. Even hardcoding values at the being of each release/chapter/season.

Edit: As for to actually implement the code to do a "text box". Just find any game that already does it and steal borrow their code. You can unpack almost any game using Unren 0.9 (dev).
 

InfamousGuy

Member
Apr 4, 2019
226
835
You need only update the save_name variable. Whatever the value of that variable is at the moment of the save will be stored and shown on the "normal" save/load screens (assuming you haven't customized them too much).

If you want a button that you click to open a dialogue box where you type the value in. Sure.
If you just want a text field on the save screen that updates the value. Sure.

Basically, anyway you can think to update a string variable... will work here. Even hardcoding values at the being of each release/chapter/season.
How exactly would I go about that? I can understand keeping save_name updated for each save, but how exactly would that look like?

I have it like this right now:

screen file_slots(title):

default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves"))

use game_menu(title):

fixed:
input:
value VariableInputValue('save_name')

it is very bare bones. So how exactly would I be able to make it to where I get a text box to appear and directly ask them (the player) the name of the current save?

Apologies in advance if I'm not understanding something.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,260
How exactly would I go about that?

Taking Pale Carnations as an example.

They have a custom "popup" screen they call screen give_save_name.
They've tied it into the standard load/save screen like this:

Python:
screen file_slots(title):

    default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves"))

    use game_menu(title):

        ## The grid of file slots.
        grid 3 2:
            xpos -100
            ypos -20

            spacing 90#gui.slot_spacing

            for i in range(6):

                $ slot = i + 1
                $ _name = FileSaveName(slot)

                button:
                    xysize (406, 248)
                    background "gui/button/panel.png"
                    insensitive_background "gui/button/panel.png"


                    add FileScreenshot(slot) xpos 35 ypos 26
                    if _name:
                        add Solid("#000000", xysize=(370, 35)) alpha 0.8 xpos 45 ypos 208
                        text _name size 28 xalign 0.5 ypos 208

                    # *** THIS IS THE LINE YOU CARE ABOUT ***
                    action If(title.lower() == "save", true=Show("give_save_name", slotIndex = slot), false=FileLoad(slot))
                    key "save_delete" action FileDelete(slot)

Then there's the custom screen itself...

Python:
### SAVE FILE NAME INPUT

style SaveInputButton:
    color "#ffffff"

style SaveInputButton_text:
    color "#FF8C00"
    selected_color "#FFA500"
    hover_color "#FFA500"

screen give_save_name(slotIndex):
    modal True

    frame:
        xalign .5
        yalign .5
        vbox:
            xalign 0.5
            xsize 450
            ysize 120
            spacing 40
            first_spacing 10

            hbox:
                text "ENTER SAVE NAME"
                yalign 0.5
                xalign 0.5
            hbox:
                input value VariableInputValue("save_name") length 12
                xalign 0.5
                yalign 0.5

            hbox:
                spacing 30
                xalign 0.5

                textbutton "Done":
                    xalign 0.2
                    action [Hide("give_save_name"), FileSave(slotIndex, confirm=False), ShowMenu('save')]

                textbutton "Return":
                    xalign 0.2
                    action [Hide("give_save_name"), ShowMenu('save')]


    key  'K_RETURN' action [Hide("give_save_name"), FileAction(slotIndex, confirm=False), Show("file_slots", title = "Save")]

Whether that works when added to just any game is anyone's guess... But this is how they implemented it.
If it needs tweaking, it won't be too much extra work.
 

InfamousGuy

Member
Apr 4, 2019
226
835
Taking Pale Carnations as an example.

They have a custom "popup" screen they call screen give_save_name.
They've tied it into the standard load/save screen like this:

Python:
screen file_slots(title):

    default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves"))

    use game_menu(title):

        ## The grid of file slots.
        grid 3 2:
            xpos -100
            ypos -20

            spacing 90#gui.slot_spacing

            for i in range(6):

                $ slot = i + 1
                $ _name = FileSaveName(slot)

                button:
                    xysize (406, 248)
                    background "gui/button/panel.png"
                    insensitive_background "gui/button/panel.png"


                    add FileScreenshot(slot) xpos 35 ypos 26
                    if _name:
                        add Solid("#000000", xysize=(370, 35)) alpha 0.8 xpos 45 ypos 208
                        text _name size 28 xalign 0.5 ypos 208

                    # *** THIS IS THE LINE YOU CARE ABOUT ***
                    action If(title.lower() == "save", true=Show("give_save_name", slotIndex = slot), false=FileLoad(slot))
                    key "save_delete" action FileDelete(slot)

Then there's the custom screen itself...

Python:
### SAVE FILE NAME INPUT

style SaveInputButton:
    color "#ffffff"

style SaveInputButton_text:
    color "#FF8C00"
    selected_color "#FFA500"
    hover_color "#FFA500"

screen give_save_name(slotIndex):
    modal True

    frame:
        xalign .5
        yalign .5
        vbox:
            xalign 0.5
            xsize 450
            ysize 120
            spacing 40
            first_spacing 10

            hbox:
                text "ENTER SAVE NAME"
                yalign 0.5
                xalign 0.5
            hbox:
                input value VariableInputValue("save_name") length 12
                xalign 0.5
                yalign 0.5

            hbox:
                spacing 30
                xalign 0.5

                textbutton "Done":
                    xalign 0.2
                    action [Hide("give_save_name"), FileSave(slotIndex, confirm=False), ShowMenu('save')]

                textbutton "Return":
                    xalign 0.2
                    action [Hide("give_save_name"), ShowMenu('save')]


    key  'K_RETURN' action [Hide("give_save_name"), FileAction(slotIndex, confirm=False), Show("file_slots", title = "Save")]

Whether that works when added to just any game is anyone's guess... But this is how they implemented it.
If it needs tweaking, it won't be too much extra work.
Thank you so much! I really do appreciate! This has been giving me a headache for more than a day now, but hopefully I can put it to rest, once again I really do appreciate it.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
11,024
16,327
Python:
                    # *** THIS IS THE LINE YOU CARE ABOUT ***
                    action If(title.lower() == "save", true=Show("give_save_name", slotIndex = slot), false=FileLoad(slot))
                    key "save_delete" action FileDelete(slot)
The problem with this method is that it's an invasive one. Whatever if the player want to give a name to the save file or not, he'll have the pop-up screen asking for a name.
It's not a breaking issue, but it also mess with Ren'py flow. You can see it by saving twice in a row, the second save slot screenshot will picture the name input screen in place of the game itself.

Therefore, since you're already relying on the screen title, there's a better approach :

Python:
screen file_slots(title):
[...]
# --- The original button
            button:
                style "page_label"

                key_events True
                xalign 0.5
                action page_name_value.Toggle()

                input:
                    style "page_label_text"
                    value page_name_value


            if title == "Save":
                hbox:
                    text "Name : "
                    input:
                        value VariableInputValue('save_name')
The input box will be at the left of the line where the name page is located.

There many advantage, for only one small inconvenient :

First and before all, if the player don't want to give a name to the save, it will be totally transparent for him. No pop-up, and therefore no need to click on a button every time he save the game
Secondly, the value is to enter only once. Generally you name your save file accordingly to the path you follow, and not accordingly to the moment you save ; Ren'py presenting a screenshot and the date and hour when the save have been made helping for that. Therefore your "girlname only - romantic" name will be used a lot of time consecutively. Contrarily to what happen with the pop-up approach, you'll not have to provide the save name every time you save, but just when the name change.
Thirdly, it don't mess with Ren'py flow.


As for the inconvenient, contrarily to what happen with the pop-up approach, the player have to remember that he have to change the name of the save file. But it's just half a problem. If you use a style that make the name itself clearly stand out of the screen, it will act as a reminder :
savename.jpg
 
Nov 21, 2018
30
71
The problem with this method is that it's an invasive one. Whatever if the player want to give a name to the save file or not, he'll have the pop-up screen asking for a name.
It's not a breaking issue, but it also mess with Ren'py flow. You can see it by saving twice in a row, the second save slot screenshot will picture the name input screen in place of the game itself.

Therefore, since you're already relying on the screen title, there's a better approach :

Python:
screen file_slots(title):
[...]
# --- The original button
            button:
                style "page_label"

                key_events True
                xalign 0.5
                action page_name_value.Toggle()

                input:
                    style "page_label_text"
                    value page_name_value


            if title == "Save":
                hbox:
                    text "Name : "
                    input:
                        value VariableInputValue('save_name')
The input box will be at the left of the line where the name page is located.

There many advantage, for only one small inconvenient :

First and before all, if the player don't want to give a name to the save, it will be totally transparent for him. No pop-up, and therefore no need to click on a button every time he save the game
Secondly, the value is to enter only once. Generally you name your save file accordingly to the path you follow, and not accordingly to the moment you save ; Ren'py presenting a screenshot and the date and hour when the save have been made helping for that. Therefore your "girlname only - romantic" name will be used a lot of time consecutively. Contrarily to what happen with the pop-up approach, you'll not have to provide the save name every time you save, but just when the name change.
Thirdly, it don't mess with Ren'py flow.


As for the inconvenient, contrarily to what happen with the pop-up approach, the player have to remember that he have to change the name of the save file. But it's just half a problem. If you use a style that make the name itself clearly stand out of the screen, it will act as a reminder :
View attachment 1104078
You're a genius! Thanks