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.
Call Common Event by Variable

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 Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Call Common Event by Variable
Version: 1.0
Author: modern algebra
Date: September 8, 2008

Version History


  • <Version 1.0> 09/08/08 - Original Release

Description


This script allows you to call a common event by setting a variable to its ID.

Features

  • Uses an in-game variable of your choosing to control common event calls
  • Can call common events by setting your control variable to the ID of a common event. Very useful for a number of Event systems.

Screenshots

N/A for this kind of scriptlet

Instructions

See inside Script Header.

Script


Code: [Select]
#==============================================================================
#  Call Common Event by Variable
#  Version 1.0
#  Author: modern algebra
#  Date: September 8, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Instructions:
#    First, go down to line 36 and set the constant, COMMON_EVENT_VARIABLE_ID.
#   Basically, just set it to the ID of the variable that you want to control
#   what common event is called. So, if you set it to 20, as it is right now,
#   then that means that Variable 20 will control what common event is called
#   when you run the Call Common Event command. So, basically, if Variable 20
#   is set to 15 and then you Call Common Event, it will call Common Event 15
#   regardless of what you put into the actual parameter field of the Call
#   Common Event event command. If the variable is set to 0 or less, then it
#   will abide by the normal rules however, and so you can use the parameter
#   field for direct selection.
#
#    Also notable is the fact that the variable will automatically reset to 0
#   once the Call Common Event event command is executed. So, even if you just
#   set the value of your control variable to 15, once you call the common
#   event the value of your variable will once again be 0. This is to avoid any
#   accidents.
#==============================================================================
# ** Game_Interpreter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    new constant - COMMON_EVENT_VARIABLE_ID
#    aliased method - command_117 (Call Common Event)
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Constants
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  COMMON_EVENT_VARIABLE_ID = 20
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Call Common Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_cl_cmn_evnt_var_cmnd_117_89rn command_117
  def command_117
    var = $game_variables[COMMON_EVENT_VARIABLE_ID]
    @params[0] = var unless var <= 0
    # Run Original Method
    value = modalg_cl_cmn_evnt_var_cmnd_117_89rn
    # Reset Variable
    $game_variables[COMMON_EVENT_VARIABLE_ID] = 0
    return value
  end
end

Credit


  • modern algebra

Support


Please post here in this topic at rmrk.net for swiftest support. Also, if you have any suggestions, please post here. I am always looking for ways to improve my scripts.

Known Compatibility Issues

No known compatibility issues.

Demo


No demo necessary.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
« Last Edit: February 11, 2010, 09:53:54 PM by Modern Algebra »

**
Rep: +0/-0Level 84
thank you very much!  :)