ainslec / adventuron-issue-tracker

Adventuron Issues Tracker
4 stars 0 forks source link

MUSIC issues #502

Open ainslec opened 2 years ago

ainslec commented 2 years ago

(via Jelly)

"In my current game (which is in adventuron.io/betabeta not in adventuron.io/classroom - not sure if that makes a difference) I was finding that if the player turns SOUND OFF, but then turns SOUND ON and MUSIC ON, it doesn't actually turn the music setting back on, it's just permanently off. So I fixed that by creating a subroutine that "asks for permission" again, which does work.

However, I then found that if you turn SOUND OFF and then turn it (and music) back on with permissions, the setting is updated, but the music WILL NOT PLAY. UNLESS you stop_music when turning sound off or music off. For this reason, you also should use an : if (sysvar_bool "sysvar_sound_enabled" && sysvar_bool "sysvar_music_enabled") {//play_music goes here} in your on_tick, to prevent it from starting up again until sound and music are turned back on."

#########################
# On Tick
#########################

on_tick {

   : if (sysvar_bool "sysvar_sound_enabled" && sysvar_bool "sysvar_music_enabled") {
      : play_music "music_field" ;
   }

}

#########################
# Subroutines
#########################

subroutines {

   sound_toggle : subroutine {
      : ask_permission ask_again_and_again = "true" category = "sound" ;
         : if (!sysvar_bool "sysvar_sound_enabled") {
            : stop_music ;
            : print "<Sound>[sound] is turned <^b^OFF>." ;
            : done ;
         }
      : ask_permission ask_again_and_again = "true" category = "music" ;
      : if (!sysvar_bool "sysvar_music_enabled") {
         : stop_music ;
         : print "<Sound>[sound] is turned <^b^ON>. <Music>[music] is turned <^b^OFF>." ;
         : done ;
      }
      : print "<Music>[music] is turned <^b^ON>." ;
      : play_music "music_field" ;
      : done ;
   }
   music_toggle : subroutine {
      : if (!sysvar_bool "sysvar_sound_enabled") {
         : ask_permission ask_again_and_again = "true" category = "sound" ;
         : if (!sysvar_bool "sysvar_sound_enabled") {
            : print "<Sound>[sound] is turned <^b^OFF>." ;
            : done ;
         }
      }
      : ask_permission ask_again_and_again = "true" category = "music" ;
      : if (!sysvar_bool "sysvar_music_enabled") {
         : print "<Sound>[sound] is turned <^b^ON>. <Music>[music] is turned <^b^OFF>." ;
         : done ;
      }
      : print "<Music>[music] is turned <^b^ON>." ;
      : play_music "music_field" ;
      : done ;
   }

}

#########################
# On Command 
#########################

on_command {

   : match "sound _;toggle sound;turn sound" {
      : gosub "sound_toggle" ;
   }
   : match "music _;toggle music;turn music" {
      : gosub "music_toggle" ;
   }

}

#########################
# Assets
#########################

assets {
   sounds {

      music_field : sound_sample "https://puzzle.grizel.in/sindrella/music/svl_field_theme.mp3" ;

   }
}