store an event in memory, spawn new unique copies at runtime?

darkgriffin

Villager
Member
Joined
Sep 3, 2013
Messages
23
Reaction score
3
First Language
English
Primarily Uses
Is there a best practice or good root object to use for copying an event off the map during loading, then recreating all the data needed to insert a new event during gameplay or even map loading?


My goal is to be able to, during the map data loading done in Game_Map.prototype.data function:


1 - grab some events the user made in the editor, by name  (I got this part, I think).


2 - put these events back into the game just after modding the map data, but before the game runs the map.  I don't understand what the engine does with events and characters during the map scene for this part.


I've tried copying $dataMap.events to an array using JsonEx.makeDeepCopy($dataMap.events);





 





But when I put them into the gameMap object with $gameMap._events[next_id]=JsonEx.makeDeepCopy(dg_events[2]);





 





I get a terrible crash saying: 






Quote







TypeError: undefined is not a function


    at file:///C:/Users/DarkGriffin/Documents/Rpg%20maker%20mv/CodeProject/js/rpg_objects.js:6154:22


    at Array.some (native)


    at Game_Map.isAnyEventStarting (file:///C:/Users/DarkGriffin/Documents/Rpg%20maker%20mv/CodeProject/js/rpg_objects.js:6153:26)


    at Game_Map.isEventRunning (file:///C:/Users/DarkGriffin/Documents/Rpg%20maker%20mv/CodeProject/js/rpg_objects.js:5421:50)


    at Game_Player.canMove (file:///C:/Users/DarkGriffin/Documents/Rpg%20maker%20mv/CodeProject/js/rpg_objects.js:7609:18)


    at Scene_Map.isMapTouchOk (file:///C:/Users/DarkGriffin/Documents/Rpg%20maker%20mv/CodeProject/js/rpg_scenes.js:485:43)


    at Scene_Map.updateDestination (file:///C:/Users/DarkGriffin/Documents/Rpg%20maker%20mv/CodeProject/js/rpg_scenes.js:476:14)


    at Scene_Map.update (file:///C:/Users/DarkGriffin/Documents/Rpg%20maker%20mv/CodeProject/js/rpg_scenes.js:397:10)


    at Function.SceneManager.updateScene (file:///C:/Users/DarkGriffin/Documents/Rpg%20maker%20mv/CodeProject/js/rpg_managers.js:1788:25)


    at Function.SceneManager.updateMain (file:///C:/Users/DarkGriffin/Documents/Rpg%20maker%20mv/CodeProject/js/rpg_managers.js:1754:14)









 





In other words, that does not appear to be the object it's expecting there.





 





Does anyone know the object I should be copying or replacing into to make this work?  I'm having hell using the debugger and javascript code to figure out how this is working under the hood during a map display loop, or what object/function I should be "loading" my copied event data into.  Any event programmers here who know this better then me?
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,546
Reaction score
3,717
First Language
Java's Crypt
Primarily Uses
RMMZ
Cloning an event is not that simple, but there are plenty of plugins that do that already. You can look at their code to understand what's being done. Here's mine:
 

darkgriffin

Villager
Member
Joined
Sep 3, 2013
Messages
23
Reaction score
3
First Language
English
Primarily Uses
Thanks for the reply.  Looks like I dove into the deep end of things, lol.  


I had no idea the game engine split up the sprite objects in the map data and the event page array.  Though in hind sight, it does make sense since "event pages" can be battle or common events too.


Looks like I have my homework cut out for me.  I'll have to save this for a day I'm not so busy.  Too many interconnected systems to figure out in the little half hour bursts I normally have for MV coding.  I already memorize code for my other game programming in other engines, so the event structures and calls are not really sticking when I try to study it.  I'll grasp it eventually, somehow.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,446
Members
137,820
Latest member
georg09byron
Top