Referring to an event by its name and not its ID

I'm currently working on a system that relies on multiple events that refer to each other. The most important ones need to be placed on relevant maps in a specific order, as copy/pasted events will refer to things by ID and not by something user-defined like a name.

Is there a way to have an event refer to something strictly by the name I give it instead of its internal ID?
Iam not sure if i understand you.

Control Variables -- Var1 set to script: "Bob"

Textbox: Hello Hero, my Name is \V[1].

Ingame that would read like this: Hello Hero, my Name is Bob.

Or can you explain in more detail, the thing you are trying to create.
Maybe something along these lines? (Sorry untested 😅)
$gameMap.events().filter(e => e.event().name == 'replace this with the name you want to search for')[0]
This will give you the first event of the current map whose name matches the given string. If the name you search for is unique, that should suffice.
If I have Event A (ID 1) set to move Event B (ID 2), it will move Event B as intended. However if I copy Event B and Event A to a different map in that order, they will switch their internal IDs. This results in Event A being ID2 and Event B being ID1.

$gameMap.events().filter(e => e.event().name == 'replace this with the name you want to search for')[0]
This will give you the first event of the current map whose name matches the given string. If the name you search for is unique, that should suffice.
I'll try this out once I'm home. I've never dabbled in javascript.
@RianQuenlin the problem with your idea is that the computer cannot understand names. It barely understands numbers (because deep down, numbers are emulated by a series of switches for the bits of binary numbers).

the only thing that you can do is writing a javascript function that loops through all events, compares the names to a given string, and returns the ID of the first matching event with that name.
and then have the other event reference the number found in that way.

of course the loop takes time during gameplay, so it would still be better in most cases to simply manually note the new IDs when you copy the events in the editor and then modify the events with the new IDs.

or if you are using a clone plugin for the copying, then remember the new ID when the event is copied.
If I have Event A (ID 1) set to move Event B (ID 2), it will move Event B as intended. However if I copy Event B and Event A to a different map in that order, they will switch their internal IDs. This results in Event A being ID2 and Event B being ID1.
Stuff like this is just a part of working with computers and, generally, working with a given piece of software. You learn how it works and accommodate. Either copy them in the appropriate order, or take a few seconds to click into the event and edit any references.

The problem with resorting to the JavaScript that eomere supplied is that many of the event commands you might be using to refer to another event can't accept script calls.

So, for example, if you're moving another event in a Move Route, there's not a way to use a JavaScript function to tell it which event you're controlling - you either click into it to select the correct event on that map, or you have to recreate the entire move route command in JavaScript, which would end up being way more work.
Guess I'll just look into offloading as much as I can into clones and common events then. Thanks anyway.

Original thread: https://forums.rpgmakerweb.com/threads/referring-to-an-event-by-its-name-and-not-its-id.149888/