I'm trying to make a custom data structure that gets saved based on my input from inside the game. Kind of think of it like Yanfly's GridFreeDoodad's plugin, which I'm sort of using as a reference except without the fancy UI and graphical loading. In short, I'm making a plugin that'll help me toggle a feature that allows me to click an object, drag it to a location, place it, face it a certain direction, and then save that event data to a JSON file to be read when I reopen the game. More or less allowing me to make a custom event placement system that isn't dependent on the 48x48 grid.
I've done something like this before, where I also set up a system where I can click and drag the player to a location, face them in a direction, and then prompt you to warp to another map where you can also click and drag your player, name the warp, and save that data to a data structure I called $dataWarps, allowing for precise warping of the character between named warp points. And that one actually works pretty well, though with my loose understanding of reading and writing files, I feel like it works by the skin of my teeth.
In this instance, I have run into the problem of keeping a catalogue of pretty much every object in every map in a structure called $dataColliders. This object contains a hierarchy that looks like:
I've had a lot of trouble trial-and-erroring when and where and how I need to load this data, because from my understanding, the $gameMap and event data is actually loaded when you enter the map, which I've pinpointed to Game_Map.prototype.setupEvents; I'm currently exploring how to load the data, but part of that problem is that there's not really a way to load all that data up front. While I technically could just load the data in on a map-by-map basis, it kind of necessitates creating a corresponding JSON file for every map, and so, what if the map ID changes, or some similar thing that makes it so I have to move all that data over to the new map? What if the new map's event IDs are totally different? And in any case, it sort of seems redundant to keep a nigh-identical data structure index when I could just go into $dataMap.events like normal and piggyback off that.
My question is, is there a clean way to say, go into the MapXXXX files, add an object after the event data, and then have the Game_Map.prototype.setupEvents or other initialization function read that second object's data, or even better yet, simply insert the data I need into each event as I go along? Where would I even start doing that? I've read a lot of tutorials about it, but everyone's more concerned with just getting the basic functionality down without imparting a lot of deeper understanding.
I've done something like this before, where I also set up a system where I can click and drag the player to a location, face them in a direction, and then prompt you to warp to another map where you can also click and drag your player, name the warp, and save that data to a data structure I called $dataWarps, allowing for precise warping of the character between named warp points. And that one actually works pretty well, though with my loose understanding of reading and writing files, I feel like it works by the skin of my teeth.
In this instance, I have run into the problem of keeping a catalogue of pretty much every object in every map in a structure called $dataColliders. This object contains a hierarchy that looks like:
Code:
$dataColliders
- _data
-- 0 null
-- 1 Game Map 1
--- mapId: 1
--- mapName: 'Game Map 1'
--- events: [null, event 1, event 2, ...]
-- 2 Game Map 2
-- 3 Game Map 3...
I've had a lot of trouble trial-and-erroring when and where and how I need to load this data, because from my understanding, the $gameMap and event data is actually loaded when you enter the map, which I've pinpointed to Game_Map.prototype.setupEvents; I'm currently exploring how to load the data, but part of that problem is that there's not really a way to load all that data up front. While I technically could just load the data in on a map-by-map basis, it kind of necessitates creating a corresponding JSON file for every map, and so, what if the map ID changes, or some similar thing that makes it so I have to move all that data over to the new map? What if the new map's event IDs are totally different? And in any case, it sort of seems redundant to keep a nigh-identical data structure index when I could just go into $dataMap.events like normal and piggyback off that.
My question is, is there a clean way to say, go into the MapXXXX files, add an object after the event data, and then have the Game_Map.prototype.setupEvents or other initialization function read that second object's data, or even better yet, simply insert the data I need into each event as I go along? Where would I even start doing that? I've read a lot of tutorials about it, but everyone's more concerned with just getting the basic functionality down without imparting a lot of deeper understanding.