Garry's Mod Wiki

ENTITY:TriggerOutput

ENTITY:TriggerOutput

  ENTITY:TriggerOutput( string output, Entity activator, string data = "nil" )

Description

Triggers all outputs stored using ENTITY:StoreOutput.

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

Arguments

1 string output
Name of output to fire
2 Entity activator
Activator entity
3 string data = "nil"
The data to give to the output.

Example

For engine entities you can use Entity:Fire to hook outputs. This example hooks all trigger_teleport.

local function SetupMapLua() local MapLua = ents.Create( "lua_run" ) MapLua:SetName( "triggerhook" ) MapLua:Spawn() for _, v in ipairs( ents.FindByClass( "trigger_teleport" ) ) do 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 )
Output: When player touches trigger_teleport this will be printed in the console:

Player [1][Player1] Entity [3][trigger_teleport]

Special Pages


Wikis

?

Render Time: 30ms

DB GetPage 4
Generate Html 7
SaveChanges (1) 8
Render Body 0
Render Sidebar 9