- Jun 14, 2018
- 1,611
- 2,258
Okay... So I've thinking about the number of developers who regularly visit the F95zone forums and some coding ideas.
One of them is for a common way of storing the player's preferred character names. In such a way that names would carried forward into future games.
RenPy has something called
After a bit of tweaking and some real world messing about, I've come up with this...
So in this example:
Most games would only use a player's first name... but I wanted to show an extended example.
One quirk is that (as far as I know), multi game persistency doesn't work on Android or iOS. There are apparently ways around it on Android... but I really couldn't be arsed that much. So instead, I have the code check to see if we're running on a PC (Windows/Linux/Mac, etc).
I check to see if a name is already available... and if there is one already stored - I use it as my standard/default name. Otherwise, I just go with whatever name(s) were coded into this game. I don't assume that just because a surname is stored, that a forename is also stored. I do each one by one.
I then let the player either pick the default name, or type in their own.
Then... if the player has picked a new name - store it in the multi-game persistent file. This allows people to accept the default names, without them being carried forward into new games. Only when a player overrides the defaults are they stored away to be used in the future.
Finally, the multi game data file is saved... just once... and again, only if we're running on a PC.
I've chosen the name of "namedata.f95zone.to" as the common store name. If people use that same name, it will both acknowledge where they found this code and mean that all other games that use similar code will share the same character names.
I've also added a comment with recommended common store names - since you're unlikely to want your default male characters to have the same name as your female characters. In this example I've only used
I've also added suggestions for store names for other common NPC types. Moms, Dads and Big Sisters and Little Sisters are all pretty common. The others should be fairly self explanatory. Though very few games actually think to let the player name anyone except the protagonist. (on that note: to anyone that does... please show the character's picture and explain who they are when asking for names.... there's nothing worse than seeing a young looking girl when naming - only to realize that it's not your younger sister... but the mom AFTER you've picked her name!).
Yes... it's more complicated and longer to type in than most of the existing code most people would cut and paste - but I think it's worth it. (well, I would... wouldn't I?)
Maybe if the idea catches on... it'll become a semi-common standard... and players will be continue to be surprised when the names from one game carry forward to the next.
One of them is for a common way of storing the player's preferred character names. In such a way that names would carried forward into future games.
RenPy has something called
You must be registered to see the links
. A way of creating a shared set of variables across any game that uses the correctly named identifier.After a bit of tweaking and some real world messing about, I've come up with this...
Python:
init python:
mp_ndata = MultiPersistent("namedata.f95zone.to")
# Recommended: male_fname, male_sname, female_fname, female_sname, futa_fname, futa_sname, other_fname or other_sname (or any, or all of these).
# Other recommendations: bigsis_fname, lilsis_fname, bigbro_fname, lilbro_fname, mom_fname, dad_fname, malebff_fname or femalebff_fname. (Again, use any or use none).
default std_player_fname = "Jon"
default std_player_sname = "Dough"
default mc_name = "Unknown"
default mc_sname = "Unknown"
define mc = Character("[mc_name]", color="#66cc00", who_outlines=[(2,"#000000")], what_prefix="\"", what_suffix="\"", what_outlines=[(2,"#000000")])
label start:
# allow default name(s) to be saved across multiple games
if renpy.variant("pc"):
if mp_ndata.male_fname != None:
$ std_player_fname = mp_ndata.male_fname
if mp_ndata.male_sname != None:
$ std_player_sname = mp_ndata.male_sname
$ mc_name = renpy.input("What is your name? {i}(Leave empty for '[std_player_fname]'){/i}", )
$ mc_name = mc_name.strip() or std_player_fname
$ mc_sname = renpy.input("What is your surname? {i}(Leave empty for '[std_player_sname]'){/i}", )
$ mc_sname = mc_sname.strip() or std_player_sname
if renpy.variant("pc"):
if mc_name != std_player_fname:
$ mp_ndata.male_fname = mc_name
if mc_sname != std_player_sname:
$ mp_ndata.male_sname = mc_sname
$ mp_ndata.save()
mc "Hello World. My name is [mc_name] [mc_sname]."
# [...] blah, blah... the rest of your game...
mc
is the Character
object for the main character.mc_name
is the character's given name.mc_sname
is the character's surname.Most games would only use a player's first name... but I wanted to show an extended example.
One quirk is that (as far as I know), multi game persistency doesn't work on Android or iOS. There are apparently ways around it on Android... but I really couldn't be arsed that much. So instead, I have the code check to see if we're running on a PC (Windows/Linux/Mac, etc).
I check to see if a name is already available... and if there is one already stored - I use it as my standard/default name. Otherwise, I just go with whatever name(s) were coded into this game. I don't assume that just because a surname is stored, that a forename is also stored. I do each one by one.
I then let the player either pick the default name, or type in their own.
Then... if the player has picked a new name - store it in the multi-game persistent file. This allows people to accept the default names, without them being carried forward into new games. Only when a player overrides the defaults are they stored away to be used in the future.
Finally, the multi game data file is saved... just once... and again, only if we're running on a PC.
I've chosen the name of "namedata.f95zone.to" as the common store name. If people use that same name, it will both acknowledge where they found this code and mean that all other games that use similar code will share the same character names.
I've also added a comment with recommended common store names - since you're unlikely to want your default male characters to have the same name as your female characters. In this example I've only used
male_fname
and male_sname
- but I could have used more... or less.I've also added suggestions for store names for other common NPC types. Moms, Dads and Big Sisters and Little Sisters are all pretty common. The others should be fairly self explanatory. Though very few games actually think to let the player name anyone except the protagonist. (on that note: to anyone that does... please show the character's picture and explain who they are when asking for names.... there's nothing worse than seeing a young looking girl when naming - only to realize that it's not your younger sister... but the mom AFTER you've picked her name!).
Yes... it's more complicated and longer to type in than most of the existing code most people would cut and paste - but I think it's worth it. (well, I would... wouldn't I?)
Maybe if the idea catches on... it'll become a semi-common standard... and players will be continue to be surprised when the names from one game carry forward to the next.