- Jul 24, 2020
- 152
- 651
I am trying to make a short "animation" that is really just a loop of two pictures. Each time one of the pictures displays I'd like a random sound effect to play from a list. Here is the code i have so far (Thank you to a different thread for the python function):
The problem is that Renpy selects a random file on the first iteration but then continues to play the same file it selected for every iteration after that. I've already done some digging and found that this is how Renpy treats "random" choices due to its rollback feature. Is there anything I can do to fix this? I would say it's not a huge issue because there are only four audio files but I will need to do the same thing again for a different scene where I have 12 different audio files. Any help would be appreciated!
Python:
default bjeff = ["bjeff1.wav", "bjeff2.wav", "bjeff3.wav", "bjeff4.wav"]
init python:
class atl_play_sound(object):
def __init__(self,sound):
super(atl_play_sound,self).__init__()
self.sound=sound
def __call__(self,*args,**kwargs):
if not renpy.predicting():
renpy.sound.play(self.sound, relative_volume = 1.0)
image l first bj anim dom:
"bg l_first_bj_finish.png" with Dissolve(0.15)
function atl_play_sound(renpy.random.choice(bjeff)) #File selected here will be random the first iteration only
pause 1.2
"bg l_first_bj_deep.png" with Dissolve(0.15)
function atl_play_sound(renpy.random.choice(bjeff)) #File selected here will be random the first iteration only
pause 1.2
repeat