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.
I essentially want a timer so that when a certain value is reached, the next show function is called. Renpy.pause() does what I want except that it delays the script.
class movSprite():
# Note that the alpha mask file must have the same name as the animation but with an extra ' mask' at the end.
# Example for the two files: 'directory/saki serious smile' and 'directory/saki serious smile mask'
# endStill should also be named same as the animation file, but with an added ' still' at the end.
def __init__(self, animation, duration):
self._movEnd = False
self._creationTime = time.time()
self._duration = duration
# Names of the displayables
self._movName = animation
self._endStillName = animation+'still'
# Create the still image displayable, movie should already be pre-defined in the 'init'
self._endStill = renpy.image(self._endStillName, animation+" still.png")
def showSprite(self):
#Add a check to see if previous sprite name is the same is new one to prevent same animation from replaying awkwardly
renpy.show(self._movName)
renpy.pause(self._duration)
renpy.show(self._endStillName)
def changeSprite(self, newName, duration):
#Add a check to see if previous sprite name is the same is new one to prevent same animation from replaying awkwardly (set self._movEnd)
self._movName = newName
self._duration = duration
You would likely do best (and probably find it easiest) to use DynamicDisplayable and utilize the inbuilt st/at parameters that are passed to the function returning the displayable... Basically taking all the *args and **kwargs of movSprite and just using them in one function that includes the time value
init python:
def mov_sprite(st, at, *args, **kwargs):
# return a displayable, recall pair
disp = self.mov_name if st <= self.duration else self.end_still
rpt = self.mov_duration if st <= self.duration else 0
return disp, rpt
image mov_still = DynamicDisplayable(
mov_sprite,
_predict_function = None, # this should be added
duration = 3.0,
animation = "some ref")
Without knowing what the animation, mask and end_still are doing, it's hard to help further
Sub-note: As regards the original question; I think renpy.ui.pausebehavior (a wrapper for the class renpy.display.behavior.PauseBehavior) and renpy.ui.timer(.1, repeat=True, action=some_function_call) are about the only facilities Ren'py has that might come close. PauseBehavior only returns a value after a set time though rather than calling a function/method so would need some extra work to implement (if possible). The ui.timer option might have knock on effects with interactions and screen/displayable/atl code if not handled well.