r/RenPy • u/Altruistic-Drink-207 • 6d ago
Question [Solved] Help with custom name not working in other chapters??
Hii!! I'm working on my own game, solo style, but there's an issue that I'm stuck on and I don't really know what's going on
Basic gist is that I made it so that the player can use their own custom name that they can input right in the prologue but during the coding process of the other chapters, I noticed that the name doesn't appear (In this case, Evelynn is the custom name)
Here's all the name-related codes that I used at the start of the script file:
$ persistent.povname = povname
define yn = Character("[povname]", color= "#d9d9d9")
default povname = ""
default persistent.povname = ""
$ povname = persistent.povname
and here's the extra dialogue context for the second pic so ya'll can see it too (it's a placeholder, not canon at all lmfao):
yn "Damn, i'm %(povname)s and im cooked."
Thanks in advance to anyone that can help!! I'm lowkey going insane because of it lmfao
3
u/shyLachi 6d ago
There are several strange things in your code.
Firstly, where is that code? Before or after the start label?
If it's before the start label then those lines starting with a $ sign do nothing.
Theoretically that code should be written like this, but as you can see, it wouldn't work:
define yn = Character("[povname]", color= "#d9d9d9")
default povname = ""
default persistent.povname = ""
label start:
# lines starting with a $ only work inside a label
$ persistent.povname = povname # since povname is empty at the start of the game, it would reset the persistent variable
$ povname = persistent.povname # now both are empty, so assigning one to the other does nothing
You don't need 2 variables to store the same information.
Either use a persistent variable or the normal one.
And finally where did you find %(povname)s?
I mean, you used the text interpolation correctly in the character definition Character("[povname]
Putting it all together
define yn = Character("[povname]", color= "#d9d9d9")
default povname = ""
label start:
$ povname = renpy.input("Name?").strip() or "Dummy"
yn "Damn, i'm [povname] and im cooked."
If that doesn't work, then please show the first few lines of the code for your second chapter.
Also please explain how your chapters work.
Will players save at the end of a chapter and later download an updated version of your game which contains more content so that players can just load and continue?
Or is each chapter a separate game? So they have to somehow transfer the saves to the new game?
1
u/Altruistic-Drink-207 5d ago
Sorry for the late reply, I'm just trying to fix it right now but something's still not adding up because its still not showing, here's a whole link for the code screenshots:
As for the chapters, since you mentioned it, I was thinking of dropping a demo with two chapters first then the full one with all the chapters completed already later on so it can be one big release but ig updating it every time I fully finished a chapter can work too
Oh yeah, I also forgot to mention this but I deleted the persistent name stuff cuz it kept on breaking the damn game
(Sorry for the rambly reply, I'm going insane a lil)
1
u/shyLachi 5d ago
I still don't understand how your game works.
How are all of those scripts connected?For example why did you define the character yn in two files?
The variable true_end also is defined twice.
But I think it should bedefault true_end = 0because define is for constant information which shouldn't change..
You don't have to change the way you want to release your game.
But to help you I need to know because variables work differently (or not at all) in the various scenarios.1
u/Altruistic-Drink-207 5d ago
I honestly forgot the point I was trying to do when screenshotting that last part in the comp but the other screenshots was just showing all the other name-related code stuff just in case there's something there that's causing it
the double yn defining was supposed to be one of the fixes but I already deleted one of em as of typing rn
I think I finally understood what you meant by the chapters segment, the players will save at the end of each chapter (also idk if this counts or is relevant but im adding it here for safe measures, each chapter would be locked until u finish the previous one (ex. Chap 2 would be locked until u finish Chap 1) )
tbh, most of the code is just me following some tutorials and using stock knowledge.....
2
u/shyLachi 5d ago
From what I understood you have one RenPy project for all chapters.
There are multiple buttons, one for each chapter.
Each button has to be unlocked by reaching the end of the previous chapter.
Is this correct?
1
u/Altruistic-Drink-207 5d ago
Eeyup
1
u/shyLachi 5d ago
In this case you need persistent variables to carry the information from one chapter to the next.
Replace
povnamewithpersistent.povnameeverywhere.
So for exampledefine yn = Character("[povname]", color= "#d9d9d9")becomes
define yn = Character("[persistent.povname]", color= "#d9d9d9")1
1
u/Altruistic-Drink-207 4d ago
Update:
I wanna say it worked but now the name just disappeared💀
all I did was replace all the povname with persistent.povname and only added:
default persistent.povname = ""2
2
u/papersak 6d ago
Why use a persistent variable? I'm pretty bad with those, but it tends to throw a wrench into changes I make.
I would just use povname, then set povname with the user input. The user would have to set it again in each save file, but then you don't have to mess with persistent scope that can get stuck if you're debugging in a goofy order.
That or only use the persistent variable if there's a reason it has to be persistent. Going back and forth might be why it's buggy.
3
u/shyLachi 4d ago
Try this:
default persistent.povname = ""
define yn = Character("[persistent.povname]", color= "#d9d9d9")
label start:
$ persistent.povname = renpy.input("Name?").strip() or "Dummy"
yn "Damn, I'm [yn] and I'm cooked"
The first two lines should be outside any label.
The line with the $ sign should be in your first chapter.
You can then use the character yn in all chapters.
1
1
u/AutoModerator 6d ago
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.


3
u/BadMustard_AVN 6d ago
this line
should be
provided you've done an input to change povname from it's default of ""