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.
[RMVX Request]Script Modification (worale's call event script)

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 73
Impossibre!
Participant - GIAW 11
Hey! I really like this script and it is extremely useful! In my project, I wanted to have common events be able to affect Guard events in any map. Unfortunately, the only way for me to do that is to make sure that my guards are always a certain event i.d., and that is a real pain, plus it makes it hard to make a map look nice and work right when you have to make guards at an exact certain point in mapping. (that was a long sentence) Anyway, I was thinking that it would be possible for a script to call an event based on its name.

It should be possible, because I have seen many scripts that make events do certain things based on their names, and hopefully it wouldn't take too much of the scripter's time. Here is the script, and anything else whoever helps me needs will be available on demand.

http://rmrk.net/index.php/topic,26623.0.html

Thanks in advance!

**
Rep:
Level 73
Impossibre!
Participant - GIAW 11
Bump! I know you all are just dying to help me!

**
Rep:
Level 73
Impossibre!
Participant - GIAW 11
Gotta keep it fresh in your minds!

*
Rep: +0/-0Level 75
Scripter.new
Still needing it? (7 days off)

Paste this script above Main and below Woratana's script:


Code: [Select]
#==============================================================================
# Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # Public instance variables
  #--------------------------------------------------------------------------
  attr_reader :map
end
 
#==============================================================================
# Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # Method alias of call event
  #--------------------------------------------------------------------------
  alias cebn_callev callev
  #--------------------------------------------------------------------------
  # Call event
  #     event_attr : Attribute of the called event
  #     page       : Event page to be called
  #     map_id     : Map ID where the event is
  #--------------------------------------------------------------------------
  def callev(event_attr, page, map_id = $game_map.map_id)
    if event_attr.is_a?(Integer)
      cebn_callev(event_attr, page, map_id = $game_map.map_id)
    else
      return if event_attr.nil?
      return if event_attr.empty?
      if map_id != $game_map.map_id
        map = load_data(sprintf("Data/Map%03d.rvdata", map_id))
      else
        map = $game_map.map
      end
      for i in map.events.values
        next if i.name != event_attr
        event_id = i.id
      end
      return if event_id.nil?
      if page == 0
        event = map.events[event_id].pages[0]
      else
        event = map.events[event_id].pages[page - 1]
      end
      @child_interpreter = Game_Interpreter.new(@depth + 1)
      @child_interpreter.setup(event.list, @event_id)
    end
  end
end

Change the Event ID for the Event Name in call method:

Code: [Select]
callev("Event Name", page, map_id)

or

Code: [Select]
callev("Event Name", page)

For the actual map.

The Call Event by ID function of the original script still working.

Sorry for the bad English...

See you.
« Last Edit: April 09, 2011, 02:36:52 AM by Kyo Panda »
I'm Brazilian, so don't bother me about my English