How to add special characters in renpy dialogue

BillyGames

Member
Game Developer
Apr 16, 2020
100
211
As the title says, how can I add for example "$" or "%" character in renpy dialogue ?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,376
15,289
As the title says, how can I add for example "$" or "%" character in renpy dialogue ?
Firstly, $ is a character like any other when in a string.
Secondly, like for the other special characters ([, {, \), you've two way to add a %. You can do as said , and escape the character by adding a \ right before it, or you can just double the character.

Therefore, you can do it either this ways, mc "I'll give you 10 \% of the total", or that way, mc "I'll give you 10 %% of the total".
 

BillyGames

Member
Game Developer
Apr 16, 2020
100
211
Firstly, $ is a character like any other when in a string.
Secondly, like for the other special characters ([, {, \), you've two way to add a %. You can do as said , and escape the character by adding a \ right before it, or you can just double the character.

Therefore, you can do it either this ways, mc "I'll give you 10 \% of the total", or that way, mc "I'll give you 10 %% of the total".
Thank you! I really appreciate it.
another question off topic but i think you know the answer.
how can i make renpy check if there is a label available and then do some action
I know its an "if" statement but i don't know how to make renpy check for the label
Edit: Nevermind i'll just check the code of one of the games with family love.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,376
15,289
how can i make renpy check if there is a label available and then do some action

Code:
label whatever:
    if renpy.has_label( "patreonBonus1" ):
        call patreonBonus1
    jump endOfUpdate

label endOfUpdate:
    "This is the end, beautiful friend."
    "This is the end, my only friend, the end."
    return
patreon.rpy
Code:
label patreonBonus1:
   [something]
   return
 

BillyGames

Member
Game Developer
Apr 16, 2020
100
211
Hello again i dont want to spam the forums with threads so you might be still following this thread
Mr. anne O'nymous

Do you know can I force everyone to watch the intro the first time, and they get a choice if to skip for the 2nd etc playthrough ?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,376
15,289
Do you know can I force everyone to watch the intro the first time, and they get a choice if to skip for the 2nd etc playthrough ?
By using . Practically it will looks more or less like this :

Code:
label start:
    # Never saw the introduction, so show it
    if persistent.introSeen is None:
        jump intro
    # Have seen the intro at least once, so ask what to do
    menu:
        "Watch the introduction":
            jump intro
        "Skip the introduction":
            jump gameStart

# The introduction
label intro:
    [Whatever you want]
    # Mark that the introduction have been seen.
    $ persistent.introSeen = True
    # and continue.
    jump gameStart

label gameStart:
    [whatever you want]
 
  • Like
Reactions: BillyGames

BillyGames

Member
Game Developer
Apr 16, 2020
100
211
again I am looking for my Senpai! will he answer ?:p
what's the difference between init -1, init 499 and 501 those are the ones that I encountered
I had a problem in main menu, i wanted to add some pics and I couldn't.
so I looked into other people's code and I found that adding init 499 and -501 solve the problem
can you explain what that is, please ? I tried to search the web with no results
thanks
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,376
15,289
what's the difference between init -1, init 499 and 501 those are the ones that I encountered
By default, the init blocks are proceeded according to the alphabetical order of the path+filename where they are located :
  1. game/characters/vanessa.rpy
  2. game/core/constants.rpy
  3. game/core/tutorial.rpy
  4. game/screens.rpy
  5. game/script.rpy

But like you can see, in this case the characters will be initialized before the core of your game, which don't feel right. Perhaps that Vanessa will need some constants, but you can't create them during the init phase, because the constants feature you created isn't initialized yet.
It's possible to move those constants directly into "game/core/constants.rpy", but what's the interest to have a "game/characters/vanessa.rpy" if you start to disperse everything related to Vanessa in different files ?

Therefore, the initialization process follow a second rules, the "priority offset". The init blocks will be proceeded according to this offset, and for blocks that have the same "priority offset", it's the alphabetical order that will be applied.
This let you define the init blocks in "game/core/constants.rpy" at -1, to ensure that the core will be initialized when you'll finally initialize the rest of the game ; and so, you can create constants into "game/characters/vanessa.rpy" that will have init blocks at the default offset (0).

Be noted that the same apply for all the statements that works at init level like default or image by example. By default they are proceeded at the "priority offset" 0, but if they are preceded by an init 1: or init 1 python they will be proceeded at the "priority offset" 1.
You can also change the priority offset for those statement by changing directly the value of .

Finally, a big part of Ren'py's core is in fact wrote in Ren'py language. While those files are proceeded before the files in the "game" folder, there initialization is grouped with the one of the game. This mean that, by choosing carefully the "priority offset", you can initialize part of your game before Ren'py initialize part of its core.
It's obviously not recommended to do this, but sometimes it can help.
 
  • Like
Reactions: 79flavors

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,583
2,222
[...] but what about 499 and 501 ?
It's just a number.

init: blocks are processed in the order of that number, from low to high. So -485 would be run before -322. -1 before 0.

If the number isn't specified, it defaults to 0.

In your case, it looks like someone picked 499 and 501 to run after the usual stuff (499 being higher than 0). Maybe they'd seen someone use 100 or 200 and wanted to make sure their code ran later than that. Maybe they just threw darts at a dart board until they came up with a number they liked. Either way, they also seem to have decided that there were two sections of code and one needed to run after the other (otherwise they could have just used 499 only).

Where two (or more) init: blocks exist with the same number, things are processed alphabetically according to their filenames.

In practical terms, the numbering allows for the developer to override their own code. The example that comes to mind is an incest patched game. The "normal" version of the game ships with:

Python:
init:
    define incest = False

# ... then the rest of the game

but a patch file can be downloaded separately and has only 2 lines:

Python:
init 1:
    define incest = True

In this case, it doesn't matter what the filenames are, because the init: level numbers are different. Then as the game is initializing, all the init 0: level code is executed and the value of incest is set to False. Then... if the patch file doesn't exist... that is the end of it. However if the patch file does exist... once all the init 0: level code has been run, all the init 1: code starts (and so on). The end result being that the value of incest is set to True. Obviously this is a simple example... things can be as simple or complicated as you like.

My rule of thumb is that if you want to play it safe, you use negative numbers (that way, there is no way of interfering with the normal RenPy initialization). If you're deliberately overriding something (even if that something is RenPy itself), use higher numbers... which will often mean positive numbers.
 
  • Like
Reactions: anne O'nymous

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,376
15,289
Either way, they also seem to have decided that there were two sections of code and one needed to run after the other (otherwise they could have just used 499 only).
It feel like this person expected a priority of 500 somewhere, and had things to do before (499) and after (501) it. But I don't know what was expected ; Ren'py itself works at -1500 and 1500.
 
  • Like
Reactions: 79flavors

BillyGames

Member
Game Developer
Apr 16, 2020
100
211
Thanks, a lot guys, I thought the number itself means something but I guess its only the order of executed code.
I'll go back and change the numbers in my code no one needs to know xD
 

BillyGames

Member
Game Developer
Apr 16, 2020
100
211
One last thing anne O'nymous
my game is ready, and I'm going to compile it soon. anything I need to know before I do it?
like maybe my persistent data goes into the build or saves (I know its far fetched, but better safe than sorry)
I have tested everything using the launch thing in renpy and everything works as intended
anything to check for before hitting the BUILD Button?
thank you
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,376
15,289
One last thing anne O'nymous
my game is ready, and I'm going to compile it soon. anything I need to know before I do it?
Always have a small "test.rpy" file with:
Code:
init python:
    config.developer = True
for your use only, and launch the game with it at least once before each release. There's errors that are shown only in the developer mode. They aren't effectively breaking errors (which mean that Ren'py know how to deal with them), but can still break the game ; like by example duplicated labels.
Therefore, see it as a last check to ensure that all seem effectively correct.


like maybe my persistent data goes into the build or saves (I know its far fetched, but better safe than sorry)
Your persistent data are in the "game/save" directory, therefore they will not be included in the distribution file.


anything to check for before hitting the BUILD Button?
Except that it's your lucky day, nothing... or perhaps everything ?

I have more than 20 years of experience as coder, and I've seen everything happen. Code that worked fine and suddenly don't works anymore, thing you thought you had controlled twice and that in fact you forgot to control, and I don't talk about the classical, "it works for me, why do you have an error ?".
Just accept that you are just human and learn from what will happen ;) Knowing that most of the time, nothing will happen.
 
  • Like
Reactions: BillyGames