Referencing "this" interpreter in script calls

I have a script call like this

HMS.setName("test", 0)Which means set the name for event 0.Event 0 means "this event", to conform with RM's ID standard.

However, the method is evaluated in the context of the HMS object, instead of the interpreter that called it.

Is there a way for me to access the eventId stored in the interpreter using this script call?

Otherwise I'd have to use plugin commands which are evaluated in the interpreter.

Alternatively I could have users say

Code:
this.setName("test, 0)
But then that increases risk of name clash in the interpreter.
For my Self Variables plugin, i have users use "this" as a parameter:

Code:
$gameSelfVariables.get(this, 'A');
For my Self Variables plugin, i have users use "this" as a parameter:

$gameSelfVariables.get(this, 'A');
Would work.

Meaning seems to make sense as well when I read it.

"Get this self-variable A"

Though, it might get confusing when it's not actually "this" object, even though "this" doesn't actually mean that.

Alternatively, this might work:

HMS.setName(this, "text")HMS.setName(1, "text")Then I would check the type of input and determine how to handle it.I would assume "this" automatically means 0, and anything else means a specific object.

From my own programming perspective, it's not clean, cause I'm accepting two different completely different types of input and I generally don't like polymorphism as much unless they had a parent-child relationship or shared an interface , but the only special case I have is when I want to reference "this" object.

Hmm...
Yeah, in my plugin, "get" and "set" are used exclusively to access "this event", while the more generic "value" and "setValue" are used to provide basic access. I would assume, that most people use the plugin commands, anyway, unless you want to do heavy calculations.
Yeah, in my plugin, "get" and "set" are used exclusively to access "this event", while the more generic "value" and "setValue" are used to provide basic access. I would assume, that most people use the plugin commands, anyway, unless you want to do heavy calculations.
Well, there's the possibility that you would want to reference an object's data as input. I suppose I could evaluate it, but then you get into things like argument parsing and other messy things that don't exist with script calls.


Only issue with script calls is the scope problem lol
You might be able to use "Function.caller" (https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Function/caller), but it's nonstandard, so i would advise against it (although it seems, that it's supported by all major browsers).

Original thread: https://forums.rpgmakerweb.com/threads/referencing-this-interpreter-in-script-calls.53503/