Revision Difference
ENTITY:TriggerOutput#546212
<function name="TriggerOutput" parent="ENTITY" type="hook">
<description>Triggers all outputs stored using <page>ENTITY:StoreOutput</page>.</description>⤶
<description>Triggers all outputs stored using <page>ENTITY:StoreOutput</page>.⤶
<note>ACTIVATOR / CALLER / TRIGGER_PLAYER globals are only available during execution, they are unset directly afterwards.⤶
https://github.com/Facepunch/garrysmod/blob/1a50a5f72f61e6cb714ed50ebccd33a01b4b6ecc/garrysmod/gamemodes/base/entities/entities/lua_run.lua#L38</note>⤶
</description>⤶
<realm>Server</realm>
<predicted>No</predicted>
<args>
<arg name="output" type="string">Name of output to fire</arg>
<arg name="activator" type="Entity">Activator entity</arg>
<arg name="data" type="string" default="nil">The data to give to the output.</arg>
</args>
</function>
<example>
<description>
For engine entities you can use <page>Entity:Fire</page> to hook outputs. This example hooks all trigger_teleport
</description>
<code>
local function SetupMapLua()
MapLua = ents.Create( "lua_run" )
MapLua:SetName( "triggerhook" )
MapLua:Spawn()
for k, v in pairs( ents.FindByClass( "trigger_teleport" ) ) do
print( v )
v:Fire( "AddOutput", "OnStartTouch triggerhook:RunPassedCode:hook.Run( 'OnTeleport' ):0:-1" )
end
end
hook.Add( "InitPostEntity", "SetupMapLua", SetupMapLua )
hook.Add( "PostCleanupMap", "SetupMapLua", SetupMapLua )
hook.Add( "OnTeleport", "TestTeleportHook", function()
local activator, caller = ACTIVATOR, CALLER
print( activator, caller )
end )
</code>
<output>
When player touches trigger_teleport this will be printed in the console:
```
Player [1][Player1] Entity [3][trigger_teleport]
```
</output>
</example>