Ren'Py Learning Renpy. Need some help!

Higurashika

Well-Known Member
Nov 15, 2018
1,400
2,000
Hello! While i'm doing my game, I meet a lot of things i'm not familiar with. So this is my thread where I would seek some help.

Because I have a lot of character's parameters I have to have a lot of saves with different routes. So I need to know, how could I change name of save file, when saving the game?

I saw this thread
but understood nothing.
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
Edit your "screens.rpy"...

Search "screen file_slots(title):"

And change this part:
Python:
screen file_slots(title):

    default page_name_value = FilePageNameInputValue(pattern=_("Página {}"), auto=_("Grabación automática"), quick=_("Grabación rápida"))

    use game_menu(title):

        fixed:

            ## This ensures the input will get the enter event before any of the
            ## buttons do.
            order_reverse True

            ## El nombre de la pagina, se puede editar haciendo clic en el
            ## botón.
            button:
                style "page_label"

                key_events True
                xalign 0.5
                action page_name_value.Toggle()

                input:
                    style "page_label_text"
                    value page_name_value
For this:
Python:
screen file_slots(title):

    default page_name_value = FilePageNameInputValue(pattern=_("Página {}"), auto=_("Grabación automática"), quick=_("Grabación rápida"))

    use game_menu(title):

        fixed:

            ## This ensures the input will get the enter event before any of the
            ## buttons do.
            order_reverse True

            ## El nombre de la pagina, se puede editar haciendo clic en el
            ## botón.
            text "{size=24}Add a name to your save file here (optional):{/size}" xalign 0.5
            button:
                style "page_label"

                key_events True
                xalign 0.5
                yalign 0.04

                input:
                    value VariableInputValue('save_name')
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
NOTE: Keep in mind that I have renpy configured in Spanish, so don't do a copy/paste; check and apply only the changes you see between the two scripts.

The important part is this:
Python:
            text "{size=24}Add a name to your save file here (optional):{/size}" xalign 0.5
            button:
                style "page_label"

                key_events True
                xalign 0.5
                yalign 0.04

                input:
                    value VariableInputValue('save_name')
 
  • Like
Reactions: t727

Higurashika

Well-Known Member
Nov 15, 2018
1,400
2,000
Thank you! It's an interesting way to name your saves. But now I can't delete saves. Is there any way to fix this?
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
Although this code allows you to do what you wanted to do, optionally write a name in the save file, it presents two problems:
- The name given to the save file remains the next time you want to save (unless you restart the game).
- The option to enter text is displayed even if you are in the Load screen (it should not be visible there)

I hope someone with more experience can help solve these two problems :p

To delete the save files you can do it by deleting the files inside the "saves" folder of the game.
You used to do it directly from the menu? How? And now you can't? (Sorry, but I've always deleted the files in the folder, lol)
 
  • Like
Reactions: t727

Higurashika

Well-Known Member
Nov 15, 2018
1,400
2,000
And I have another question:

Can I do nvl monologue, if my game runs not in nvl mode?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,976
16,232
- The name given to the save file remains the next time you want to save (unless you restart the game).
- The option to enter text is displayed even if you are in the Load screen (it should not be visible there)
Since you tweak the "file_slots" screen for this, there's a solution for the second problem, the parameter. As long as it's not translated, it will works like this. If the game is translated, you'll have to also test the possible translations.

Python:
screen file_slots(title):
[...]
                # Not translated game
                if title == "Save":
                # translated game
                #if title in [ "Save", "translation1", "translation2" ]:
                    input:
                        value VariableInputValue('save_name')

As for the first problem, it come from the fact that you changed the behavior of an existing button, instead of adding your own one :
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
            # end of the original button >>>

            # The new button for the name.
            if title == "Save":
                hbox:
                    text "Name : "

                    button:
                        style "page_label"

                        key_events True
                        xalign 0.5
                        action NullAction()

                        input:
                            value VariableInputValue('save_name')
[...]

I hope someone with more experience can help solve these two problems :p
Done.
 
  • Like
Reactions: t727 and mickydoo

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,976
16,232
anne O'nymous hmmm your code doesn't work - I can't save, I can't chage save pages, can't choose save slot...
Hm... I tested it before giving it, so you should have made an error somewhere. Yet to discover where.

You understood that it's just the "part to change", right ? You should look at the "file_slot" screen, search the part that is like the original button (which is here as reference), then insert the "new button" right after it, while keeping the rest of the screen.
 

Higurashika

Well-Known Member
Nov 15, 2018
1,400
2,000
You understood that it's just the "part to change", right ? You should look at the "file_slot" screen, search the part that is like the original button (which is here as reference), then insert the "new button" right after it, while keeping the rest of the screen.
Well... somehow I've managed this. Thank you! But what about deleting saves with DEL? Still doesn't work. Or it's not possible if you can name saves?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,976
16,232
But what about deleting saves with DEL? Still doesn't work. Or it's not possible if you can name saves?
This should be available by default :/

In the "file_slots" screen you should already have something like this :
Code:
            grid gui.file_slot_cols gui.file_slot_rows:
                style_prefix "slot"

                xalign 0.5
                yalign 0.5

                spacing gui.slot_spacing

                for i in range(gui.file_slot_cols * gui.file_slot_rows):

                    $ slot = i + 1

                    button:
                        action FileAction(slot)

                        has vbox

                        add FileScreenshot(slot) xalign 0.5

                        text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")):
                            style "slot_time_text"

                        text FileSaveName(slot):
                            style "slot_name_text"

                        key "save_delete" action FileDelete(slot)
The last one being the one that let you delete a save file.
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
Well... somehow I've managed this. Thank you! But what about deleting saves with DEL? Still doesn't work. Or it's not possible if you can name saves?
Doesn't work for me too, BUT... I changed "order_reverse" from True to False and then it works :)

With the new code, the problem of appearing on the save and load screen has also been solved; now it only appears on the save screen.

The only problem I still have is that when I leave the save screen and come back in, it keeps the same name I gave to the last save... Is there any way to "reset" it?

Here's my code:
Python:
screen file_slots(title):

    default page_name_value = FilePageNameInputValue(pattern=_("Página {}"), auto=_("Grabación automática"), quick=_("Grabación rápida"))

    use game_menu(title):

        fixed:

            ## This ensures the input will get the enter event before any of the
            ## buttons do.
            order_reverse False
            
            ## El nombre de la pagina, se puede editar haciendo clic en el
            ## botón.
            #text "{size=24}Add a name to your save file here (optional):{/size}" xalign 0.5

            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 in [ "Save", "Guardar", "Guardado" ]:
                hbox:
                    text "Name : "

                    button:
                        style "page_label"

                        key_events True
                        xalign 0.5
                        action NullAction()

                        input:
                            value VariableInputValue('save_name')
                

            ## The grid of file slots.
            grid gui.file_slot_cols gui.file_slot_rows:
                style_prefix "slot"

                xalign 0.5
                yalign 0.5

                spacing gui.slot_spacing

                for i in range(gui.file_slot_cols * gui.file_slot_rows):

                    $ slot = i + 1

                    button:
                        action FileAction(slot)

                        has vbox

                        add FileScreenshot(slot) xalign 0.5

                        text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("vacío")):
                            style "slot_time_text"

                        text FileSaveName(slot):
                            style "slot_name_text"

                        key "save_delete" action FileDelete(slot)

            ## Buttons to access other pages.
            hbox:
                style_prefix "page"

                xalign 0.5
                yalign 1.0

                spacing gui.page_spacing

                textbutton _("<") action FilePagePrevious()

                if config.has_autosave:
                    textbutton _("{#auto_page}A") action FilePage("auto")

                if config.has_quicksave:
                    textbutton _("{#quick_page}R") action FilePage("quick")

                ## range(1, 10) da los numeros del 1 al 9.
                for page in range(1, 10):
                    textbutton "[page]" action FilePage(page)

                textbutton _(">") action FilePageNext()
Thanks! :giggle:
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
Ok, I found the solution :D

To clear the last "save_name" used, just add this:
Python:
on "show" action SetVariable("save_name", "")
So, this is my final code:
Python:
screen file_slots(title):

    default page_name_value = FilePageNameInputValue(pattern=_("Página {}"), auto=_("Grabación automática"), quick=_("Grabación rápida"))
    on "show" action SetVariable("save_name", "")
    use game_menu(title):

        fixed:

            order_reverse False

            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 in [ "Save", "Guardar", "Guardado" ]:
                hbox:
                    text "Name : "

                    button:
                        style "page_label"

                        key_events True
                        xalign 0.5
                        action NullAction()

                        input:
                            value VariableInputValue('save_name')
               

            ## The grid of file slots.
            grid gui.file_slot_cols gui.file_slot_rows:
                style_prefix "slot"

                xalign 0.5
                yalign 0.5

                spacing gui.slot_spacing

                for i in range(gui.file_slot_cols * gui.file_slot_rows):

                    $ slot = i + 1

                    button:
                        action FileAction(slot)

                        has vbox

                        add FileScreenshot(slot) xalign 0.5

                        text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("vacío")):
                            style "slot_time_text"

                        text FileSaveName(slot):
                            style "slot_name_text"

                        key "save_delete" action FileDelete(slot)

            ## Buttons to access other pages.
            hbox:
                style_prefix "page"

                xalign 0.5
                yalign 1.0

                spacing gui.page_spacing

                textbutton _("<") action FilePagePrevious()

                if config.has_autosave:
                    textbutton _("{#auto_page}A") action FilePage("auto")

                if config.has_quicksave:
                    textbutton _("{#quick_page}R") action FilePage("quick")

                ## range(1, 10) da los numeros del 1 al 9.
                for page in range(1, 10):
                    textbutton "[page]" action FilePage(page)

                textbutton _(">") action FilePageNext()
 
  • Like
Reactions: Higurashika

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,976
16,232
Doesn't work for me too, BUT... I changed "order_reverse" from True to False and then it works :)
What version of Ren'py do you use ?

I'm almost sure that I haven't changed the content of screen.rpy in the project I use for code validation, so why is this working for me and not for others ? :/
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
What version of Ren'py do you use ?

I'm almost sure that I haven't changed the content of screen.rpy in the project I use for code validation, so why is this working for me and not for others ? :/
I'm using v6.99.14.1... I know, this version is getting old, lol... I plan to jump to the last one (v7.3 I think) with the v3.0 release of my game :p
 

Higurashika

Well-Known Member
Nov 15, 2018
1,400
2,000
I wonder if I could use nvl mode with not nvl character. Is any way to say something in nvl mode just once?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,976
16,232
I wonder if I could use nvl mode with not nvl character. Is any way to say something in nvl mode just once?
Technically it's not totally impossible, but it's also not recommended. This said, if it's just for the narration, you have the narrator character that exist for the adventure mode, and the nvl_narrator for the nvl mode.
Therefore :
Code:
label whatever:
    nvl_narrator "This is a narration line."
    nvl_narrator "And here come another one."
will turn the narration into NVL mode, then return in adventure mode once a character will talk.
 
  • Like
Reactions: Higurashika

Higurashika

Well-Known Member
Nov 15, 2018
1,400
2,000
Need help again. I know how to do what I want, but I wonder if there is simpler solution.

I got vbox with lines:

text "blablabla"
text "blablabla"

et cetera. There are a lot of lines with a lot of text effects. So, I need to apply {b}{/b} to all lines.
I thought about creating a style with bold properties, but I don't get how to do it :(


Ok, i've found solution using this

Named styles exists as fields on the global style object. To create a new style, create an instance of the Style class, and assign it to a field on the style object.


init python:
style.big_text = Style(style.default)
style.big_text.size = 42


Once created, a named style can be applied to displayables by supplying it's name, or the style object.


screen two_big_lines:
vbox:
text "This is Big Text!" style "big_text"
text "So is this." style style.big_text
Any easier options?
 
Last edited:

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
Maybe like this:
Python:
style mybigtext:
    size 42
    bold True

screen two_big_lines:
    vbox:
        style "mybigtext"

        text "......"
        text "......"
        text "......"
        text "......"
        text "......"
Now I'm not sure if the style should be applied inside or outside the vbox :p