Garry's Mod Wiki

ENTITY:TriggerOutput

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

Description

Triggers all outputs stored using ENTITY:StoreOutput.

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() 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 )
Output: When player touches trigger_teleport this will be printed in the console:

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

Page Links


Special Pages


Wikis

?

Render Time: 36ms

DB GetPage 4
Generate Html 10
SaveChanges (1) 8
Render Body 0
Render Sidebar 12