Hello!
I'm facing an issue with running a function in the background. Basically, I want a Python idle function to perform calculations and update a progress bar in the background.
I utilized the "renpy.restart_interaction()" command to update the progress bar. Without it, I wouldn't get a visual update for the progress bar. Everything seems to be going well, but after some time, I encounter this error:
Here is a code which I use:
I'm facing an issue with running a function in the background. Basically, I want a Python idle function to perform calculations and update a progress bar in the background.
I utilized the "renpy.restart_interaction()" command to update the progress bar. Without it, I wouldn't get a visual update for the progress bar. Everything seems to be going well, but after some time, I encounter this error:
Code:
While running game code:
File "game/scripts/test.rpy", line 24, in script
call screen progress_bar
File "renpy/common/000statements.rpy", line 670, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
Exception: renpy.restart_interaction() was called 100 times without processing any input.
Here is a code which I use:
Code:
init python:
from time import time
class IdleRun:
def __init__(self):
self.start = time()
self.progress_bar_value = 0
def update_progress_bar(self):
if time() - self.start >= 0.1:
self.progress_bar_value += 1
renpy.restart_interaction()
# self.start = time()
# a method to run some calculations in the background
def background_update(t, st, at):
idlerun.update_progress_bar()
return 0
label progress_bar_test:
$ idlerun = IdleRun()
$ update_placeholder = Transform(function = background_update)
call screen progress_bar
return
screen progress_bar:
add update_placeholder
bar:
value idlerun.progress_bar_value
range 100
xysize(200,25)
xalign 1.0
yalign 0.5