-
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 ?
[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
-
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:
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.
-
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 ^^;)
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
-
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.
-
My suggestion is setting a new var to determine the random system.
Example:
[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:
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.
-
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.
-
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.