Code: Select all
f = open('testfile.txt','w')
f.write('\ntext')
f.close()
Code: Select all
f = open('testfile.txt','w')
f.write('\ntext')
f.close()
If the said statement is placed into a python block (or an init python block), the following error occurs:SuperbowserX wrote: ↑Tue Aug 28, 2018 1:42 pm You can run Python statements in Ren'py. To run a Python statement at a specific point in your script, just use a python block. To run it at startup, just use an init python statement.
https://www.renpy.org/doc/html/python.html
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 3, in script
python:
File "game/script.rpy", line 4, in <module>
file = open('testfile,txt','w')
IOError: [Errno 13] Permission denied: u'testfile.txt'
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 3, in script
python:
File "/Users/user/Desktop/renpy-6.99.12.4-sdk/renpy/ast.py", line 848, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "/Users/user/Desktop/renpy-6.99.12.4-sdk/renpy/python.py", line 1812, in py_exec_bytecode
exec bytecode in globals, locals
File "game/script.rpy", line 4, in <module>
file = open('testfile,txt','w')
IOError: [Errno 13] Permission denied: u'testfile.txt'
Darwin-17.7.0-x86_64-i386-64bit
Ren'Py 6.99.14.1.3218
Text File Output Testing 1.0
Tue Aug 28 17:43:19 2018
Code: Select all
label start:
"Help"
python:
f = open('testfile.txt','w')
f.write('\ntext')
f.close()
"Hello"
return
Code: Select all
with open( os.path.join( renpy.config.gamedir, "testfile.txt" ), 'w' ) as f:
f.write( 'text' )
Thanks! That actually worked! Now I am curious if there is a way to make it so that the text file is saved to (or created on) the desktop or the document folder. Is that possible? As of right now, the text file would be imbedded within the game file and normally would not be accessible to the player.Remix wrote: ↑Tue Aug 28, 2018 7:03 pmMight work betterCode: Select all
with open( os.path.join( renpy.config.gamedir, "testfile.txt" ), 'w' ) as f: f.write( 'text' )
I was asking for whether or not if you can be done, not if it was a good idea. I already know it is a bad idea. The only reason this topic came to surface is due to the fact that Doki Doki Literature Club! did this with its directory and was curious to find out how one would do so (without scanning through the surprisingly complex scripts for the said game) and if Ren'Py is restricted to its own directory and that seems to be the case. The reason for the generation of text files would be due to the fact that the game that I am working on is a semi-point-and-click adventure psychological horror game with a tale of mystery.Remix wrote: ↑Wed Aug 29, 2018 7:57 am Ren'Py games will only have permission to create or edit files within their directory scope, so I'd imagine trying to target desktop or docs would likely fail as above... You'd also need lots of conditionals to spoof paths for all the different platforms and have to navigate around firewall/av programs etc.
I personally would instant uninstall (or tbh, never install to begin with) a game that tried to play outside its scope.
There is a solution for that:Remix wrote: ↑Wed Aug 29, 2018 12:29 pm Ren'Py has full frameworks in place to create, remember, amend, delete as many variable values as you want.
The store module naturally remembers stuff as you go along and integrates into the rollback/forward and save facilities - if a passcode is added to the store then you rollback, the newly acquired passcode can be lost (if chosen)
Ren'Py has systems to remember them per play-through, per entire game or even per game series, so I fail to see what benefits could be achieved by using your own text file instead.
I'm pretty sure you would find more benefits by exploring using variables in Ren'Py than you would gain by effectively creating your own store.
Code: Select all
$ renpy.block_rollback()
Users browsing this forum: Bing [Bot], giorgi1111, Google [Bot]