How many definitions can you have before you start to run into problems

ChaosOpen

Well-Known Member
Game Developer
Sep 26, 2019
1,014
2,142
I've built up a few during the process of writing my novel and I fear there might be some upper limit where the game can no longer keep up.

Untitled.png
 

GNVE

Active Member
Jul 20, 2018
724
1,185
Eh don't worry too much about it. You are a long long way out. I don't think Ren'Py has a hard limit. Just a soft limit in the pc resources available. (you are a far way out).
Though if you really are afraid of at one point hitting that limit you could look into optimizing your code. (But I'm far from a programmer so can't really help you there. I think things like dictionaries and classes are better memory wise but don't quote me on that...)
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
No limit you're ever likely to reach that way.

There are occasional pitfalls that can cause issues, but define, image and default aren't them. Plus those pitfalls... you really have to work hard to screw up that badly.

The more default variables you create, the larger save files will become. But again, it's VERY unlikely you're ever going to hit any limits as long as you just do "normal" stuff. Plus is just a tiny file on disk... who cares?!?

Keep in mind, some very long running games (Milfy City, Summertime Saga, Being a DIK, Corruption, The Tyrant, etc) are bigger and more complex than anything you're likely to write in the next year.

So yeah, don't worry about it.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,964
16,209
I don't think Ren'Py has a hard limit.
Until the porting to Python 3.x is finished, it depend on the 2GB limit of Python. But this regard only the variables, therefore, as 79flavors said, it's not something that will be easily reached.
 

moskyx

Forum Fanatic
Jun 17, 2019
4,223
13,980
Considering you have nothing to fear from software's memory side of things, biggest problem I see might come from player's memory. ALL your "thinking" characters are named just "Thinking" and player would need to mentally link their font color to their respective names. Depending on the nature of game's scenes and interactions this could be somehow confusing. So, you might want to add their name to those definitions (or just get rid of them and go for the commonly accepted use of italics in textbox to show character's thoughts)
 
  • Like
Reactions: Grap and GNVE

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
ALL your "thinking" characters are named just "Thinking" and player would need to mentally link their font color to their respective names.

Good catch. I'd missed that completely.

So, you might want to add their name to those definitions (or just get rid of them and go for the commonly accepted use of italics in textbox to show character's thoughts)

Yeah. Something I'm trying to do more and more these days is have speaking characters say things with double quotes around the text and thinking characters say things within parenthesis and with italics. The other things I tend to tweak is to have any narration (any said without it being a specific character) in yellow and alter the color of any "thinking" text to be very light grey rather than pure white. Thankfully all that can be done with the Character() definition and not something you need to do with every line of dialogue.

My version of these same definitions would look something like:

Python:
define narrator = Character("", what_color="#FFFF00")

define p = Character("[persistent.pname]", color="#FF0000", what_prefix='"', what_suffix='"')
define kar = Character("Karen", color="#FFFF00", what_prefix='"', what_suffix='"')
define ken = Character("Kendal", color="#A52A2A", what_prefix='"', what_suffix='"')
define mol = Character("Molly", color="#FFCC00", what_prefix='"', what_suffix='"')
define molmary = Character("'Mary'", color="#FFCC00", what_prefix='"', what_suffix='"')
define emi = Character("Emily", color="#33CC99", what_prefix='"', what_suffix='"')
define sar = Character("Sarah", color="#FF33CC", what_prefix='"', what_suffix='"')
define san = Character("Sandra", color="#33CC00", what_prefix='"', what_suffix='"')
define mar = Character("Mary", color="#FFCC66", what_prefix='"', what_suffix='"')
define cla = Character("Claire", color="#009900", what_prefix='"', what_suffix='"')
define che = Character("Chelsey", color="#FF3399", what_prefix='"', what_suffix='"')
define amy = Character("Amy", color="#CC9933", what_prefix='"', what_suffix='"')

define p_t = Character("[persistent.pname]", color="#FF0000", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define kar_t = Character("Karen", color="#FFFF00", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define ken_t = Character("Kendal", color="#A52A2A", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define mol_t = Character("Molly", color="#FFCC00", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define molmary_t = Character("'Mary'", color="#FFCC00", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define emi_t = Character("Emily", color="#33CC99", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define sar_t = Character("Sarah", color="#FF33CC", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define san_t = Character("Sandra", color="#33CC00", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define mar_t = Character("Mary", color="#FFCC66", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define cla_t = Character("Claire", color="#009900", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define che_t = Character("Chelsey", color="#FF3399", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define amy_t = Character("Amy", color="#CC9933", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")

Using what_prefix and what_suffix to add either the " characters or the ( and ) with italics. And what_color to change the dialogue to light grey for thinking.

The result is something like:

You walk into the kitchen...
Player : "Good morning everyone."
Karen : "Good morning, Player."
Sarah : "Hey there."
Player : (Damn, Sarah looks good this morning.)
You hear someone else coming down the stairs...
Emily : "Oh good, everyone's already up."

... and, in my opinion, makes it very clear when someone is thinking, speaking or it's just narration.
 
  • Like
Reactions: GNVE

moskyx

Forum Fanatic
Jun 17, 2019
4,223
13,980
Another option being forgetting about defining characters and just write the text in narrative style instead of this screenplay style almost everybody use. Food for thought from most recent Tlaero's games
 

ChaosOpen

Well-Known Member
Game Developer
Sep 26, 2019
1,014
2,142
Considering you have nothing to fear from software's memory side of things, biggest problem I see might come from player's memory. ALL your "thinking" characters are named just "Thinking" and player would need to mentally link their font color to their respective names. Depending on the nature of game's scenes and interactions this could be somehow confusing. So, you might want to add their name to those definitions (or just get rid of them and go for the commonly accepted use of italics in textbox to show character's thoughts)
Well, their hair color matches their name color, so it's pretty easy to match names due to that.
aaaaa.png
aaaa.png
Good catch. I'd missed that completely.

Yeah. Something I'm trying to do more and more these days is have speaking characters say things with double quotes around the text and thinking characters say things within parenthesis and with italics. The other things I tend to tweak is to have any narration (any said without it being a specific character) in yellow and alter the color of any "thinking" text to be very light grey rather than pure white. Thankfully all that can be done with the Character() definition and not something you need to do with every line of dialogue.

My version of these same definitions would look something like:


Python:
define narrator = Character("", what_color="#FFFF00")

define p = Character("[persistent.pname]", color="#FF0000", what_prefix='"', what_suffix='"')
define kar = Character("Karen", color="#FFFF00", what_prefix='"', what_suffix='"')
define ken = Character("Kendal", color="#A52A2A", what_prefix='"', what_suffix='"')
define mol = Character("Molly", color="#FFCC00", what_prefix='"', what_suffix='"')
define molmary = Character("'Mary'", color="#FFCC00", what_prefix='"', what_suffix='"')
define emi = Character("Emily", color="#33CC99", what_prefix='"', what_suffix='"')
define sar = Character("Sarah", color="#FF33CC", what_prefix='"', what_suffix='"')
define san = Character("Sandra", color="#33CC00", what_prefix='"', what_suffix='"')
define mar = Character("Mary", color="#FFCC66", what_prefix='"', what_suffix='"')
define cla = Character("Claire", color="#009900", what_prefix='"', what_suffix='"')
define che = Character("Chelsey", color="#FF3399", what_prefix='"', what_suffix='"')
define amy = Character("Amy", color="#CC9933", what_prefix='"', what_suffix='"')

define p_t = Character("[persistent.pname]", color="#FF0000", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define kar_t = Character("Karen", color="#FFFF00", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define ken_t = Character("Kendal", color="#A52A2A", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define mol_t = Character("Molly", color="#FFCC00", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define molmary_t = Character("'Mary'", color="#FFCC00", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define emi_t = Character("Emily", color="#33CC99", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define sar_t = Character("Sarah", color="#FF33CC", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define san_t = Character("Sandra", color="#33CC00", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define mar_t = Character("Mary", color="#FFCC66", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define cla_t = Character("Claire", color="#009900", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define che_t = Character("Chelsey", color="#FF3399", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")
define amy_t = Character("Amy", color="#CC9933", what_prefix='{i}(', what_suffix='){/i}', what_color="#CCCCCC")

Using what_prefix and what_suffix to add either the " characters or the ( and ) with italics. And what_color to change the dialogue to light grey for thinking.

The result is something like:

You walk into the kitchen...
Player : "Good morning everyone."
Karen : "Good morning, Player."
Sarah : "Hey there."
Player : (Damn, Sarah looks good this morning.)
You hear someone else coming down the stairs...
Emily : "Oh good, everyone's already up."

... and, in my opinion, makes it very clear when someone is thinking, speaking or it's just narration.
That is kind of a good idea, problem is with the font I'm using italics don't really stand out, however, I have been looking for a way to do thinking without putting "Character Thinking"

By the way, can I put all of the names under a label so that I can collapse them(to keep everything organized)?
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
[...] problem is with the font I'm using italics don't really stand out

Italics are used in some games for thinking.
Parenthesis are used in some games for thinking.
I just combined the two for added emphasis and used color to further show the difference.
I don't see any reason why you couldn't just use the parenthesis and color only. Hell, use italics too - even if it's only a minor difference.

By the way, can I put all of the names under a label so that I can collapse them(to keep everything organized)?

It's not clear to me what it is that you're asking.

It's normal to put all Character() statements at (or near) the top of the script.rpy file. I've been known to create a new script file called characters.rpy. RenPy doesn't especially need things to be organized... that's purely down to your own view of your code. Put stuff where you'd like.
 

moskyx

Forum Fanatic
Jun 17, 2019
4,223
13,980
Well, their hair color matches their name color, so it's pretty easy to match names due to that.
View attachment 1145338
View attachment 1145337

That is kind of a good idea, problem is with the font I'm using italics don't really stand out, however, I have been looking for a way to do thinking without putting "Character Thinking"

By the way, can I put all of the names under a label so that I can collapse them(to keep everything organized)?
Yeah, if they are going to be alone on screen the name may not be needed. I was thinking in more complex scenes, with characters thinking while talking to others and with more people on screen (like Char1 says something, Char2 thinks something then Char3 answers loud before Char2 says anything, etc) But with that artstyle and hair matching name colour you'll be good enough
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,964
16,209
Yeah. Something I'm trying to do more and more these days is have speaking characters say things with double quotes around the text and thinking characters say things within parenthesis and with italics.
I'm relatively tired so I'll not try to code it, but there's surely something that can be done by using the parameters available with the say statement.

Something along the lines of :
Python:
label whatever:
    mc "Wow, mom have really big boobs !"( state="thinking" )

screen say(who, what):
[...]
                style "namebox"
                if sayParam["state"]: # Imaginary code, it depend how the parameters are stored.
                    text ( "{} {}".format( who, sayParam["state"] )  id "who"
                else:
                    text who id "who"
Summertime Saga use the say parameters, taking a quit look at the code for the "say" screen should be enough to transform this into a real code.

This way, only one Character object is needed by character, and the player still have the explicit nature of the dialog line.
 

ChaosOpen

Well-Known Member
Game Developer
Sep 26, 2019
1,014
2,142
Italics are used in some games for thinking.
Parenthesis are used in some games for thinking.
I just combined the two for added emphasis and used color to further show the difference.
I don't see any reason why you couldn't just use the parenthesis and color only. Hell, use italics too - even if it's only a minor difference.
I'll definitely give it some thought.

It's not clear to me what it is that you're asking.

It's normal to put all Character() statements at (or near) the top of the script.rpy file. I've been known to create a new script file called characters.rpy. RenPy doesn't especially need things to be organized... that's purely down to your own view of your code. Put stuff where you'd like.
I mean putting it like this:
aaaa.png

So when I'm not using them, I can just collapse it like this:
aaaaa.png

Yeah, if they are going to be alone on screen the name may not be needed. I was thinking in more complex scenes, with characters thinking while talking to others and with more people on screen (like Char1 says something, Char2 thinks something then Char3 answers loud before Char2 says anything, etc) But with that artstyle and hair matching name colour you'll be good enough
Actually, I was thinking of leaving it the name up there the same in both cases, the only difference is the name turns grey when they are thinking. I know it's popular to have the MC have a constant running dialogue when in conversations, but personally I dislike it. Whenever two people are in a scene, unless I absolutely need to, I prefer to get my point across through dialogue. This is because I think that one only talks to themselves when they are alone as a conversation moves too fast for you to consciously mull over every single statement, there is also the more practical reason of it breaking up the flow of a conversation when a character has to stop and monologue his reaction every single line.

For example, take 79Flavor's statement, where he put the character thinking: "Damn, Sarah looks good this morning." I know it was simply something 79Flavor's thought up quickly to demonstrate the different types of dialogue, but I actually do see such statements all the time. The point of monologue is basically narration, to tell the the audience things they wouldn't be able to figure out without it. The audience can see the character, this is no need to explain how she looks. /rant
 

felipons

Fluffy, The Destroyer of Worlds
Modder
Game Developer
Jan 15, 2018
266
1,137
As many said it's virtually impossible to reach the limit of variables.

But you do have alot of variables, so you could put them in a different file for organization, and/or do something like this.

Python:
init python:
    class PCharacter:
        def __init__(self, name, color):
            self.say = Character(name, color = color)
            self.think = Character('{i}Thinking{/i}', color = color)

define karen = PCharacter('Karen', '#ffff00')
define kendal = PCharacter('Kendal', '#a52a2a')

To use you just go like this.

Python:
karen.say "Hello World!"
karen.think "♪  Somebody once told me  ♫"
karen.think "♪  The world is gonna roll me ... ♫"
you can also put other information inside of the PCharacter class that all characters have in common.

Another tip I can give you is that you can change the color, size and other information of the text spoken.
e.g.:

Python:
init python:
    class PCharacter:
        def __init__(self, name, color):
            self.think = Character(name, image="", who_color=color, what_color="#ddd", what_prefix="{size=-5}{i}", what_suffix="{/i}{/size}")
The same way there is also who_prefix and who_suffix, and many other variables if you check the
 
Last edited:

ChaosOpen

Well-Known Member
Game Developer
Sep 26, 2019
1,014
2,142
As many said it's virtually impossible to reach the limit of variables.

But you do have alot of variables, so you could put them in a different file for organization, and/or do something like this.

Python:
init python:
    class PCharacter:
        def __init__(self, name, color):
            self.say = Character(name, color = color)
            self.think = Character('{i}Thinking{/i}', color = color)

define karen = PCharacter('Karen', '#ffff00')
define kendal = PCharacter('Kendal', '#a52a2a')
Python:
init python:
    class PCharacter:
        def __init__(self, name, color):
            self.think = Character(name, image="", who_color=color, what_color="#ddd", what_prefix="{size=-5}{i}", what_suffix="{/i}{/size}")
What does "def" and "__init__" do?

Like, I'm sure it's some useful stuff in there, but I don't actually understand what you're telling me to do.
 

GNVE

Active Member
Jul 20, 2018
724
1,185
These are part of basic to intermediatish python programming. If you want to learn more may I suggest the free university of waterloo's into python. It won't take too much time but help you massively in understanding what you are doing in Ren'Py. It won't actually answer what the __init__ statement does as that is slightly more advanced but it get's the basics down in one of the best tutorials I've come across and will allow you to branch out into slightly more advanced tutorials.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
What does "def" and "__init__" do?

Honestly, if you're asking that question... you are not ready for the answer yet.

def and __init__ are python. They are used to create custom functions and classes. def is python's "define" (different from RenPy's define). __init__ is a reserved name of a function that is executed when the structure is initially created (You say "create this thing" and the first thing that happens is that python looks to see if there's an "__init__" that needs running during it's creation).

Seriously, don't worry about it.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
I mean putting it like this:
So when I'm not using them, I can just collapse it like this:

If you don't want to see them most of the time, I would simply move all those define x = Character() statements to a new RenPy file. Something like characters.rpy.

RenPy doesn't care where certain statements like define, image or default are within the code. During game startup, RenPy scans for all these type of statements and processes them regardless of where they exist.

There are rules which govern the order in which they are processed, but honestly you don't need to know it at that level of detail at the stage of coding you're at. For the moment, just accept "they can be anywhere".

That's anywhere in the code (top, middle, bottom, in the middle of an if statement) and they can be in any .rpy file, named anything.

All that said, the general convention is that all statements like that go at (or near) the top of the script file. Since they are processed during game startup, it makes sense to us mere mortals that they appear in the code before label start:. It doesn't need to be the top of script.rpy, just the top of any script file (hence the suggestion for characters.rpy).

In the past, I've separated out a lots of types of code from the main script file. Character definitions, variables, image statements, animations, all sorts of stuff. Experience has taught me that it's mainly pointless. RenPy doesn't care, so do whatever keeps you sane.