[SOLVED] Persistent Player Data

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
4listair
Newbie
Posts: 11
Joined: Tue Jul 31, 2018 10:54 pm
Contact:

[SOLVED] Persistent Player Data

#1 Post by 4listair »

Is it possible to make a player name persistent? So, if you close the game, it would retain your name when you came back?

Going off of that, is it possible to put player names in the settings, rather than having it as a prompt within the script?

Thanks!
Last edited by 4listair on Sun Aug 05, 2018 9:17 pm, edited 2 times in total.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Persistent Player Data

#2 Post by Per K Grok »

4listair wrote: Fri Aug 03, 2018 3:06 pm Is it possible to make a player name persistent? So, if you close the game, it would retain your name when you came back?

Going off of that, is it possible to put player names in the settings, rather than having it as a prompt within the script?

Thanks!
1. With this code the game will ask for the players name the first time a new game is started.
The following times new games are started the game will go directly to welcome (pname)

Code: Select all

default pname=""

    if not persistent.playername:
        $ pname= renpy.input("What is your name?")
        $ pname=pname.strip()
        $ persistent.playername = pname
        $ renpy.save_persistent()
    else:
        $ pname=persistent.playername

    "Welcome [pname]."
You might want to include a possibility to change the player name.

2. Yes you could add an input element to the settings screen - or another screen- and collect the input data for the player name from that.

Post Reply

Who is online

Users browsing this forum: apocolocyntose, Bing [Bot], Majestic-12 [Bot], Semrush [Bot]