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.
if 'this file' exists then jump 'this label'
Is this something simple that I just missed, or is it a complicated task? Thanks!
- Hikari Beldrich
- Posts: 14
- Joined: Wed Dec 19, 2012 9:01 pm
- Projects: Mystic Grimoire Series
- Organization: Independent
Use can use try/except/else blocks to when attempting verification against the files. I'm going to assume that the goal here is to identify the "presence" of a file only.
Here's a general block that should be able to handle that:
Code: Select all
python: try: #Try reading the file to see if it exists (file is given as a path relative to the "game" directory): renpy.file("myfile.txt") except: #The read failed, act on it here: do_thing_B() else: #The the file exists, act on it here: do_thing_A()
You should also keep in mind how the game will recover the state of the files if the user does something you might not expect. Think about how the game could be self healing by regenerating the files in certain conditions or offer the player a "I just want to make it work again" nuclear option. The DDLC mod template I mentioned above handles this by checking a flag in an init python statement to offer the user a choice to delete their save files when resetting the game to a "pre-Monikapocolpyse" setting :p
Finished Projects: "The Man and His Shell" http://lemmasoft.renai.us/forums/viewto ... 11&t=19006