Problem with renpy.reload_script

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
sine12
Newbie
Posts: 7
Joined: Sun Apr 08, 2018 2:03 pm
Contact:

Problem with renpy.reload_script

#1 Post by sine12 »

Hello, I am new to here (sorry for the bad english, this is not my first language)
Currently, I am working on a game which kinda like DDLC.
The player have to delete a file and the game should be able to know and show some dialogue like "oh you deleted me".
I use the renpy.loadable("file") to make these work, but its not working well as i have to reload the script in order to let the game knows the file is missing.

So, I use renpy.reload_script() function before the if loadable statement to force the game to reload.

However, this function makes the game gets stuck. It just keeps reloading the script and saving the game(the screen keep refreshing, I m not sure).
I am wondering if I use reload_script wrong or is there a better way to do this?
sorry for my bad English again...

User avatar
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: Problem with renpy.reload_script

#2 Post by PyTom »

I'd suggest not doing this. If you're going to look for the existence or absence of a file, a reasonable way to do it is:

Code: Select all

init python:
    import os


while os.path.exists(os.path.join(config.basedir, "game/fakeout.txt")):
     "You didn't delete me!"

The renpy.reload_script function is developer functionality, and I'm not going to support is as part of an actual game mechanic. (And deleting .rpy files is similarly forbidden - Ren'Py caches and uses them, and I don't want to support games that remove content from a released game at runtime.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

sine12
Newbie
Posts: 7
Joined: Sun Apr 08, 2018 2:03 pm
Contact:

Re: Problem with renpy.reload_script

#3 Post by sine12 »

PyTom wrote: Sun Apr 08, 2018 2:28 pm I'd suggest not doing this. If you're going to look for the existence or absence of a file, a reasonable way to do it is:

Code: Select all

init python:
    import os


while os.path.exists(os.path.join(config.basedir, "game/fakeout.txt")):
     "You didn't delete me!"

The renpy.reload_script function is developer functionality, and I'm not going to support is as part of an actual game mechanic. (And deleting .rpy files is similarly forbidden - Ren'Py caches and uses them, and I don't want to support games that remove content from a released game at runtime.)
Thanks! This is much better!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]