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.

end battle music script

So, I'm no programmer, but I thought I had a basic idea.
I wanted to change the background music after a battle on the condition that an actor leveled up, so in the Scene_Battle2
script, on line 173/174, it reads:

if actor.level > last_level
@status_window.level_up(i)

so I added on line 175 after moving everything down a line:
Audio.bgm_play(thepower [100, 100])

(thepower being the filename)
I know the syntax doesn't look like what's in the help doc for the RSS, which confused me, mostly because the way I put it was the only way to rid myself of a syntax error, but now the error message reads:

Script 'Scene_Battle 2' line 175: NoMethodError occurre
Undefined method 'thepower' for #<scene_battle:0x142a48>

I'm really flustered because I though I kinda got the dead basics of scripting but this little thing is putting me off. Can anyone help?
Thanks
 
You have to do this:

Code:
Audio.bgm_play('thepower', 100, 100)

You had two problems. The first was that since you didn't put thepower in quotes (to make it a string), it thought you were trying to tell it to use a method or variable as the name of the file. The second problem was the brackets. Those are used in the help file to show parts of a method that are not required, but can be included. When you actually use the code, the brackets shouldn't be there, as that makes the two values into an array, instead of being two seperate values.

Here, I'll explain what that error method was. When you put a value into something like that, without setting it equal to something, it thinks you are trying to either use a variable that hasn't been defined, or are trying to use the return value of an undefined method. THe syntax is different because you have to call the Audio module, and then the method within it, resulting in Audio.bgm_play. That's houw you call pretty much any of the methods mentioned in the help file, is by Class.method

Edit: Oops, I figured out why it gave a syntax error. Fixed.
 
I figured out what the problem is. You need this:

Code:
Audio.bgm_play('Audio/BGM/thepower', 100, 100)

Using the $game_system version (Which I did not give) takes a little more work. Still, that would technically be the best method, as taking a shortcut like this can cause issues if you try to reset the BGM with events, as best I can tell.

Edit: Never mind, apparently this shortcut doesn't matter. I just tried resetting it with events, and it did absolutely nothing.
 

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