How to write external files?
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.
-
- Newbie
- Posts: 2
- Joined: Mon Dec 04, 2017 6:49 pm
- Contact:
How to write external files?
Hello I'm a bit knew to python, i know mostly the basics and some of the advanced stuff but i'm stumped on how to create text.txt files in the game folder.
you know..
breaking the 4th wall and stuff
is there any way i can do that, if so please explain to me as if im a 3 year old cause i have no god damn clue
you know..
breaking the 4th wall and stuff
is there any way i can do that, if so please explain to me as if im a 3 year old cause i have no god damn clue
-
- Newbie
- Posts: 2
- Joined: Mon Dec 04, 2017 6:49 pm
- Contact:
Re: How to write external files?
Dw i figured it out lol
$ f = open("filename.txt","w+")
$ f.write("text")
$ f.close()
puts file in game directory
$ f = open("filename.txt","w+")
$ f.write("text")
$ f.close()
puts file in game directory
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: How to write external files?
Note that this might not work on all platforms. It's actually a really hard problem, since the game's directory might not be writeable on all platforms. (It probably isn't on mac, iOS, and Android.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: How to write external files?
Saves folder and its parent (where trace file is written) should be writable on platforms, right?
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: How to write external files?
On Android, apps have access to read and execute from folders, but they do not have permission to write.
Saving is done in another folder where it does have permission to write, perhaps you could work out how to use that folder?
Saving is done in another folder where it does have permission to write, perhaps you could work out how to use that folder?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
- Donmai
- Eileen-Class Veteran
- Posts: 1960
- Joined: Sun Jun 10, 2012 1:45 am
- Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
- Projects: Slumberland
- Location: Brazil
- Contact:
Re: How to write external files?
Just a guess, but if connorofford question is related to the way DDLC plays with its internal files, I'm also intrigued and I believe what that game does is extract those .chr files from its .rpa archives. I don't know if that's the way it really works, but anyone interested may take a look here: https://www.renpy.org/doc/html/file_pyt ... ile-access
Don't know if that solves the problem of the game directory not being writable is some OS. I'm not even a programmer and I may be talking hf@ls#rh$jf& here.
Don't know if that solves the problem of the game directory not being writable is some OS. I'm not even a programmer and I may be talking hf@ls#rh$jf& here.
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)
TOIRE NO HANAKO (A Story About Fear)
Re: How to write external files?
@Imperf3kt where would we be able to write files in Android?
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: How to write external files?
I'm afraid this is something I never looked into so can't help with, sorry.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Re: How to write external files?
Its okay, I found a workaround using io.BytesIO which provides me an in-memory file that I can manipulate as needed. So viewtopic.php?f=51&t=55866 works on Android as well.
Who is online
Users browsing this forum: Majestic-12 [Bot]