MV Trigger common events with mouse hover on event

So i couldn't find any plugins to use mouse hover as input to trigger a common event, i'm making a point and click and wanted to fill the borders of the map with events, that, when triggered by the moouse hover input, would transfer to a different map, to emulate looking around. As a last resource i turned to chatgpt and it made me this script:

JavaScript:
//=============================================================================
// HoverEventTrigger.js
//=============================================================================

/*:
 * @plugindesc Triggers common events on mouse hover based on event note tags.
 * @author Your Name
 *
 * @param Common Events
 * @text Common Events Configuration
 * @desc Configuration for triggering common events on mouse hover.
 * @type struct<CommonEvent>[]
 * @default []
 *
 * @help
 * This plugin allows you to trigger different common events
 * based on note tags assigned to events on the map.
 *
 * Note tags should be added to event notes in the following format:
 * <triggerHover> or <customHover>
 *
 * Each common event is configured in the Plugin Manager parameters.
 */

/*~struct~CommonEvent:
 * @param Note Tag
 * @desc The note tag that identifies events triggering this common event on hover.
 * @type text
 *
 * @param Common Event ID
 * @desc The ID of the common event to trigger.
 * @type number
 * @min 1
 *
 * @param Cooldown Time
 * @desc The cooldown period in frames for each common event.
 * @type number
 * @min 1
 * @default 60
 */

(function() {
  var pluginParams = PluginManager.parameters('HoverEventTrigger');
  var commonEvents = JSON.parse(pluginParams['Common Events']);

  var cooldowns = {};

  document.addEventListener('mouseover', function(event) {
    try {
      console.log('Mouseover event:', event);

      if (!SceneManager._scene || !SceneManager._scene.spriteset || !SceneManager._scene.spriteset.characterSprites) {
        console.log('Scene or spriteset not fully initialized');
        return; // Exit early if scene or spriteset is not fully initialized
      }

      var character = SceneManager._scene.spriteset.characterSprites.find(function(sprite) {
        return sprite instanceof Sprite_Character && sprite.character === event.target;
      });

      if (character && character instanceof Sprite_Character) {
        var event = character._character;
        console.log('Hovered event:', event);

        var noteTag = event.event().note.trim().replace(/<(?:.|\n)*?>/gm, '');
        console.log('Event note tag:', noteTag);

        var config = findConfigByNoteTag(noteTag);
        console.log('Config for note tag:', config);
        
        if (config && !cooldowns[event.eventId()]) {
          console.log('Triggering Common Event ID:', config['Common Event ID']);
          $gameTemp.reserveCommonEvent(config['Common Event ID']);
          cooldowns[event.eventId()] = config['Cooldown Time'];
          setTimeout(function() {
            cooldowns[event.eventId()] = 0;
          }, config['Cooldown Time'] * 1000);
        }
      }
    } catch (error) {
      console.error('Error in hover event trigger:', error);
    }
  });

  function findConfigByNoteTag(noteTag) {
    for (var i = 0; i < commonEvents.length; i++) {
      if (commonEvents[i]['Note Tag'] === noteTag) {
        return commonEvents[i];
      }
    }
    return null;
  }
})();

initially, it worked for the mouse hover input, but with the limit of just one common event, so i asked to rewrite it and add the option to put multiple common events, to do that i set in the parameters the note tag that links to a common event, and put that note tag on the event, but, this time, hovering with the mouse does nothing, what could be the problem here?
i already asked to rewrite a bunch of times and checked everything in the engine, thanks in advance!
so far I can tell, you say it can be triggered by <TriggerHover> and <CustomHover>
but it's nowhere in your code that tells you that. just a notetag by a custom string.

so how does your code exactly work?
I'm wondering if this script would work for you.

const picId = 101; SceneManager._scene._spriteset._pictureContainer.children[picId - 1]?.isBeingTouched()

I have been using this with Show Pictures and this script as the Conditional Branch. For me, I am just showing another picture, but since it is a Conditional Branch, you could do a lot. Even call a Common Event.

So in this script example, the Show Picture ID is 101. I have another plugin that allows picture IDs above 100.

I didn't make this script. But is is working great for my Hover Over Hints event. Hover over a picture and it shows information. Move off the picture and the information goes away.

EDIT: I should mention this works for me in MZ. Not sure if anything needs to be different for MV.
If you don't need anything extensive, you can do this. Put these event commands in your event set to parallel trigger. Use the conditional branch, script portion. Run the common event you want. Use a selfswitch on the event to move it to a different page so the parallel page stops running.

Do note that this only checks if the mouse is specifically on the event, whether the mouse was moved to be on the event, or if you left the mouse on the screen and moved the player using directional keys and the mouse happened to have entered in the event's coordinates:
JavaScript:
◆Wait: 15 frames
◆If:Script:this.character(0).x === $gameMap.canvasToMapX(TouchInput.x) && this.character(0).y === $gameMap.canvasToMapY(TouchInput.y)
  ◆Common Event:Common Message
  ◆Control Self Switch:A = ON
  ◆
:End

Edit: do note that there is TouchInput.isHovered() in MZ, not in MV.

Original thread: https://forums.rpgmakerweb.com/threads/trigger-common-events-with-mouse-hover-on-event.169661/