Difference between revisions of "Category:Lua Commands"

From Fortress Forever Wiki
Jump to navigationJump to search
Line 6: Line 6:
  
 
{| border="1" cellspacing="0"
 
{| border="1" cellspacing="0"
! LUA Command !! Discription
+
! LUA Command !! Description
 
|-
 
|-
 
| [[Lua:Tick|tick]]() || This function is called every second by the engine.
 
| [[Lua:Tick|tick]]() || This function is called every second by the engine.
Line 22: Line 22:
  
 
{| border="1" cellspacing="0"
 
{| border="1" cellspacing="0"
! LUA Command !! Discription
+
! LUA Command !! Description
 
|-
 
|-
 
| [[Lua:player_spawn|player_spawn]]( player ) || triggers when a player spawns.
 
| [[Lua:player_spawn|player_spawn]]( player ) || triggers when a player spawns.
Line 85: Line 85:
 
= Casting Commands =
 
= Casting Commands =
  
in lua entity's and other objects may be passed to other commands's as a different object then needed these are used to cast or transform a lua object to a different type of object such as a player.
+
These functions cast game objects into different data types. See [[Lua:Entity_typing]]
  
 
{| border="1" cellspacing="0"
 
{| border="1" cellspacing="0"
! LUA Command !! Discription
+
! LUA Command !! Description
 
|-
 
|-
 
| [[Lua:CastToBeam|CastToBeam]]( ent_id ) || tries to cast the entity to a beam (to see if whatever triggered the event was a laser beam, a la SD2). If it fails, it returns null.
 
| [[Lua:CastToBeam|CastToBeam]]( ent_id ) || tries to cast the entity to a beam (to see if whatever triggered the event was a laser beam, a la SD2). If it fails, it returns null.
Line 110: Line 110:
  
  
= Entity Check's =
+
= Entity Checks =
 
these commands are used to Check if a passed in entity is a game entity of a specific type
 
these commands are used to Check if a passed in entity is a game entity of a specific type
  
 
{| border="1" cellspacing="0"
 
{| border="1" cellspacing="0"
! LUA Command !! Discription
+
! LUA Command !! Description
 
|-
 
|-
 
| [[Lua:IsPlayer|IsPlayer]]( ent_id ) || used to see if a passed in entity is a player to before actions are performed on said player.
 
| [[Lua:IsPlayer|IsPlayer]]( ent_id ) || used to see if a passed in entity is a player to before actions are performed on said player.
Line 133: Line 133:
  
 
{| border="1" cellspacing="0"
 
{| border="1" cellspacing="0"
! LUA Command !! Discription
+
! LUA Command !! Description
 
|-
 
|-
 
| [[Lua:BroadCastMessage|BroadCastMessage]]( message ) || broadcasts a given message to all players.
 
| [[Lua:BroadCastMessage|BroadCastMessage]]( message ) || broadcasts a given message to all players.
Line 150: Line 150:
  
 
{| border="1" cellspacing="0"
 
{| border="1" cellspacing="0"
! LUA Command !! Discription
+
! LUA Command !! Description
 
|-
 
|-
 
| [[Lua:AddSchedule|AddSchedule]]("name", time, function[, param1 ... param4]) || Schedules function to go off with time second delay. Optional parameters are applied to the function.
 
| [[Lua:AddSchedule|AddSchedule]]("name", time, function[, param1 ... param4]) || Schedules function to go off with time second delay. Optional parameters are applied to the function.

Revision as of 20:16, 11 May 2009


LUA commands that require further explanation.

Global Events

These are functions that are called by the engine that do not belong inside any class. Simply declare them as globals in the lua namespace.

LUA Command Description
tick() This function is called every second by the engine.
precache() This function is called when the map starts, before entities have been initialized.
startup() This function is called when the map starts, after all the entities have been initialized, also used to set map properties.
flaginfo()

Player Triggered Commands

These commands are triggered when a event with a player happens in-game.

LUA Command Description
player_spawn( player ) triggers when a player spawns.
player_killed( player, killer ) triggers when a player is killed.
player_onconc( player, inflictor ) triggers when a player is conced.

conc_duration -- duration of conc

conc_iconduration -- duration of conced icon on HUD

player_ondamage( player ) triggers is called whenever a player takes damage.
player_ontranq( player, inflictor ) triggers when a player is tranq'd.

tranq_duration -- duration of tranq.

tranq_speed -- speed of tranq'd player.

player_ongas( player, inflictor ) triggers when a player is gassed.

gas_duration

gas_iconduration

player_oninfect( player, inflictor )

infection_duration

infect_iconduration

player_onradiotag( player, inflictor )

radiotag_duration radiotag_iconduration

player_onheadshot( player, inflictor )
player_onlegshot( player, inflictor )

legshot_duration

legshot_iconduration

legshot_speed

player_oncaltrop( player, inflictor )

caltrop_duration

caltrop_iconduration

caltrop_speed

player_onacspinup( player, inflictor )

acspinup_duration

acspinup_speed

player_onsniperrifle( player, inflictor )

sniperrifle_speed

player_onspeedluaX( player, inflictor ) these are for various speed settings, like CZ2's flags. You can have up to ten, they're defined here.

speedlua_speed

Casting Commands

These functions cast game objects into different data types. See Lua:Entity_typing

LUA Command Description
CastToBeam( ent_id ) tries to cast the entity to a beam (to see if whatever triggered the event was a laser beam, a la SD2). If it fails, it returns null.
CastToPlayer( ent_id ) used to cast the passed in entity to a player, often used for touch commands.
CastToInfoScript( ent_id )
CastToTriggerScript( ent_id )
CastToTriggerClip( ent_id )
CastToGrenade( ent_id )
CastToDispenser( ent_id )
CastToSentrygun( ent_id )
CastToDetpack( ent_id )


Entity Checks

these commands are used to Check if a passed in entity is a game entity of a specific type

LUA Command Description
IsPlayer( ent_id ) used to see if a passed in entity is a player to before actions are performed on said player.
IsDispenser( ent_id )
IsSentrygun( ent_id )
IsDetpack( ent_id )
IsGrenade( ent_id )
IsTurret( ent_id )

Player messaging and sounds

these are used to send text messages and sounds to players.

LUA Command Description
BroadCastMessage( message ) broadcasts a given message to all players.
BroadCastMessageToPlayer( player, message ) broadcasts message to one player.
BroadCastSound( sound )
BroadCastSoundToPlayer( player, sound )
ConsoleToAll( message ) sends a message to server console. Inaccurately named.

Other Commands

other misc commands not lumped into any group as of yet.

LUA Command Description
AddSchedule("name", time, function[, param1 ... param4]) Schedules function to go off with time second delay. Optional parameters are applied to the function.
AddScheduleRepeating("name", time, function[, param1 ... param4]) Adds a schedule that repeats function constantly every time seconds.
AddScheduleRepeatingNotInfinitely("name", time, function, counts[, param1 ... param4]) Adds a schedule that repeats function counts times every time seconds.
AddHudIcon( player, HudIconType, NameOfHudIcon, X, Y, Width, Height, Align ) adds HUD icon to given player of given type. Name is generally taken from the flag entity to apply the right kind. X, Y, W, H, and A are all standard.
AddHudIconToAll( HudIconType, NameOfHudUcon, X, Y, W, H, A ) adds HUD icon to all players like those used for flag info.
DeleteSchedule( schedulename ) deletes an existing schedule.
RemoveSchedule( schedulename ) same as delete.
GetConvar( cvar ) checks the value of a console variable (cvar)
GetEntity( index ) gets an entity by its index.
GetEntityByName( name ) obvious?
GetInfoScriptById( id ) gets an info_ff_script's information by its id.
GetInfoScriptByName( name ) obvious?
GetGrenade() ??
GetPacketloss( playerentity ) gets a player's packet loss. Woo?
GetPing( playerentity )
GetPlayer( playerentity )
GetPlayerByID( id )
GetServerTime()
GetSteamID( playerentity )
GetTeam( playerentity )
GetTriggerScriptByName( name )
GoToIntermission( ) ???
IncludeScript( luafile ) used to include Lua files found in /includes/ such as base_teamplay or base_ctf.
ApplyToAll( effect )
ApplyToTeam( effect, team )
ApplyToPlayer( effect, player )
AreTeamsAllied( team1, team2 ) obvious?
KillAndRespawnAllPlayers() obvious!
NumPlayers() gets the number of players.
OutputEvent( event, ent_id[, param1, param2, etc.] ) tells an entity to fire the given output.
OutputEvent , void * const char* , const char* , const char* , float , unsigned int &FFLib::FireOutput
PrecacheModel( modelfile ) loads a given model into memory for use later.
PrecacheSound( soundfile ) as above.
PrintBool , &FFLib::PrintBool
RandomFloat( min, max ) generates a random float.
RandomInt( min, max ) generates a random integer
RemoveEntity( ent_id ) removes entity.
RemoveHudItem( player, hudiconid ) removes hud icon.
RemoveHudItemFromAll( hudiconid )
RespawnAllPlayers( ) respawns everyone.
ResetMap() resets map.
SetGlobalRespawnDelay( time ) enforces a respawn delay.
SetPlayerLimit( team , # ) used to set player limit per team.
SetPlayerLimits( #, # )
SmartClassLimits( team, #scout, #sniper, #soldier, #demoman, #medic, #hwguy, #pyro, #spy, #engineer, #civilian ) sets smart class limits instead of using individual commands.
SetConvar( player, var, value ) sets a players cvar to set value
SetTeamAllies( team , bits ) used to ally one team to another.
SetTeamClassLimit( team, class, limit )
SetTeamName( team, name )
SetTeamPlayerLimit( team, limit )
SetTeamPlayerLimit( team, limit )
SmartMessage , &FFLib::SmartMessage
SmartSound , &FFLib::SmartSound
SmartTeamMessage , &FFLib::SmartTeamMessage
SmartTeamSound , &FFLib::SmartTeamSound
SpeakAll , &FFLib::SpeakAll
SpeakPlayer , &FFLib::SpeakPlayer
SpeakTeam , &FFLib::SpeakTeam