How to make a .txt file depending on the renpy.input?

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
MystikGaming
Newbie
Posts: 4
Joined: Wed Jul 25, 2018 7:03 pm
Projects: Akai Ito - The Red String of Destiny
Organization: Night Shift Studios
Location: Argentina
Contact:

How to make a .txt file depending on the renpy.input?

#1 Post by MystikGaming »

Hi! I got a question to make about creating a .txt file depending on which name you input at the beggining of game.

It's for an Easter Egg, like if you put as your name: "Michael" , it writes a .txt file with a short story.

I'd like to know how to ask whats the current renpy.input and how to write the .txt file.

Thank you very much!

(Sorry for my english, It's not my dominant language)

User avatar
erickcire95
Regular
Posts: 33
Joined: Tue Dec 26, 2017 7:38 pm
Contact:

Re: How to make a .txt file depending on the renpy.input?

#2 Post by erickcire95 »

First you have to store the input in a variable. Something like:

Code: Select all

character_name = renpy.input("What's your name?")
Then, create a txt file using python's open function with mode "w" (writting):

Code: Select all

python:
    with open("Name of the file.txt","w") as egg:
        egg.write("Some text " + character_name + " some more text")
    egg.closed
Where:

"Name of the file" will be the file name that is created.
character_name is the variable where you stored the player's input.
"Some text " & " some more text" are the text that you want to put inside the txt file.

User avatar
Minuteman
Regular
Posts: 40
Joined: Sat Feb 24, 2018 2:02 pm
Location: On duty
Contact:

Re: How to make a .txt file depending on the renpy.input?

#3 Post by Minuteman »

erickcire95 wrote: Thu Jul 26, 2018 2:52 am First you have to store the input in a variable. Something like:

Code: Select all

character_name = renpy.input("What's your name?")
Then, create a txt file using python's open function with mode "w" (writting):

Code: Select all

python:
    with open("Name of the file.txt","w") as egg:
        egg.write("Some text " + character_name + " some more text")
    egg.closed
Where:

"Name of the file" will be the file name that is created.
character_name is the variable where you stored the player's input.
"Some text " & " some more text" are the text that you want to put inside the txt file.
Sorry for off topic!
This looks amazing, can I ask is there any more possible "eggs" in renpy engine to make?
of the people for the people

MystikGaming
Newbie
Posts: 4
Joined: Wed Jul 25, 2018 7:03 pm
Projects: Akai Ito - The Red String of Destiny
Organization: Night Shift Studios
Location: Argentina
Contact:

Re: How to make a .txt file depending on the renpy.input?

#4 Post by MystikGaming »

erickcire95 wrote: Thu Jul 26, 2018 2:52 am First you have to store the input in a variable. Something like:

Code: Select all

character_name = renpy.input("What's your name?")
Then, create a txt file using python's open function with mode "w" (writting):

Code: Select all

python:
    with open("Name of the file.txt","w") as egg:
        egg.write("Some text " + character_name + " some more text")
    egg.closed
Where:

"Name of the file" will be the file name that is created.
character_name is the variable where you stored the player's input.
"Some text " & " some more text" are the text that you want to put inside the txt file.
It worked! Thank you very much!

User avatar
erickcire95
Regular
Posts: 33
Joined: Tue Dec 26, 2017 7:38 pm
Contact:

Re: How to make a .txt file depending on the renpy.input?

#5 Post by erickcire95 »

Minuteman wrote: Sat Jul 28, 2018 1:50 pm Sorry for off topic!
This looks amazing, can I ask is there any more possible "eggs" in renpy engine to make?
Well... This question is very hard to answer. The simplest answer is: Yes. you can make a lot of easter eggs in Ren'py, but I don't know ecaxtly what you are looking for. Could you be a little more precise?

User avatar
Minuteman
Regular
Posts: 40
Joined: Sat Feb 24, 2018 2:02 pm
Location: On duty
Contact:

Re: How to make a .txt file depending on the renpy.input?

#6 Post by Minuteman »

erickcire95 wrote: Sun Jul 29, 2018 7:21 pm
Minuteman wrote: Sat Jul 28, 2018 1:50 pm Sorry for off topic!
This looks amazing, can I ask is there any more possible "eggs" in renpy engine to make?
Well... This question is very hard to answer. The simplest answer is: Yes. you can make a lot of easter eggs in Ren'py, but I don't know ecaxtly what you are looking for. Could you be a little more precise?
To be honest...I can't tell right now what I want to do.....perhaps you have some examples? What possible renpy can generate?
of the people for the people

MisakiCRT
Newbie
Posts: 1
Joined: Mon Feb 18, 2019 4:22 pm
Contact:

Re: How to make a .txt file depending on the renpy.input?

#7 Post by MisakiCRT »

Wonderful help! Also, I would like a similar code. Just a difference, could the player's message be put in the text file instead of that? It's also quite an easter egg. Though this is another code, I am using python to verify if the player's message has certain words, and if it has, it will open a secret ending or something like that. But for that, I must somehow put player's message in a .txt file.

Post Reply

Who is online

Users browsing this forum: No registered users