Copying a map event in-game?

I'm trying to use a script to make a copy of an existing event in-game, and while the event os created successfully and I can interact with it as expected, it's never being drawn on the actual map.  Here is my code (it runs when the action button is pressed, and puts a copy of event ID 3 directly in front of the player):

var direction = $gamePlayer.direction();var x1 = $gamePlayer.x;var y1 = $gamePlayer.y;var x2 = $gameMap.roundXWithDirection(x1, direction);var y2 = $gameMap.roundYWithDirection(y1, direction);var e = new Game_Event($gameMap._mapId, 3);e.setPosition(x2, y2);$gameMap._events.push(e); $gameMap.requestRefresh();console.log($gameMap._events);Note:  I tried $gameMap.requestRefresh() just for kicks -- it doesn't seem to help.  I also tried explicitly setting the event to visible, but that didn't do anything either (the event I'm copying is visible anyway).

I'm guessing I need to add the event to some kind of draw queue somewhere, but I've been digging through the code, and so far I'm kind of at a loss as to where the event's corresponding sprite is located in the code (as far as I can tell, it doesn't seem to be referenced from inside the Game_Event object).  If I can make this work, I'd like to release a simple eveny copying plugin so other people can make use of it too.  Any help would be appreciated,
I don't see you giving it a graphic.

I've moved this thread to Javascript/Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.
The event I'm copying already has a graphic, and is displaying correctly on screen.  Is this something I need to manually?  If so, how do I do it?  It's not clear from the Game_Event object how I would add a graphic to it (note that the object in question already has a nonzero tile ID).
Thanks to a tip from a plugin developer, I have a solution, and that is to append these two lines to the end of the code:

SceneManager._scene._spriteset._characterSprites.push(s);SceneManager._scene._spriteset._tilemap.addChild(s);You can check out their plugin here, which does custom event creation.  It's probably a lot better to use it than my crappy code. 🙂

https://github.com/Hudell/mv-plugins/tree/master/OrangeCustomEvents
If you copy the event, the new event will have the same id as the old event.

There IS a plugin already that will let you clone events.  Have you seen it?  Any reason why you don't want to use it?  If you still want to write your own, you could at least take a look at that one to see how they've done it.

Original thread: https://forums.rpgmakerweb.com/threads/copying-a-map-event-in-game.47252/