Here is some script I’m trying to use to get an audio.play to onComplete randomly to 1 of 3 sounds. For the purposes of testing the number is always 1.
act_bloop1 does not initiate…
I’ve used similar code to execute other functions successfully, but timerStash.timer_gl in this case is not even running act_bloop1 as you would expect (as GenLoop[1] does equal act_bloop1).
local act_bloop1
local act_bloop2
local act_bloop3
local genBloop
local rn = 0
local GenLoop = {}
GenLoop[1] = act_bloop1; GenLoop[2] = act_bloop2; GenLoop[3] = act_bloop3
act_bloop2 = function ()
audio.play(vars.bubloop2, { channel = 3, onComplete = genBloop })
end
act_bloop3 = function ()
audio.play(vars.bubloop3, { channel = 3, onComplete = genBloop })
end
genBloop = function ()
rn = 1 – just using number 1 for testing will use a random generator here
timerStash.timer_gl = timer.performWithDelay( 0, GenLoop[rn], 1 ) – GenLoop will equal 1
end
This just means that when “someOtherSounds” is finished playing (that being an actual sound file), then the function “playBloop()” is called. In the sample that Rob gives, this picks a random number from 1 to #bloop (the number of entries/indexes in the table “bloop”), then it plays the sound associated with that index number.
This just means that when “someOtherSounds” is finished playing (that being an actual sound file), then the function “playBloop()” is called. In the sample that Rob gives, this picks a random number from 1 to #bloop (the number of entries/indexes in the table “bloop”), then it plays the sound associated with that index number.