RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
VX map playlist

0 Members and 1 Guest are viewing this topic.

****
Rep:
Level 69
With the event conditional branch>scripts could you technically code it where if song "A" is playing then wait(x) seconds before playing song "B" and how many other songs, then put it all in a loop?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member

****
Rep:
Level 69
so how would I put it in the script? like this?
A.bgm.play
and what would I type in to recall that script action?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Play BGM is its own event command. It doesn't require a script and Conditional Branches also are not required (though they are useful since it will be easier to copy, so I will use them - however, you could just as easily only use Wait commands

It would be like this:

@>Loop
   @>Play BGM: BGM1, 100, 100
   @>Control Variable: [XXXX: Song Length] = song length in seconds (so 180 if the song is 3 minutes long)
   @>Loop
       @>Conditional Branch: Variable [XXXX: Song Length] > 0
           @> Wait: 60 frames
           @>Control Variables: [XXXX: Song Length] -= 1
         : Else
             Break Loop
         : Branch END
      : Repeat
   # Do the same for the next song, etc...
 : Repeat



You could make it even cleaner if you put the counting loop in a common event and just called it after each time you set a song.

I attached a demo, and I even made it a little snazzier to fade it out.

There is, however, a problem - it won't keep counting down if you, for instance, click outside of the window to do something else on your computer or if you call a new scene and expect to have the map music play in it. The Audio module is, sadly, pretty restrictive in general, so a scripted solution could probably solve the second issue but not the first (or rather, the amount of work involved in solving the first would give you much more sophisticated way to track the time a song has been playing and the like, so it would make this method obsolete).

Also, changing maps would naturally interfere with that method since it uses a local parallel process event, but you could fix that by putting it in a common event.
« Last Edit: June 28, 2011, 05:45:56 PM by modern algebra »

*
Rep:
Level 82
GIAW 14: 1st Place (Easy Mode)2013 Project of the Year2013 Best RPG Maker User (Programming)2013 Most Promising ProjectParticipant - GIAW 11Bronze - GIAW 10
To help with the problem of people clicking outside of the window, OriginalWij's Audio Position script is very exacting. Although it doesn't work when they take focus away from the window, when they click back it can still check against the current playing time of a song.

Code: [Select]
#==============================================================================
# Audio Position
#==============================================================================
# Author : OriginalWij
# Version : 1.0
#==============================================================================

#==============================================================================
# To use:
#   call: (from a Script Event command)
#     bgm_position - gets playing BGM position in seconds (float) *
#     bgs_position - gets playing BGS position in seconds (float) *
#
#     * = returns 0 if none playing
#     examples: $game_variables[42] = bgm_position
#               RPG::BGS.stop if bgs_position > 42
#==============================================================================

#==============================================================================
# What this does:
#   allows syncing to music by position (accurate to 0.01 seconds)
#==============================================================================

#==============================================================================
# RPG
#==============================================================================

module RPG
  #============================================================================
  # BGM
  #============================================================================
  class BGM < AudioFile
    #------------------------------------------------------------------------
    # Variables                                                         [New]
    #------------------------------------------------------------------------
    @@position = 0
    @@started  = false
    #------------------------------------------------------------------------
    # Play                                                              [Mod]
    #------------------------------------------------------------------------
    alias ow_ap_rpg_bgm_play play unless $@
    def play
      ow_ap_rpg_bgm_play
     
      if @name.empty?
        @@position = 0
      else
        if @@started == false
          @@position = Time.now
          @@started  = true
        end
      end
      #@@position = @name.empty? ? 0 : Time.now
    end
    #------------------------------------------------------------------------
    # Stop                                                          [Rewrite]
    #------------------------------------------------------------------------
    def self.stop
      Audio.bgm_stop
      @@last = BGM.new
      @@position = 0
      @@started  = false
    end
    #------------------------------------------------------------------------
    # Fade                                                          [Rewrite]
    #------------------------------------------------------------------------
    def self.fade(time)
      Audio.bgm_fade(time)
      @@last = BGM.new
      @@position = 0
      @@started  = false
    end
    #------------------------------------------------------------------------
    # Position                                                          [New]
    #------------------------------------------------------------------------
    def position
      return 0 if @@position == 0
      return Time.now - @@position
    end
  end

  #============================================================================
  # BGS
  #============================================================================
  class BGS < AudioFile
    #------------------------------------------------------------------------
    # Variables                                                         [New]
    #------------------------------------------------------------------------
    @@position = 0
    @@started = false
    #------------------------------------------------------------------------
    # Play                                                              [Mod]
    #------------------------------------------------------------------------
    alias ow_ap_rpg_bgs_play play unless $@
    def play
      ow_ap_rpg_bgs_play
      @@position = @name.empty? ? 0 : Time.now
     
      if @name.empty?
        @@position = 0
      else
        if @@started == false
          @@position = Time.now
          @@started  = true
        end
      end
    end

    #------------------------------------------------------------------------
    # Stop                                                          [Rewrite]
    #------------------------------------------------------------------------
    def self.stop
      Audio.bgs_stop
      @@last = BGS.new
      @@position = 0
      @@started  = false
    end
    #------------------------------------------------------------------------
    # Fade                                                          [Rewrite]
    #------------------------------------------------------------------------
    def self.fade(time)
      Audio.bgs_fade(time)
      @@last = BGS.new
      @@position = 0
      @@started  = false
    end
    #------------------------------------------------------------------------
    # Position                                                          [New]
    #------------------------------------------------------------------------
    def position
      return 0 if @@position == 0
      return Time.now - @@position
    end
  end

end

#==============================================================================
# Game_Interpreter
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # Get BGM Position                                                    [New]
  #--------------------------------------------------------------------------
  def bgm_position
    return RPG::BGM.last.position
  end
  #--------------------------------------------------------------------------
  # Get BGS Position                                                    [New]
  #--------------------------------------------------------------------------
  def bgs_position
    return RPG::BGS.last.position
  end

end

« Last Edit: June 28, 2011, 07:25:35 PM by Exhydra »

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5