- Joined
- Jun 9, 2014
- Messages
- 70
- Reaction score
- 3
- First Language
- English
- Primarily Uses
=beginName: Remember Event PositionAuthor: DarkShadow44Description: Saves additional information for events that RPGMaker normally doesn't saveInstructions: Just Copy the script into your script editor, under "Materials".For convenience the door events are skipped during save, so you don't need to reset them manually.Copyright (c) 2015 DarkShadow44Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.=end#=beginclass Game_Event < Game_Character attr_reader :eventendclass Game_CharacterBase def setData(eventDataSave) moveto(eventDataSave[0], eventDataSave[1]) set_direction(eventDataSave[2]) @transparent = eventDataSave[3] @through = eventDataSave[4] @step_anime = eventDataSave[5] @walk_anime = eventDataSave[6] @move_frequency = eventDataSave[7] @move_speed = eventDataSave[8] if(eventDataSave[9] == true) erase end @direction_fix = eventDataSave[10] end def getData() eventDataSave = [] eventDataSave[0] = @x eventDataSave[1] = @y eventDataSave[2] = @direction eventDataSave[3] = @transparent eventDataSave[4] = @through eventDataSave[5] = @step_anime eventDataSave[6] = @walk_anime eventDataSave[7] = @move_frequency eventDataSave[8] = @move_speed eventDataSave[9] = @erased eventDataSave[10]= @direction_fix; return eventDataSave endendclass Game_Map attr_accessor:eventData alias initialize_super initialize def initialize() @eventData = [] @lastMap = -1 initialize_super() end def log(data) print(data) end def isDoor(event) return event.event.name =~ /door/i end def saveMap(map_id, mapEvents) log("Trying to save map ") log(map_id) log("\n") if mapEvents == nil if(mapEvents == nil) log("save: mapEvents nil\n") end else if eventData[map_id] == nil eventData[map_id] = [] end currentMap = eventData[map_id] #save additional event data mapEvents.each_value do |event| if(not isDoor(event)) currentMap[event.id] = event.getData() end end log("Saved data for map ") log(map_id) log("\n") end end def loadMap(map_id, mapEvents) log("Trying to load map ") log(map_id) log("\n") if mapEvents == nil if(mapEvents == nil) log("load: mapEvents nil\n") end else if eventData[map_id] == nil eventData[map_id] = [] end currentMap = eventData[map_id] #load additional event data mapEvents.each_value do |event| if(not isDoor(event)) eventDataSave = currentMap[event.id] if(eventDataSave != nil) event.setData(eventDataSave) end end end log("Loaded data for map ") log(map_id) log("\n") end end alias setup_super setup def setup(map_id) if(@lastMap != -1) saveMap(@lastMap, @events) end @lastMap = map_id #setup map setup_super(map_id) loadMap(map_id, @events) endend#=endThe script is now fixed and should work for doors, there have been no other issues reported.
Last edited by a moderator:
