YesNoOk
avatar

help with ifelse and parenthesis for sounds (+random) (Read 2243 times)

Started by Nedflandeurse, April 17, 2021, 04:45:54 PM
Share this topic:
help with ifelse and parenthesis for sounds (+random)
New #1  April 17, 2021, 04:45:54 PM
  • *****
  • SlowSpriter. Even slower and limited coding skills
  • A.K.A. NED
Hi,

I would like some help for checking how I can make this code working.
I'm not sure what's wrong with the code structure (particularly the use of parenthesis) and I never been a good math guy or somthing.

;what is wrong with the ifelse structure ?

Code:
[State 810, Voice]
type = PlaySnd
trigger1 = AnimElem = 8
value = ifelse(random<500, (800,1), (4,0))
channel = 0

I would like randomly to play sound 800,1 OR sound 4,0

Thanks

Custom POTS-like Kotaro WIP :
https://mugenguild.com/forum/topics/pots-kotaro-custom-ned-trying--192619.0.html And other fighting beauties in mind...
Last Edit: April 19, 2021, 12:13:55 PM by Nedflandeurse
Re: help with ifelse and parenthesis for sounds (+random)
#2  April 17, 2021, 05:01:04 PM
  • **
    • Vietnam
Code:
value = ifelse(random<500, (800,1), (4,0))


That's not the correct way to use Ifelse. I suppose that you want to use sound index 1 from group 800 and sound index 0 from group 4. And, You also want these two sounds to be randomly switched to each others.

The correct code should be:
Code:
value = ifelse(random<500,800,4),ifelse(random<500,1,0)

But if the code is set like this, the index sound would be switched too. With that being said, the system may use sound index 4 from group 1 and index 0 from group 800 as well. I'd recommend setting another condition to trigger the correct sound you wanted.
Re: help with ifelse and parenthesis for sounds (+random)
#3  April 17, 2021, 05:10:47 PM
  • *****
  • SlowSpriter. Even slower and limited coding skills
  • A.K.A. NED
Oh, I see.
Thanks. So, do you think is there a better way to have the same effect?


My last choice would be to clone the existing needed sounds into the SND, so the coding would be easier.
(Something I used to do in the past, but now, I try to avoid that ^^;)

Code:
value = 800, 0+random%2;;;;;;;;;;;; 800,0 ou 800,1

actually. I would like something just like in my exemple, but without having to "clone" a sound to give it the "needed" number 800,1

Custom POTS-like Kotaro WIP :
https://mugenguild.com/forum/topics/pots-kotaro-custom-ned-trying--192619.0.html And other fighting beauties in mind...

DS

Re: help with ifelse and parenthesis for sounds (+random)
#4  April 17, 2021, 05:41:57 PM
  • ****
    • Brazil
    • deathscythemugen.neocities.org/
In either case you'll be "sacrificing" one of the resources. I'd prefer cloning the sound here than using a var. Variables are limited, you never know when you'll run out of it. Sounds are not.
Re: help with ifelse and parenthesis for sounds (+random)
#5  April 17, 2021, 05:42:10 PM
  • **
    • Vietnam


My suggestion is setting a new var to determine the random system.

Example:
Code:
[State 810, Varset]
type = varset
trigger1 = !time
var(28) = ifelse(random<500,1,0)

After setting up the custom var(28), the Playsnd value should look like this:
Code:
value = ifelse(var(28)=1,800,4),ifelse(var(28)=1,1,0)

In this case, the system will play 800,1 if var(28) = 1 and 4,0 if var(28) = 0

The value of var(28) is determined between 0 and 1, as I shown above.
Re: help with ifelse and parenthesis for sounds (+random)
New #6  April 17, 2021, 10:20:39 PM
  • *****
  • SlowSpriter. Even slower and limited coding skills
  • A.K.A. NED
Oh yes, this is the system I used before.
when I tried some stuffs around 2007 (with custom gameplay)

I'll have to check the availiable vars in Jm's characters, since I use his beinmaru to code POTS a character.


EDIT : I finally kept this method:

value = 800, 0+random%2;;;;;;;;;;;; 800,0 ou 800,1

So, I cloned some sounds. It's not a big memory use to have few sounds twice in the sound file anyway.
and it will make coding WAY easier for me.

Custom POTS-like Kotaro WIP :
https://mugenguild.com/forum/topics/pots-kotaro-custom-ned-trying--192619.0.html And other fighting beauties in mind...
Last Edit: April 19, 2021, 12:13:44 PM by Nedflandeurse
Re: help with ifelse and parenthesis for sounds (+random)
#7  April 18, 2021, 09:19:45 AM
  • ***
    • beterwork.hopto.org
Oh yes, this is the system I used before.
when I tried some stuffs around 2007 (with custom gameplay)

I'll have to check the availiable vars in Jm's characters, since I use his beinmaru to code POTS a character.


i never thought this before since I always sort same type of sound in one group.
Check my Odysee Channel videos for latest stuff from me.
https://odysee.com/@BeterWork:e
My Home Page
https://beterwork.hopto.org