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.

Music Restore Script

Hey. I need a script that restores the Music of the Map that the Hero is on, through the common event system. See, I'm making a day-and-night system, and I want the music to change at night.

OPTIONAL: I might also need a script which turns off music for some specified maps, so that the music doesn't restart during the night-time when the hero changes maps.

Thanks,
 
You're going to have to provide me with the variables you use for your time system. So you mean that when it hits 24 hours (00:00 or whatever) it runs a common event and then waits until it hits 12 hours (12:00)?

Then all you would have to do is to add this within the def update of your map, somewhere after its loop.

Replace $game_system.time with your time variable or whatever.
Code:
@day= 1 # replace with common event id
@night = 2 # replace with common event id
if $game_system.time == 12.00
  $game_temp.common_event_id = @day
end

if $game_system.time == 00.00
  $game_temp.common_event_id = @night
end

It was hard to understand your post, but I hope this is what you are looking for.

NOTE: I'm not sure how your time is set up, so you will have to change the values for the time if my format is not correct.
 
FireRaven;194419 said:
You're going to have to provide me with the variables you use for your time system. So you mean that when it hits 24 hours (00:00 or whatever) it runs a common event and then waits until it hits 12 hours (12:00)?

Then all you would have to do is to add this within the def update of your map, somewhere after its loop.

Replace $game_system.time with your time variable or whatever.
Code:
@day= 1 # replace with common event id
@night = 2 # replace with common event id
if $game_system.time == 12.00
  $game_temp.common_event_id = @day
end

if $game_system.time == 00.00
  $game_temp.common_event_id = @night
end

It was hard to understand your post, but I hope this is what you are looking for.

NOTE: I'm not sure how your time is set up, so you will have to change the values for the time if my format is not correct.

Here are my events
http://i51.photobucket.com/albums/f359/brunotherhino/CmnEvntTIME.gif[/img]
http://i51.photobucket.com/albums/f359/brunotherhino/CmnEvntTONE.gif[/img]
http://i51.photobucket.com/albums/f359/brunotherhino/CmnEvntNIGHTMUSIC.gif[/img]

At the conditional Branch "NIGHTOFF == ON" is where I need the script to go.

Thanks
 
Okay this will be simple, but you need to do it correctly.
Go first into Game_System and add this def somewhere out of the bounds:
Code:
def memorize_bgm(bgm)
   @memorized_bgm = bgm
end
Simply go into Game_Map script and find the lines:
Code:
if @map.autoplay_bgm
  $game_system.bgm_play(@map.bgm)
end
Replace that with:
Code:
if @map.autoplay_bgm
  if $game_switches[20]
     $game_system.memorize_bgm(@map.bgm)
  else
     $game_system.bgm_play(@map.bgm)
  end
end
Since your common event runs (it's like paralell process right?) all the time, the night music should automatically play while the map bgm is stored.

All you have to do in your common event at the night time switch is to put this call script in(do not use the event restore bgm/bgs, because you just want the bgm):
Code:
$game_system.bgm_restore

That should do it.
Hope it works.
 
FireRaven;194759 said:
Okay this will be simple, but you need to do it correctly.
Go first into Game_System and add this def somewhere out of the bounds:
Code:
def memorize_bgm(bgm)
   @memorized_bgm = bgm
end
Simply go into Game_Map script and find the lines:
Code:
if @map.autoplay_bgm
  $game_system.bgm_play(@map.bgm)
end
Replace that with:
Code:
if @map.autoplay_bgm
  if $game_switches[20]
     $game_system.memorize_bgm(@map.bgm)
  else
     $game_system.bgm_play(@map.bgm)
  end
end
Since your common event runs (it's like paralell process right?) all the time, the night music should automatically play while the map bgm is stored.

All you have to do in your common event at the night time switch is to put this call script in(do not use the event restore bgm/bgs, because you just want the bgm):
Code:
$game_system.bgm_restore

That should do it.
Hope it works.
Cool! Thanks for the help. I'll try that when I next can.
 

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