YesNoOk
avatar

Trying to make looping sounds using fvars, but operations won't work. (Read 1443 times)

Started by XxJRushxX, January 25, 2020, 08:35:55 pm
Share this topic:
Trying to make looping sounds using fvars, but operations won't work.
#1  January 25, 2020, 08:35:55 pm
  • avatar
  • *
  • I like pancakes
  • Lol no
    • USA
Code:
[State 0, DisplayToClipboard]
type = DisplayToClipboard
trigger1 = 1
text = "fvar(10) = %d"
params = fvar(10)


[State 0, PlaySnd]
type = PlaySnd
trigger1 = root,var(3) = 11
value = S1,0
volumescale = 99
channel = 2

[State 0, VarAdd]
type = VarAdd
triggerall = fvar(10) < 30.0
trigger1 = root,var(3) > 10
fv = 10
value = 0.2

[State 0, VarSet]
type = VarSet
trigger1 = root,var(3) <= 10
fv = 10
value = 0

[State 0, PlaySnd]
type = PlaySnd
trigger1 = fvar(10) = 20
value = S1,5
volumescale = 99
channel = 3
loop = 1

Hi again! I was creating a character that uses charged attacks, and I used a helper to show effects and play sounds. When I tried to use an fvar to count up until I could play a looping sound, the sound straight up doesn't play! I've even used other sounds in the snd file but nothing worked.

Ya see, var(3) is the charged amount the play is holding, and it goes up to 100. 10 is the threshold for button taps, etc. So when I used fvar(10) inside the helper to count up until the sound plays the loop, nothing can be heard. "=" does nothing, but ">", ">=", "<=", and "<" all work for some reason, but the sound makes this loud ear grating noise instead (because it's playing over and over each frame). I decided not to use persistent because, well, the state controller would only run once and I want this to run everytime fvar(10) hits 20 so it could play the looping sound. I've even attempted to do this with "loop = 0" and still nothing played!

These are all within a helper. Is this a problem with helpers storing variables? Or is there something I'm just not seeing?

EDIT: I forgot to clarify, but when using var(3), the sound works fine. The problem is that the var(3) is constantly changing, and I needed to use something else. Using the clipboard in debug mode, I can SEE the fvar(10) count up to 20, which is when the sound is SUPPOSED to play! I'm a little ticked off after trying to find out how to fix this, but then I realized that the internet exists!
oh ok
Last Edit: January 25, 2020, 08:41:51 pm by XxJRushxX
Re: Trying to make looping sounds using fvars, but operations won't work.
#2  January 27, 2020, 03:59:35 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
I didn't scrutinize your code too much but I can tell you this from my experience.... MUGEN is hit or miss when it comes to using integer values in float parameters, and vice versa.  It works in some instances, and not in others.

My advice to you is, in float parameters (such as fvars, "vel x", etc), I recommend:

1. ALWAYS include a decimal point in your values.

example (a correction to your last state controller):
trigger1 = fvar(10) = 20.0


2. Whenever using an integer trigger in a float parameter (such as AILevel, Anim, StateNo, etc), multiply that by 1.0 to convert it to a float value.
example (unrelated to your particular issue, just for sake of example):

[State 0, VarAdd]
type = VarSet
trigger1 = 1
fv = AILevel*1.0


The same is true when using float values in an integer parameter... always Floor, Ceil, or whatever.


If something seems to work completely logically, but straight up isn't working, go through your triggers and check that you have your floats and integers dealt with accordingly.
I ran into this issue constantly.

Re: Trying to make looping sounds using fvars, but operations won't work.
#3  January 28, 2020, 08:58:03 pm
  • *****
  • Shame on you!
    • USA
if you're using a helper, it'll have it's own variables. So I don't see the need for a float value when you're not doing anything except counting whole numbers.
Move your scale up x10. So each tic you'll increase 2 instead of .2 .  You'd also change
triggerall = fvar(10) < 30.0
to 300. and anywhere else your fvar(10) is at.

If not, You might want to change
 
[State 0, VarSet]
type = VarSet
trigger1 = root,var(3) <= 10
fv = 10
value = 0   ;<<<<this to 0.01
vVv Ryuko718 Updated 10/31/22 vVv