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.
[VXA] Map Transfer Common Events

0 Members and 1 Guest are viewing this topic.

*
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
Map Transfer Common Events
Version: 1.0.0
Author: modern algebra
Date: 9 October 2012

Version History


  • <Version 1.0> 2012.10.09 - Original Release

Description


This script lets you instantly run a specified common event when exiting or entering a map. This is useful, for instance, for when you want to instantly change the tone when transferring to a different map, or really for any other change that you want to take place instantly. The event will only be run once.

Features

  • Instantly run common events to account for system differences in map, like screen tone.
  • Can set both an Enter common event and an Exit common event.
  • Easy configuration through the map's note box.

Instructions

Paste the script into its own slot in the Script Editor, above Main but below Materials.

For configuration instructions, see the header of the script. Please note, however, that this ignores any switch condition on the common event, so it should not be used to call parallel process or autorun common events directly. Also, the player will not be able to move while the event is running, so you should not put many wait frames in the event. If you need wait frames, then the recommended option would be to make a parallel process event or common event, and if necessary you can turn on the switch with a common event called by this script.

Script


Code: [Select]
#==============================================================================
#    Map Transfer Common Event
#    Version: 1.0.0
#    Author: modern algebra (rmrk.net)
#    Date: 9 October 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#   
#    This script lets you instantly run a specified common event when exiting
#   or entering a map. This is useful, for instance, for when you want to
#   instantly change the tone when transferring to a different map, or really
#   for any other change that you want to take place instantly. The event will
#   only be run once.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#   
#    Paste this script into its own slot in the Script Editor, above Main but
#   below Materials.
#
#    All you need to do to set this script up is place one or both of the
#   following codes into the note box of a map:
#
#      \EXIT_CE[0]
#      \ENTER_CE[0]
#
#    Obviously, the EXIT_CE will run when leaving the map, while the ENTER_CE
#   will run when entering the map. Replace the 0 with the ID of the common
#   event which you want to run in that circumstance.
#
#    Please note that this ignores any switch condition on the common event, so
#   it should not be used to call parallel process or autorun common events
#   directly. Also, the player will not be able to move while the event is
#   running, so you should not put many wait frames in the event. If you need
#   wait frames, then the recommended option would be to make a parallel
#   process event or common event, and if necessary you can turn on the switch
#   with a common event called by this script.
#==============================================================================

$imported = {} unless $imported
$imported[:MA_MapTransferCommonEvent] = true

#==============================================================================
# ** Game_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - setup
#==============================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Setup
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mamtce_setup_9qg8 setup
  def setup(map_id, *args)
    if @map_id != map_id
      old_ce_id = $game_temp.common_event_id
      mamtce_run_instant_common_event(mamtce_out_common_event_id)
      mamtce_setup_9qg8(map_id, *args) # Call original method
      mamtce_run_instant_common_event(mamtce_in_common_event_id)
      $game_temp.reserve_common_event(old_ce_id) if old_ce_id > 0
    else
      mamtce_setup_9qg8(map_id, *args) # Call original method
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Transfer Common Event IDs
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def mamtce_in_common_event_id
    @map ? @map.note[/(?<=\\ENTER[_ ]CE\[)\s*\d+\s*(?=\])/i].to_i : 0
  end
  def mamtce_out_common_event_id
    @map ? @map.note[/(?<=\\EXIT[_ ]CE\[)\s*\d+\s*(?=\])/i].to_i : 0
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Instant Run Common Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def mamtce_run_instant_common_event(ce_id)
    return unless ce_id > 0
    $game_temp.reserve_common_event(ce_id)
    @interpreter.setup_reserved_common_event
    @interpreter.update
  end
end

Credit


  • modern algebra

Support


Please post in this topic at RMRK.net if you have any questions, suggestions, error reports, or comments about this script. Please do not message me privately, as it is more efficient and useful to answer any concerns you have in the topic where others may benefit from our correspondence.

Known Compatibility Issues

I do not know of any compatibility problems as of yet.

Terms of Use


I adopt RMRK's default Terms of Use.
« Last Edit: January 31, 2013, 09:47:26 PM by modern algebra »

**
Rep:
Level 83
Very useful script, I often make a script call on my game to change screen tone at the next map, I tried to call a common event too but I fail, the common event always started when the tranfer was completely done

*
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
Hooray! In the past I have tried to finagle something like this, as some of my maps shifted radically in terms of screen tone and appearance. Excellent script.

UPDATED 05-29-14


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

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

*
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
I am glad you both like it! I don't know why I didn't write it earlier; I remember having that problem back when I was making games, always having to have a parallel process event in each map to initialize anything for the map and then delete itself. It wasn't a particularly daunting task, but it was easy to forget to do it, and for some repetetive things like changing the tone when exiting and entering indoor areas, it can be helpful to just have a single common event to call.