Hello! I tried creating a file with python at a specific moment of my story, but I can't get it to work.
I used the code in the image below.
I'm a beginner when it comes to coding, so I might've messed something up.
Thanks in advance!
[SOLVED]Creating a file at a certain moment of the story
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.
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.
- TsukiWorks
- Regular
- Posts: 27
- Joined: Sat Jun 23, 2018 6:50 am
- Projects: The Misunderstood
- Deviantart: TsukiWorks
- Contact:
[SOLVED]Creating a file at a certain moment of the story
- Attachments
-
- Code.png (4.01 KiB) Viewed 482 times
- 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: Creating a file at a certain moment of the story
You need to go through three steps:TsukiWorks wrote: ↑Fri Jul 27, 2018 12:39 pm Hello! I tried creating a file with python at a specific moment of my story, but I can't get it to work.
I used the code in the image below.
I'm a beginner when it comes to coding, so I might've messed something up.
Thanks in advance!
Open the file for writing,
write and
close the file.
try this
Code: Select all
python:
with open("noteSaveMe.txt", "w") as f:
f.write(" Save me")
f.close()
- TsukiWorks
- Regular
- Posts: 27
- Joined: Sat Jun 23, 2018 6:50 am
- Projects: The Misunderstood
- Deviantart: TsukiWorks
- Contact:
Re: Creating a file at a certain moment of the story
Thank you, I solved it!Per K Grok wrote: ↑Fri Jul 27, 2018 1:25 pmYou need to go through three steps:TsukiWorks wrote: ↑Fri Jul 27, 2018 12:39 pm Hello! I tried creating a file with python at a specific moment of my story, but I can't get it to work.
I used the code in the image below.
I'm a beginner when it comes to coding, so I might've messed something up.
Thanks in advance!
Open the file for writing,
write and
close the file.
try thisI think the file will end up in the renpy folder but I gave it a unique name if you need to search for it.Code: Select all
python: with open("noteSaveMe.txt", "w") as f: f.write(" Save me") f.close()
-
- Regular
- Posts: 111
- Joined: Fri Oct 11, 2013 12:46 am
- Contact:
Re: [SOLVED]Creating a file at a certain moment of the story
You don't need f.close() at the end. The "with open" statement will close the file at the end of the block.
Should work just fine.
Code: Select all
python:
with open("noteSaveMe.txt", "w") as f:
f.write(" Save me")
Who is online
Users browsing this forum: Google [Bot]