MV Access an event's Sprite object

Morning guys,

So I have created a function in the Sprite class. Just imagine it's something like this:

Code:
Sprite.prototype.helloWorld = function(msg) {
  console.log(msg);
};

I need to call this function for the Sprite that draws a particular event, let's say event 214 on the map.

I thought it would be as simple as: $gameMap.event(214).sprite.helloWorld("hi");

But there doesn't seem to be a property "sprite" of event. In fact trawling through the MV scripting reference, I cannot even find a Sprite attached to an Event (or Character, or CharacterBase).

Having created the function I want, how do I call it for a given event's Sprite object?
You don't want to do it on Sprite. Do it on
Game_Character.prototype, or Game_Event.prototype
Sprite is a class more based around showing and tracking the sprite itself, it goes in the spriteset of Scene_Map.
The objects that get returned from the $gameMap.events calls aren't Sprite objects

EDIT:
Since the title of the thread is accessing an event's sprite object, I'll go a step further, and explain how to actually do that from the getting the event.
There are several ways, here's the way I do it. I have a function for it, so I'll just share that.
JavaScript:
function findInSpriteset(char){ //char is the event object ex: $gameMap.event(214)
    let spset = SceneManager._scene._spriteset._characterSprites;
    let i = {};
  
    for(i of spset){
        if(i._character == char)
        return i; 
    }
    return false;
}

The object that gets returned would actually be a Sprite_Character, which gets a prototype from the Sprite_Base, which gets a prototype from Sprite. So the function you wrote in your post would be accessible on the object that gets returned here
Awesome, than function is exactly what I need, thanks.

Original thread: https://forums.rpgmakerweb.com/threads/access-an-events-sprite-object.127695/