Help with file system?
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.
Help with file system?
Hello!
I need some help with simple problem - I need to create simple file, not regular save file, and create in specified locaion on HDD, for example in "my documents", (it will be some kind of saves for next episodes of game). Well... How to do it? =)
I need some help with simple problem - I need to create simple file, not regular save file, and create in specified locaion on HDD, for example in "my documents", (it will be some kind of saves for next episodes of game). Well... How to do it? =)
- RicharDann
- Veteran
- Posts: 286
- Joined: Thu Aug 31, 2017 11:47 am
- Contact:
Re: Help with file system?
If I understand the documentation correctly, Ren'Py can do this for you. You might want to see here:
https://www.renpy.org/doc/html/persiste ... ersistence
https://www.renpy.org/doc/html/persiste ... ersistence
The most important step is always the next one.
Re: Help with file system?
Thanks! On my way to learn it. (Before I read easy "patch" feature but is seems good only for 1 patch, I just want to make episodes of game and all I need is the external save fail where I simply put some vars)
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Help with file system?
You should only need to use multi persistent data for that.
https://www.renpy.org/doc/html/persistent.html
https://www.renpy.org/doc/html/persistent.html
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
Re: Help with file system?
But how about new versions of game? If 1st version of game has 1st episode and has multipersistent object and second version of whole game has both 1st and 2nd episodes and one multipersistent object that is "clean" - like no game was played - so does it rewrite all game directories (and "saves" with persistent file)? Yes it does, in my opinion, in this way, when new episodes of game appear together as one entire game.
Is it impossible in ren'py to work with file in any external directory?
(reading python doks - there some hards with relative paths and also must be imported library sys, os - even can't think how to do it in ren'py...)
Is it impossible in ren'py to work with file in any external directory?
(reading python doks - there some hards with relative paths and also must be imported library sys, os - even can't think how to do it in ren'py...)
- RicharDann
- Veteran
- Posts: 286
- Joined: Thu Aug 31, 2017 11:47 am
- Contact:
Re: Help with file system?
It is possible using plain python code, you just need to put it in an init python block. A very quick example:
Code: Select all
default n = None #Just a placeholder variable
init python:
import sys
def create_external_file(name,ext):
filename = "C:\\"+ name + "." + ext #We put the path Here.
fl = open(filename,'w') #Open the file in write mode
fl.write("Hello world!") #Write something in it, I assume it will be a text file.
fl.close() #Close the file
def read_external_file(fl):
filename = "C:\\"+ fl #Specify the path where the file should be read from.
fl = open(filename, 'r') #Open the file in read mode
return fl.read() #For this quick example, simply return the contents of the file
label start:
"Let's create a new file."
$ create_external_file("test","txt") #We call the create function here.
"Let's read the file."
$ n = read_external_file("test.txt") #We read the file here and store it's content in a variable.
"[n]" #Hello World!
Persistent functionality was suggested because it's ready to use, and can save you a lot of time and effort needed for creating this kind of system. But yes if you're going to include both episodes in a new version I guess you may need to overwrite persistent in case the player hasn't played standalone episode 1 first.
The most important step is always the next one.
Re: Help with file system?
Thank you, RicharDann! Can you explain me one moment about multipersistent - where they are saved and what happens to them if, for example, first version of game has 1st story episode and multipersistent saved by finishing by player and second version of game has 1st and 2nd episodes - and pure persisnet as no one played - will it overwrite played persitent on install? If installation means copying files and overwriting new ones if such exist.
- RicharDann
- Veteran
- Posts: 286
- Joined: Thu Aug 31, 2017 11:47 am
- Contact:
Re: Help with file system?
Multipersistent is created when the players saves the game, in the same folder where the normal savefiles are created. It is saved in a file called 'persistent', without an extension. Each Ren'Py project creates it's own save files and it's own persistent file.tohtamish wrote: ↑Sat Nov 25, 2017 2:06 pm Thank you, RicharDann! Can you explain me one moment about multipersistent - where they are saved and what happens to them if, for example, first version of game has 1st story episode and multipersistent saved by finishing by player and second version of game has 1st and 2nd episodes - and pure persisnet as no one played - will it overwrite played persitent on install? If installation means copying files and overwriting new ones if such exist.
I'd need to triple check to be absolutely sure, but from what I experienced when I was testing this some time ago, if you play Episode 1 version 1, save persistent, and then in version 2 you play episode 2 directly, it will load the persistent file in Episode 1's save folder. But if you start episode 1 in version 2, it will overwrite the data from episode 1, wich might lead to problems when you continue episode 2. So I'm not sure yet if you can use it for this particular case, I'll try it again as soon as I have the time, but if you want you can create a couple of test projects and experiment yourself with it.
The most important step is always the next one.
Re: Help with file system?
thanks, man, I've found them in username/appdata/roaming folders. That's all what I needed to know. But let's change our talk to near subject:
viewtopic.php?f=51&t=45448&sid=8fd68660 ... efd3a8e099
But it's only for one patch... If I plan few chapters - can I do it just adding patch1(chapter2) rpy- files? So I need to create firstly eampty folders, set chapter# persistent vars to False in main scrypt and then when new chapters is ready - bring them as patch1-2-3-etc RPY files with audio-images folders? If I plan many patches - am I supposing correct? Firstly set all chapter persistent vars to false in main scprit and just bring new content in RPY files?
viewtopic.php?f=51&t=45448&sid=8fd68660 ... efd3a8e099
But it's only for one patch... If I plan few chapters - can I do it just adding patch1(chapter2) rpy- files? So I need to create firstly eampty folders, set chapter# persistent vars to False in main scrypt and then when new chapters is ready - bring them as patch1-2-3-etc RPY files with audio-images folders? If I plan many patches - am I supposing correct? Firstly set all chapter persistent vars to false in main scprit and just bring new content in RPY files?
Who is online
Users browsing this forum: bonnie_641