Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logic_relay outputs do not properly carry the !caller #487

Open
alexiscoutinho opened this issue Jan 27, 2024 · 0 comments
Open

logic_relay outputs do not properly carry the !caller #487

alexiscoutinho opened this issue Jan 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@alexiscoutinho
Copy link
Contributor

alexiscoutinho commented Jan 27, 2024

Description

logic_relay outputs like OnTrigger and OnUserX do not properly forward the caller entity to the !caller target. Instead, the !caller target points to the relay itself. The !self and !activator targets work fine by the way.

A possible workaround for entities spawned via tables, if you don't care about the real activator, is to inject the real caller in the activator parameter of EntFire:

//button
OnIn =
{
    cmd1 = "!self�RunScriptCode�EntFire( \"relay_name\", \"Trigger\", \"\", 0, self )�0�-1"
}
//relay
OnTrigger =
{
    cmd1 = "!activator�FireUser1��0�-1"
    ...
}

Reproduction steps

script_execute the script below:

SpawnEntityFromTable( "script_func_button", {
	spawnflags = 1024
	origin = GetListenServerHost().EyePosition()
	extent = "8 8 8"
	connections =
	{
		OnPressed =
		{
			cmd1 = "relay_name�Trigger��0�-1"
		}
		OnUser1 =
		{
			cmd1 = "!self�RunScriptCode�printl(\"Success!\")�0�-1"
		}
	}
} )

SpawnEntityFromTable( "logic_relay", {
	targetname = "relay_name"
	connections =
	{
		OnTrigger =
		{
			cmd1 = "!caller�FireUser1��0�-1"
		}
		OnUser1 =
		{
			cmd1 = "!self�RunScriptCode�printl(\"Failure\")�0�-1"
		}
	}
} )

Take a step backwards then press the button (turn on picker mode if you can't find the invisible button). When you press it, you will see "Failure" instead of "Success!" in the console.

@alexiscoutinho alexiscoutinho added the bug Something isn't working label Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant