Author Topic: Slayer: Please fix this Support_EventTargets stuff  (Read 1727 times)


This has been an issue over and over, if I disable Slayer I do not get this kind of spam until it is activated again. This happens when I rapidly activate.

I have PM'd Greek about this, and I never got a response.

Can I get an actual log file?

Honestly though this doesn't matter at all.

Why eval is being used here at all seems to be the real question

server/support/Support_EventTargets.cs:96
    $InputTarget_[%targetName] = eval("return" SPC %targetFindCode @ ";");


%targetFindCode is influenced by :92
    %targetFindCode = strReplace(%targetFindCode,"%this",%this);


%this is from :72
    function SimObject::processInputEvent(%this,%eventName,%client)


Using the result of a raycast as a single object is pretty common as object logic works fine even with extra words, i.e.:

%ray = containerRayCast(...);

if (%ray)
    %ray.processInputEvent(...);


... which would cause %this to receive that value.
The solution is to remove this, as eval receives %this from the local scope regardless:
    %targetFindCode = strReplace(%targetFindCode,"%this",%this);

For example, this works fine (though of course there's no reason to use eval in this example):

%thing = findLocalClient();
%name = eval("return %thing.getPlayerName();");

%thing = findLocalClient();
%name = eval("return %thing.getPlayerName();");

This practice is known as quickscoping.

This practice is known as quickscoping.

Related:

function evalNoScope(%code)
{
    eval("%code=\"\";" @ %code);
}


Noscoping is also fun.

Related:

function evalNoScope(%code)
{
    eval("%code=\"\";" @ %code);
}


Noscoping is also fun.
hah

eval receives %this from the local scope

I didn't know that. Thank you. It seems bizarre though, since eval takes a string.

This practice is known as quickscoping.
heh :D