Ok, I have been experimenting around with using RGSS to add and then later remove events from a map. I can do each operation individually without a problem. That is to say, if can remove any event from a map that was on the map when it was loaded, and I can add events to the map that weren't there when the map was loaded. The problem occurs if I want to use RGSS to remove an event that I created through RGSS as opposed to one that was loaded with the game map. When I attempt to remove an RGSS generated event, the corresponding event sprite is not removed from the game map.
Here is the code used to create an event:
And here is the code I am using to remove an existing event
Does anyone know why using these scripts in conjunction cause a problem when they work fine when used independently?
Thanks for the help.
Here is the code used to create an event:
Code:
def create_event(x,y,name="")
# Create a new RPG::Event object (ev)
ev = RPG::Event.new(x, y)
ev.id = $game_map.events.size + 1
#print ev.id
ev.pages = []
# Create a game event object using map id and ev value
event = Game_Event.new($game_map.map_id, ev)
event.through = false
# Set the event at ev.id to our event (include it in map)
$game_map.events[ev.id] = event
#$event_instance[ev.id] = event
#$game_map.map.events.keys.push(@summon_index)
$game_map.map.events[ev.id] = ev
#print $game_map.events
# Map needs to be redrawn because a new event was added
$game_map.need_refresh = true
$scene.spriteset.add_additional_sprites
event.character_name = name
end
And here is the code I am using to remove an existing event
Code:
def delete_event(index)
e = $game_map.events.delete(index)
e.erase
end
Does anyone know why using these scripts in conjunction cause a problem when they work fine when used independently?
Thanks for the help.