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.

[Resolved] Comparing BGM

Status
Not open for further replies.
Okay, so ... I'm working on an addition to the combat system so that it will only play the BattleEnd ME if the combat music is not the same as the map music. However, I'm having a bit of trouble working out the code for "if battle_bgm is not the same as the map BGM." I've tried this:

PHP:
if $game_system.battle_bgm != $game_temp.map_bgm
  $game_system.me_play($game_system.battle_end_me)
end

And I've tried this:


PHP:
if $game_system.battle_bgm == $game_temp.map_bgm
else
  $game_system.me_play($game_system.battle_end_me)
end

It doesn't seem to work, though, in that it always plays the battle end ME. So, uh ... what am I doing wrong?
 
Hmm, yeah ... I was having a sinking feeling like "oh great, it's not gonna be some sort of crazy business like that 'string.equals(otherstring)' or whatever it is in Java, is it?" business ...

EDIT: Just to exacerbate that, I thought I'd hit upon a solution through lateral thinking: add a new variable to game_temp called same_bgm. Then, right before $game_system.playing_bgm gets saved to $game_temp.map_bgm, you insert this:

PHP:
if $game_system.playing_bgm == $game_system.battle_bgm
  $game_temp.same_bgm = false
else
  $game_temp.same_bgm = true
end

And then, you only play the battle_end_me if $game_temp.same_bgm == true. However, it seems it always returns true. I have a feeling figuring this out is going to be a bit more complicated ...
 
Aha, I've found out what it is! You need to compare <audiofile>.name (and <audiofile>.pitch for good measure) ... So:

PHP:
if ($game_system.playing_bgm.name == $game_system.battle_bgm.name) && ($game_system.playing_bgm.pitch == $game_system.battle_bgm.pitch)
    ....
 
Status
Not open for further replies.

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