Sound Issues

This is the place for discussion and support for LunaLua and related modifications and libraries.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
TheKidCodee
Snifit
Snifit
Posts: 234
Joined: Sun Jul 16, 2017 6:47 pm
Flair: ill teach your grandmother to suck eggs
Contact:

Sound Issues

Postby TheKidCodee » Sun Oct 01, 2017 11:18 pm

So I write this in a lunalua script.

Image

And it works perfectly fine. But when I write these in the same lunalua script

Image

only script 4 plays a sound. Does anyone know why this is the case and how I can fix this?

Zha Hong Lang
Buster Beetle
Buster Beetle
Posts: 445
Joined: Thu Jun 22, 2017 10:14 am

Re: Sound Issues

Postby Zha Hong Lang » Sun Oct 01, 2017 11:32 pm

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.

TheKidCodee
Snifit
Snifit
Posts: 234
Joined: Sun Jul 16, 2017 6:47 pm
Flair: ill teach your grandmother to suck eggs
Contact:

Re: Sound Issues

Postby TheKidCodee » Mon Oct 02, 2017 11:30 am

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.

The0x539
Eerie
Eerie
Posts: 751
Joined: Fri Jan 22, 2016 8:02 pm

Re: Sound Issues

Postby The0x539 » Mon Oct 02, 2017 11:35 am

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
Last edited by The0x539 on Mon Oct 02, 2017 5:09 pm, edited 1 time in total.

Zha Hong Lang
Buster Beetle
Buster Beetle
Posts: 445
Joined: Thu Jun 22, 2017 10:14 am

Re: Sound Issues

Postby Zha Hong Lang » Mon Oct 02, 2017 3:30 pm

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.

TheKidCodee
Snifit
Snifit
Posts: 234
Joined: Sun Jul 16, 2017 6:47 pm
Flair: ill teach your grandmother to suck eggs
Contact:

Re: Sound Issues

Postby TheKidCodee » Sat Oct 07, 2017 1:49 pm

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?

Code: Select all

drownCounter ==
?

The0x539
Eerie
Eerie
Posts: 751
Joined: Fri Jan 22, 2016 8:02 pm

Re: Sound Issues

Postby The0x539 » Sat Oct 07, 2017 2:26 pm

TheKidCodee wrote: What do you mean by Condition?

Code: Select all

drownCounter ==
?
Your question would make sense if it were

TheKidCodee
Snifit
Snifit
Posts: 234
Joined: Sun Jul 16, 2017 6:47 pm
Flair: ill teach your grandmother to suck eggs
Contact:

Re: Sound Issues

Postby TheKidCodee » Sat Oct 07, 2017 2:39 pm

The0x539 wrote:
TheKidCodee wrote: What do you mean by Condition?

Code: Select all

drownCounter ==
?
Your question would make sense if it were
Does It mean drownCounter == (number)?

The0x539
Eerie
Eerie
Posts: 751
Joined: Fri Jan 22, 2016 8:02 pm

Re: Sound Issues

Postby The0x539 » Sat Oct 07, 2017 2:41 pm

TheKidCodee wrote:
The0x539 wrote:
TheKidCodee wrote: What do you mean by Condition?

Code: Select all

drownCounter ==
?
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.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest