Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

help my to play SEs please

I'm trying to modify mr mo's sbabs to play a sound effect whenever you attack get hit or die and the sound effect varies on what gender and race you are. I got the syntax correct (i think) but it won't play the sound effect. it doesn't get any errors though.

this is what I wrote:

Code:
      if $gender == 1 then
        if $race == 1 then
          Audio.se_play("HMatk1", 100, 100)
        else
        end
      elsif $gender == 2
        if $race == 1 then
          Audio.se_play("HFatk1", 100, 100)
        else
        end
      end

I tried without the quotes too and with .wav in the name. I think this issue is more of the variables.
becuase I don't know how to check the variables you use with events. but I thought it would be with the variable name with $ in front of it. is the correct? or did I do something wrong? any help is appreciated thanks.
 

khmp

Sponsor

You need to use a RPG::AudioFile object to play an sound.
Code:
sound = RPG::AudioFile.new(filename, volume, pitch)
Audio.se_play(sound)
Or you can shorten it to one line.
Code:
Audio.se_play(RPG::AudioFile.new(filename, volume, pitch))
Also I notice you are using then and else when they aren't needed. The 'then' keyword is only needed if you want the if statement on one line.
Code:
if true then p 'true' end
As for the else's they are only needed if there is an else. You can leave them out if there is nothing that happens if the conditional statement is false.

Good luck with it nazra7! :thumb:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top