Revision Difference
Map_Lua#564998
<cat>Dev.Map</cat>
<title>Map Lua</title>
Maps can run Lua scripts via the `lua_run` entity.
Here's an example on `gm_construct`:
<upload src="70c/8dc34c7aa6923b1.png" size="625196" name="image.png" />
During the execution of the script, the following global variables are available:
```
-- The activator of the input (i.e. the player that pressed a button or walked into the trigger)
print( ACTIVATOR )
-- The called or the input (i.e. button or the trigger that sent the input to this lua_run entity)
print( CALLER )
-- Will be set to the ACTIVATOR, if it is a player.
print( TRIGGER_PLAYER )
```
The code can be ran on entity spawn via a spawnflag, or via its `RunCode` input.
There's also the `RunPassedCode` input, which will run any code passed as the input value. Never use double-quotation marks `""` in any Hammer Output, it will corrupt the map file. Try using Double Square brackets `[[]]` instead.
There's also the `RunPassedCode` input, which will run any code passed as the input value. Never use double-quotation marks `""` in any Hammer Output, it will corrupt the map file. Try using Double Square brackets `[[]]` instead⤶
⤶
-- The activator of the input (i.e. the player that pressed a button or walked into the trigger)⤶
print( ACTIVATOR )⤶
⤶
-- The called or the input (i.e. button or the trigger that sent the input to this lua_run entity)⤶
print( CALLER )⤶
⤶
-- Will be set to the ACTIVATOR, if it is a player.⤶
print( TRIGGER_PLAYER )