Page 1 of 1
Sound Issues
Posted: Sun Oct 01, 2017 11:18 pm
by TheKidCodee
So I write this in a lunalua script.
And it works perfectly fine. But when I write these in the same lunalua script
only script 4 plays a sound. Does anyone know why this is the case and how I can fix this?
Re: Sound Issues
Posted: Sun Oct 01, 2017 11:32 pm
by Zha Hong Lang
You're redefining the function for each if statement. It's the same as if you made a robot to do your daily chores and gave it instructions, but then you replaced it three times, giving it new instructions each time.
You can fix this problem by creating a single onInputUpdate() function and making an if/elseif/else chain inside it for each value of drownCounter.
Re: Sound Issues
Posted: Mon Oct 02, 2017 11:30 am
by TheKidCodee
Zha Hong Lang wrote:You're redefining the function for each if statement. It's the same as if you made a robot to do your daily chores and gave it instructions, but then you replaced it three times, giving it new instructions each time.
You can fix this problem by creating a single onInputUpdate() function and making an if/elseif/else chain inside it for each value of drownCounter.
What do you mean by "chain"?
also sorry if i sound a little dum im new to lua
Keep in mind that 1 script plays a different sound.
Re: Sound Issues
Posted: Mon Oct 02, 2017 11:35 am
by The0x539
TheKidCodee wrote:
What do you mean by "chain"?
Code: Select all
function onWhateverCallback()
if conditionA or conditionB or conditionC then
actionA()
elseif conditionD and conditionE then
actionB()
elseif conditionF then
actionC()
else
actionD()
end
end
Re: Sound Issues
Posted: Mon Oct 02, 2017 3:30 pm
by Zha Hong Lang
TheKidCodee wrote:What do you mean by "chain"?
also sorry if i sound a little dum im new to lua
Keep in mind that 1 script plays a different sound.
0x showed you what a chain of if/elseif/else statements looks like. It allows you to do different things depending on different conditions. So, you can set it up so that for each condition it'll play a different sound.
Re: Sound Issues
Posted: Sat Oct 07, 2017 1:49 pm
by TheKidCodee
The0x539 wrote:TheKidCodee wrote:
What do you mean by "chain"?
Code: Select all
function onWhateverCallback()
if conditionA or conditionB or conditionC then
actionA()
elseif conditionD and conditionE then
actionB()
elseif conditionF then
actionC()
else
actionD()
end
end
What do you mean by Condition?
?
Re: Sound Issues
Posted: Sat Oct 07, 2017 2:26 pm
by The0x539
TheKidCodee wrote:
What do you mean by Condition?
?
Your question would make sense if it were
Re: Sound Issues
Posted: Sat Oct 07, 2017 2:39 pm
by TheKidCodee
The0x539 wrote:TheKidCodee wrote:
What do you mean by Condition?
?
Your question would make sense if it were
Does It mean drownCounter == (number)?
Re: Sound Issues
Posted: Sat Oct 07, 2017 2:41 pm
by The0x539
TheKidCodee wrote:The0x539 wrote:TheKidCodee wrote:
What do you mean by Condition?
?
Your question would make sense if it were
Does It mean drownCounter == (number)?
A condition is any expression meant to evaluate sometimes to true and sometimes to false.