How do I make a script always running in the background?

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
Psywriter
Newbie
Posts: 2
Joined: Tue Mar 19, 2019 10:30 pm
Contact:

How do I make a script always running in the background?

#1 Post by Psywriter »

-- First thing I'd like to say, is that if this is the wrong subforum to post this on, I'm sorry. But I'm new to this forum site and none of the topics seemed to fit exactly what I'm asking, either way this was the closest I found to a "help me answer my questions" forum I could think of. If that's wrong, I apologize.



Okay, I'm not actually doing anything meaningful. I'm just messing with DDLC's renpy code and noticed something.

There's nothing that is actually always running, the closest I ever found to code that always runs is the line of code pretaining to deleting Monika in Act III, and all that does is check for her dialogue and jumps to a label if the .chr file isn't there.


Is there any way I can make a script always run in the background? And not just something that waits for another thing?

For example, the code that deals with deleting Monika still waits for Monika's dialogue, like so:

init python:
import random
import subprocess
import os

dismiss_keys = config.keymap['dismiss']

def slow_nodismiss(event, interact=True, **kwargs):
if not persistent.monika_kill:
try:
renpy.file("../characters/monika.chr")
except:
persistent.tried_skip = True
config.allow_skipping = False
_window_hide(None)
pause(2.0)
renpy.jump("ch30_end")
if config.skipping:
persistent.tried_skip = True
config.skipping = False
config.allow_skipping = False
renpy.jump("ch30_noskip")
return


It waits for Monika to talk with this:

$ m.display_args["callback"] = slow_nodismiss



But I don't want something like that, which waits for dialogue, or waits for a variable to change.

What I want is for something to detect a variable, then once it detects it to be always running.

So, imagine that instead of waiting for monika to say something, detecting monika's chr file not being there and then jumping to the label, rather I want a script that's constantly running in the background, always checking if monika's chr file is there and jumping to the label if it's not. This script would always be running, even if I was in a different chapter of the game alltogether.

Also, there's no particular reason as to why I want this. It's not necessary, in fact nothing of what I'm doing is really necessary but I just couldn't figure out how to do it on my own so I figured asking this forum. That's why I created an account just to ask.




I also apologize if I don't know how to use the site properly.

Thank you, Psywriter.

strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Re: How do I make a script always running in the background?

#2 Post by strayerror »

This exists: https://www.renpy.org/doc/html/config.h ... c_callback

There are other (more pythonic) ways to do what you seek, but this is the most obvious "Ren'Py" way to do it, afaik.

Psywriter
Newbie
Posts: 2
Joined: Tue Mar 19, 2019 10:30 pm
Contact:

Re: How do I make a script always running in the background?

#3 Post by Psywriter »

I would prefer the pythonic methods if you could direct me to them. Thanks.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]