MV How to make a plugin with continual checks

Hello everyone. I am new here, and new to programming (but did not start for RPG Maker).
I'd appreciate if someone could help me here.

I am working on a plugin that needs to do continuous checks.
So far, it only executes once.

Would it be wise to insert it into an infinite loop with a timer (to don't crash the game)?

More details on the plugin:
The plugin calculates the distance between the player an all events on the map containing a proper note.
It will then activate the Event's Self Switch, so it changes the Event's page. Right now, i am using the other page to make the monster try to catch the player and then it would start a battle.
So i need to constantly check the distance between the player and the events, because the player and the event may move around.
Moved to: Learning Javascript

I have split your post into its own topic as it certainly isn't a "question that doesn't deserve its own thread"

You definitely don't want to make an infinite loop. All of the classes already have functions that will run once per frame, so you just have to find the appropriate class and function and put it in there.

I would probably create Game_Event.update() function, making it call the inherited Game_CharacterBase.update() function, then adding your extra logic to check just that event. Or alias Game_Player.update() and add code to look at each event and update if necessary.

Be careful what you do here. There are already things happening to every event on every frame - this sounds like an opportunity for you to introduce a lot of lag.
I've moved this thread to Learning Javascript. Please be sure to post your threads in the correct forum next time. Thank you.
Sorry
You definitely don't want to make an infinite loop. All of the classes already have functions that will run once per frame, so you just have to find the appropriate class and function and put it in there.

I would probably create Game_Event.update() function, making it call the inherited Game_CharacterBase.update() function, then adding your extra logic to check just that event. Or alias Game_Player.update() and add code to look at each event and update if necessary.

Be careful what you do here. There are already things happening to every event on every frame - this sounds like an opportunity for you to introduce a lot of lag.
Thank you very much! I will look into it! You were very helpful.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-plugin-with-continual-checks.131832/