[pre lang="ruby"]class Game_Character
attr_accessor :direction
end
class Game_Event
attr_reader :page
end
class Game_Map
alias mapsave_game_map_initialize initialize
def initialize
mapsave_game_map_initialize
@event_pos = {}
end
def save_event_pos
return unless @map
@event_pos[@map_id] = {}
for i in @map.events.keys
if @events.page
@event_pos[@map_id] = [@events.x, @events.y, @events.direction, @events.page.graphic.character_name]
end
end
end
def load_event_pos
return unless @event_pos[@map_id]
for i in @map.events.keys
if @event_pos[@map_id] and @events.page
if @events.page.graphic.character_name == @event_pos[@map_id][3]
@events.moveto(@event_pos[@map_id][0], @event_pos[@map_id][1])
@events.direction = @event_pos[@map_id][2]
end
end
end
end
alias mapsave_game_map_setup setup
def setup(map_id)
save_event_pos
mapsave_game_map_setup(map_id)
load_event_pos
end
end
[/pre]
[pre lang="ruby"] for i in @map.events.keys
if @events.page
@event_pos[@map_id] = [@events.x, @events.y, @events.direction, @events.page.graphic.character_name]
end
end[/pre]
[pre lang="ruby"] for i in @map.events.keys
if @event_pos[@map_id] and @events.page
if @events.page.graphic.character_name == @event_pos[@map_id][3]
@events.moveto(@event_pos[@map_id][0], @event_pos[@map_id][1])
@events.direction = @event_pos[@map_id][2]
end
end
end[/pre]