Ren'Py Learning Renpy. Need some help!

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,318
15,208
Maybe like this:
Python:
style mybigtext:
    size 42
    bold True
This is better for the style creation, but :

Now I'm not sure if the style should be applied inside or outside the vbox :p
Ren'py do not make its style propagate, so it have to be applied directly to the text.

But there's a way to still simplify this, the screen property. It works by defining the prefix that will be used to build the name of the style to apply to each screen statements inside the actual block ; the said name being prefix_statement. Therefore, to apply the same style to all the text screen statements inside a vbox :
Python:
# The style need to apply to /text/.
style mybig_text:
    size 42
    bold True

screen two_big_lines:
    vbox:
        # Tell to Ren'py which prefix to use.
        style_prefix "mybig"

        text "line 1"
        text "line 2"
Note that some screen statements, like by example textbutton, are particular because they have more than a single part. Like implied by its name, a textbutton is a combination between the button and the text screen statements. For them, the name of the style is a little more complex :
prefix_outer statement_inner statement

So, for a textbutton you need :
Python:
# Style for the /button/ part.
style myStyle_button:
   background "#0F0"
# Style for the /text/ part.
style myStyle_button_text:
   color "#F00"

screen whatever():
    vbox:
        style_prefix "myStyle"

        textbutton "Click me to quit" action Return()


label start:
    call screen whatever
    "End."
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,692
This is better for the style creation, but :



Ren'py do not make its style propagate, so it have to be applied directly to the text.

But there's a way to still simplify this, the screen property. It works by defining the prefix that will be used to build the name of the style to apply to each screen statements inside the actual block ; the said name being prefix_statement. Therefore, to apply the same style to all the text screen statements inside a vbox :
Python:
# The style need to apply to /text/.
style mybig_text:
    size 42
    bold True

screen two_big_lines:
    vbox:
        # Tell to Ren'py which prefix to use.
        style_prefix "mybig"

        text "line 1"
        text "line 2"
Note that some screen statements, like by example textbutton, are particular because they have more than a single part. Like implied by its name, a textbutton is a combination between the button and the text screen statements. For them, the name of the style is a little more complex :
prefix_outer statement_inner statement

So, for a textbutton you need :
Python:
# Style for the /button/ part.
style myStyle_button:
   background "#0F0"
# Style for the /text/ part.
style myStyle_button_text:
   color "#F00"

screen whatever():
    vbox:
        style_prefix "myStyle"

        textbutton "Click me to quit" action Return()


label start:
    call screen whatever
    "End."
Ups, I forgot the "prefix" :p
 
  • Haha
Reactions: anne O'nymous

Higurashika

Well-Known Member
Nov 15, 2018
1,378
1,979
Hi again!

I got this simple code for a small notification.

But I've got an error when I use quick save button. It's like notice_text has no value. How to fix it?

You don't have permission to view the spoiler content. Log in or register now.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,269
22,391
Hi again!

I got this simple code for a small notification.

But I've got an error when I use quick save button. It's like notice_text has no value. How to fix it?

You don't have permission to view the spoiler content. Log in or register now.
Just asking, did you delete/overwrite the original notify screen?
 

Higurashika

Well-Known Member
Nov 15, 2018
1,378
1,979
did you delete/overwrite the original notify screen?
No.. but what do you mean by "original notify screen"? I just want to make pop-up notification, not to replace vanilla.

p.s. now I see where is the problem. Now I need to figure out how to fix this.
 
Last edited:

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,269
22,391
No.. but what do you mean by "original notify screen"? I just want to make pop-up notification, not to replace vanilla.
in screens.rpy there is a screen notify(message):
That's the usual notification message you get when saving, you're basically overwriting it. I guess this might cause your problem.
 

Higurashika

Well-Known Member
Nov 15, 2018
1,378
1,979
That's the usual notification message you get when saving, you're basically overwriting it. I guess this might cause your problem.
Yeah this is a problem.. for now I decided to use simple renpy.notify(message) function. It seems pop-up notification is too complicated for me.
 
  • Like
Reactions: recreation

Higurashika

Well-Known Member
Nov 15, 2018
1,378
1,979
Guys, I need a help. I got a screen with player's info. But I want to add information there later, after some playing time. How I can do this?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,318
15,208
Guys, I need a help. I got a screen with player's info. But I want to add information there later, after some playing time. How I can do this?
Well, you just need to condition the display of the information, by using the screen statement.


Python:
screen myScreen():

    vbox:
        text "Some information [myVar]"
        text "Other information [otherVar]"
        text "Oh, look, information [aVar]"
        # Here come the delayed information.
        # Will be shown only if /aFlag/ is /true/.
        showif aFlag == true:
            text "And this information come later [delayedVar]"

# By default, do NOT show the delayed information
default aFlag = false

label whatever:
    [...]
    # It's time to show the delayed information
    $ aFlag = true
Alternatively, if the said information have to be in the middle of others and you want to keep a clean and constant presentation, something like :
  • Some information
  • Other information
  • Oh, look, information
  • Yet another information
You can combine and the screen statement.

Code:
screen myScreen():

    vbox:
        [...]
        text "Oh, look, information [aVar]"
        if aFlag == true:
            text "And this information come later [delayedVar]" 
        else:
            null height 20
        text "Yet another information [aNewVar]"
Just adjust the value of null to match the number of vertical pixels normally used to display the line of text.
 

Higurashika

Well-Known Member
Nov 15, 2018
1,378
1,979
Unusual problem. I removed aFlag from code , but the game still sees this var and shows showif statements.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,269
22,391
What is autoreload? Nope, restart didn't work. Maybe I should use something to reload my custom screen?
If you're in the game, press ctrl + R. The game will automatically releoad when you make (and save) changes to your script files, that's autoreload.
 
  • Like
Reactions: Higurashika

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,318
15,208
Unusual problem. I removed aFlag from code , but the game still sees this var and shows showif statements.
If the variable wasn't here, Ren'py would have thrown an error screen. Therefore, it's because the variable is still seen as existing.

It happen when you load a saved game. Ren'py check nothing. It just see that the save say "hey, there's a variable named [whatever], with a value of [something]", and create it. So a variable you thought you removed will still be seen in any game after a load. And reloading the script make Ren'py perform an invisible save/load, which lead to the same problem.


On a side note regarding variable persistence, sometimes it's not the variable but its value that stay. Depending of how you created it, when you restart the game without quitting it, some variables will keep the value they had, and not be reset to their starting value. It's especially true for variable created in an init block.
 

Higurashika

Well-Known Member
Nov 15, 2018
1,378
1,979
It happen when you load a saved game. Ren'py check nothing. It just see that the save say "hey, there's a variable named [whatever], with a value of [something]", and create it. So a variable you thought you removed will still be seen in any game after a load. And reloading the script make Ren'py perform an invisible save/load, which lead to the same problem.
I always quit and restart, when I do changes in code. So this seems a true reason. I use the prev save, thank you!
 

Higurashika

Well-Known Member
Nov 15, 2018
1,378
1,979
I'm here again :)

Let's say I have a lot of vars.

Code:
a = false
b = false
c = false
d = false
...
n = false
Through dialog I may change them or may not. I have a route where they weren't changed, so how could I code the condition like

Code:
if a == false and b == false and c == false .... :
jump
I know I can't use so many "ands".