I got a script that would enable me to call events from one map to another, but I keep getting a method not defined error. I had an event that would activate on player interaction and would call an event on another map
I got the script from here: https://rmrk.net/index.php?topic=49541.0
This is the script
And this is the error:
I got the script from here: https://rmrk.net/index.php?topic=49541.0
This is the script
Code:
==============================================================================
#
# ▼ Yanfly Engine Ace - Spawn Event v1.00
# -- Last Updated: 2012.02.08
# -- Level: Normal, Hard
# -- Requires: n/a
#
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.02.08 - Started Script and Finished.
# Edited for RPG Maker XP by Wrinkle
# Credit to Modern Algebra for fixing the graphic refresh bug
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# For those who would like to spawn pre-made events from the current map or
# even other maps, this script allows you to do so. With the option of spawning
# the events at specific locations or a random spot marked by a certain region,
# you can have events spawn using simple script calls. The events remain until
# a map change.
#
# -----------------------------------------------------------------------------
# Script Calls - These commands are used with script calls.
# -----------------------------------------------------------------------------
# spawn_event_location(x, y, event_id)
# spawn_event_location(x, y, event_id, map_id)
# This causes a new event to be created at location x,y on the current map with
# the data from the corresponding event and map ID.
# The map_id is where the event will be called from according to event_id.
# If no map_id is included it will call the event from your current map.
#
#==============================================================================
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# new method: spawn_event
#--------------------------------------------------------------------------
def spawn_event(dx, dy, event_id, map_id)
map_id = @map_id if map_id == 0
map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
event = generated_event(map, event_id)
return if event.nil?
key_id = @events.keys.max + 1
@events[key_id] = Game_Event.new(@map_id, event)
@events[key_id].moveto(dx, dy)
$scene.spriteset.wrinkle_refresh_event(@events[key_id])
end
#--------------------------------------------------------------------------
# new method: generated_event
#--------------------------------------------------------------------------
def generated_event(map, event_id)
for key in map.events
event = key[1]
next if event.nil?
return event if event.id == event_id
end
return nil
end
end # Game_Map
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# new method: spawn_event_location
#--------------------------------------------------------------------------
def spawn_event_location(dx, dy, event_id, map_id = 0)
$game_map.spawn_event(dx, dy, event_id, map_id)
end
end # Game_Interpreter
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :spriteset
end # Scene_Map
class Spriteset_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Refresh_Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def wrinkle_refresh_event(event)
# Refresh new region event
index = @character_sprites.size - 1
@character_sprites.insert(index, Sprite_Character.new(@viewport1, event))
end
end #Refresh_Event
#==============================================================================
#
# ▼ End of File
#
#==============================================================================
And this is the error:
Code:
Script error in event 1 (coords 6,6), map 22 (MAP022)
Exception: NoMethodError
Message: undefined method `wrinkle_refresh_event' for nil:NilClass
***Full script:
spawn_event_location(8,8,1,1)
Backtrace:
386:Spawn_event:53:in `spawn_event'
386:Spawn_event:80:in `spawn_event_location'
(eval):1:in `execute_script'
033:Interpreter:143:in `eval'
033:Interpreter:143:in `execute_script'
034:Interpreter_Commands:1112:in `command_355'
034:Interpreter_Commands:116:in `execute_command'
033:Interpreter:133:in `block in update'
033:Interpreter:90:in `loop'
033:Interpreter:90:in `update'