Silent Lua: Difference between revisions
Line 501: | Line 501: | ||
=== ClientIsFlooding === | === ClientIsFlooding === | ||
'''Description''' | |||
Tells if a client is flooding. | |||
'''Syntax''' | |||
flooding = et.ClientIsFlooding( clientnum ) | |||
*''clientnum'' is the slotnumber of the client that is checked | |||
*return value ''flooding'' is 1 if the clientis flooding, 0 otherwise | |||
'''Portability''' | |||
Function is not implementedin the ETPro Lua API. Function is derived from ETPub Lua module. | |||
=== G_AddSkillPoints === | === G_AddSkillPoints === | ||
=== G_LoseSkillPoints === | === G_LoseSkillPoints === |
Revision as of 21:54, 14 November 2012
silEnT servers support Lua 5.1.4 scripts. Starting from version 0.5.1 the Lua interpreter is inbuilt into the server side mod. Before the vesion 0.5.1, the Lua was installed as an external module. A separate build of the silEnT mod is supplied within the download to admins who still want to use separate Lua library. silEnT's Lua API is aiming to be fully compatible to ETPro's Lua API. The origin of the silEnT Lua API is the Lua module in ETPub version 0.9.1.
Cvars
lua_modules
Description:
List of files to be loaded by the Lua API engine. Can be separated by space, comma or semicolon. The paths are relative to the mod's directory, and can optionally be placed inside pk3 archieves. We are aiming for compatibility with ETPro's Lua Mod API found at http://wolfwiki.anime.net/index.php/Lua_Mod_API.
Type: string
Default: ""
lua_allowedModules
Description:
List of sha1 signatures for the lua modules to be loaded by the Lua API engine. Can be separated by space, comma or semicolon. Only lua modules with the matching sha1 signature listed in this cvar will be allowed to load by the Lua API engine (ACL).
Type: string
Default: ""
Commands
lua_status
Shows information about the scripts currently loaded by the Lua API server engine. This command works also from the client so that players can check what modules are currently loaded by the server.
Interface Function Reference
Modules
RegisterModname
Description
Registers a descriptive name for this Lua module.
Syntax
et.RegisterModname( modname )
- modname is the name to register the Lua module
Portability
Function is ETPro compatible.
FindSelf
Description
Returns a number indicating the VM slot the current mod is loaded into.
Syntax
vmnumber = et.FindSelf()
Portability
Function is ETPro compatible.
FindMod
Description
Returns the registered module name and the SHA-1 signature of the module loaded in the VM. Do note that each loaded Lua module will have it's own VM.
Syntax
modname, signature = et.FindMod( vmnumber )
- vmnumber is the number of the VM in where the Lua module is loaded
- return value (modname, signature) is the registered module's name and the SHA-1 signature. Returns (nil, nil) if there is no module loaded into the given VM number
Portability
Function is ETPro compatible.
IPCSend
Description
Inter Process Communication. This function enables communication between different loaded Lua modules.
Syntax
success = et.IPCSend( vmnumber, message )
- vmnumber is the number of the loaded module message is sent
- message is the string to send
- return value success is 1 if success and 0 if function fails
Portability
Function is ETPro compatible.
Printing
G_Print
Description
Prints text to the server console.
Syntax
et.G_Print( text )
- text is the printed string
Portability
Function is ETPro compatible.
G_LogPrint
Description
Prints text to the server console and also to the log.
Syntax
et.G_LogPrint( text )
- text is the printed and logged string
Portability
Function is ETPro compatible.
Argument Handling
ConcatArgs
Description
Function concatenates server command arguments into one string.
Syntax
args = et.ConcatArgs( index )
- index is the index of the first argument in the concatenated string. First command argument index in general is 1.
- return value args is the concatenated string
Portability
Function is ETPro compatible.
trap_Argc
Description
Function returns the number of the arguments in the server command.
Syntax
argc = et.trap_Argc()
- return value argc is the count of arguments. For example for the command "/m gao message", the function would return 2.
Portability
Function is ETPro compatible.
trap_Argv
Description
Function returns argument in the given index.
Syntax
arg = et.trap_Argv( index )
- index is the argument index to return.
- return value arg is the argument
Portability
Function is ETPro compatible.
Cvars
trap_Cvar_Get
Description
Returns the value of the given cvar.
Syntax
cvarvalue= et.trap_Cvar_Get( cvar )
- cvar is the name of the cvar
- return value cvarvalue is a string containing the value. If there is no cvar with the given name, the returning string has zero length.
Portability
Function is ETPro compatible.
trap_Cvar_Set
Description
Sets value to a cvar.
Syntax
et.trap_CvarSet( name, value )
- name is the name of the cvar to set
- value is the new value for the cvar
Portability
Function is ETPro compatible.
Configstrings
trap_GetConfigstring
Description
Returns contents of the configstring at index.
Syntax
configstringvalue = et.trap_GetConfigstring( index )
- index is the index of the configstring
- return value configstring contains the full config string
Portability
Function is ETPro compatible.
trap_SetConfigstring
Description
Function sets the full configstring.
Syntax
et.trap_SetConfigstring( index, configstringvalue )
- index is the configstring index
- configstringvalue is the full configstring to set
Portability
Function is ETPro compatible.
Server Console and Client Handling
trap_SendConsoleCommand
Description
Sends command to the server console.
Syntax
et.trap_SendConsoleCommand( when, command )
- when tells when the command is executed. Possible values are
- et.EXEC_NOW - executes instantly
- et.EXEC_INSERT - inserts at the current position but doesn't run yet
- et.EXEC_APPEND - appends at the end of the command buffer
- command is the full command to execute
Portability
Function is ETPro compatible.
trap_DropClient
Description
Disconnects client from the server.
Syntax
et.trap_DropClient( clientnum, reason, ban_time )
- clientnum is the slot number of the client to disconnect
- reason is the descriptive reason for the kick. This is also displayed to the client.
- ban_time is optional length of the kick. If this is not set, the g_defaultBanTime is used.
Portability
Function is ETPro compatible.
trap_SendServerCommand
Description
Function sends reliable server command to a client. I.e. the command is acknowledged by the client to ensure it has received it.
Syntax
et.trap_SendServerCommand( clientnum, command )
- clientnum is the slot number of the client to send the command. If the number is -1, the command is sent to all connected clients.
- command is the full command string to send
Portability
Function is ETPro compatible.
ClientNumberFromString
Description
Function finds one matching player name based on the given string.
Syntax
clientnum = et.ClientNumberFromString( string )
- string is a pattern to match against client names
- return value clientnum is the client slot number if one match is found, otherwise -1 is returned
Portability
ETPro does not implement this function. Function is derived to silEnT from ETPub implementation.
G_Say
Description
Writes to chat on behalf of a client.
Syntax
et.G_Say( clientNum, mode, text )
- clientNum is the slot number of the client on behalf to write chat
- mode is the type of chat to write. Possible values are
- et.SAY_ALL - writes to the global chat
- et.SAY_TEAM - writes to the team chat of the client
- et.SAY_BUDDY - writes to the fireteam chat of the client
- et.SAY_TEAMNL - writes to the team chat of the client without position
- text is the chat message to write
Portability
Function is ETPro compatible.
ClientUserinfoChanged
Description
Loads the new userinfo string of the client and sets the client settings to match it.
Syntax
et.ClientUserinfoChanged( clientNum )
- clientNum is the slot number of the client who's userinfo is loaded
Portability
Function is ETPro compatible.
trap_GetUserinfo
Description
Returns the userinfo string of a client.
Syntax
userinfo = et.trap_GetUserinfo( clientnum )
- clientnum is the slot number of the client who's userinfo is returned
- return value userinfo is the full userinfo string of that client
Portability
Function is ETPro compatible.
trap_SetUserinfo
Description
Sets the userinfo string of the client to the passed userinfo. To make the changes to take effect in the game, ClientUserinfoChanged must be called after this function.
Syntax
et.trap_SetUserinfo( clientnum, userinfo )
- clientnum is the slot number of the client who's userinfo is changed
- userinfo is the full new userinfo of the client
Portability
Function is ETPro compatible.
G_Damage
Description
Damages target entity on behalf of the attacker entity.
Syntax
et.G_Damage( target, inflictor, attacker, damage, dflags, mod )
- target is the entity number to damage, value must be 0 or more
- inflictor is the entity number that does the damage, value must be 0 or more
- attacker is the entity number that causes the inflictor entity to cause damage to target, value must be 0 or more
- damage is the amount of damage to inflict
- dflags is the type of damage to inflict, possible values are
- DAMAGE_RADIUS - damage was indirect (from a nearby explosion)
- DAMAGE_NO_ARMOR - armor does not protect from this damage
- DAMAGE_NO_KNOCKBACK - do not affect velocity, just view angles
- DAMAGE_NO_PROTECTION - kills godmode, armor, everything
- mod is the means of death, possible values are:
- 0 - MOD_UNKNOWN
- 1 - MOD_MACHINEGUN
- 2 - MOD_BROWNING
- 3 - MOD_MG42
- 4 - MOD_GRENADE
- 5 - MOD_ROCKET
- 6 - MOD_KNIFE
- 7 - MOD_LUGER
- 8 - MOD_COLT
- 9 - MOD_MP40
- 10 - MOD_THOMPSON
- 11 - MOD_STEN
- 12 - MOD_GARAND
- 13 - MOD_SNOOPERSCOPE
- 14 - MOD_SILENCER
- 15 - MOD_FG42
- 16 - MOD_FG42SCOPE
- 17 - MOD_PANZERFAUST
- 18 - MOD_GRENADE_LAUNCHER
- 19 - MOD_FLAMETHROWER
- 20 - MOD_GRENADE_PINEAPPLE
- 21 - MOD_CROSS
- 22 - MOD_MAPMORTAR
- 23 - MOD_MAPMORTAR_SPLASH
- 24 - MOD_KICKED
- 25 - MOD_GRABBER
- 26 - MOD_DYNAMITE
- 27 - MOD_AIRSTRIKE
- 28 - MOD_SYRINGE
- 29 - MOD_AMMO
- 30 - MOD_ARTY
- 31 - MOD_WATER
- 32 - MOD_SLIME
- 33 - MOD_LAVA
- 34 - MOD_CRUSH
- 35 - MOD_TELEFRAG
- 36 - MOD_FALLING
- 37 - MOD_SUICIDE
- 38 - MOD_TARGET_LASER
- 39 - MOD_TRIGGER_HURT
- 40 - MOD_EXPLOSIVE
- 41 - MOD_CARBINE
- 42 - MOD_KAR98
- 43 - MOD_GPG40
- 44 - MOD_M7
- 45 - MOD_LANDMINE
- 46 - MOD_SATCHEL
- 47 - MOD_TRIPMINE
- 48 - MOD_SMOKEBOMB
- 49 - MOD_MOBILE_MG42
- 50 - MOD_SILENCED_COLT
- 51 - MOD_GARAND_SCOPE
- 52 - MOD_CRUSH_CONSTRUCTION
- 53 - MOD_CRUSH_CONSTRUCTIONDEATH
- 54 - MOD_CRUSH_CONSTRUCTIONDEATH_NOATTACKER
- 55 - MOD_K43
- 56 - MOD_K43_SCOPE
- 57 - MOD_MORTAR
- 58 - MOD_AKIMBO_COLT
- 59 - MOD_AKIMBO_LUGER
- 60 - MOD_AKIMBO_SILENCEDCOLT
- 61 - MOD_AKIMBO_SILENCEDLUGER
- 62 - MOD_SMOKEGRENADE
- 63 - MOD_SWAP_PLACES
- 64 - MOD_SWITCHTEAM
- 65 - MOD_GOOMBA
- 66 - MOD_POISON
- 67 - MOD_FEAR
- 68 - MOD_THROWN_KNIFE
- 69 - MOD_REFLECTED_FF
- 70 - MOD_PPSH
- 71 - MOD_SHOVE
Portability
Function is implemented in ETPro but some of the mod values may differ.
ClientIsFlooding
Description
Tells if a client is flooding.
Syntax
flooding = et.ClientIsFlooding( clientnum )
- clientnum is the slotnumber of the client that is checked
- return value flooding is 1 if the clientis flooding, 0 otherwise
Portability
Function is not implementedin the ETPro Lua API. Function is derived from ETPub Lua module.
G_AddSkillPoints
G_LoseSkillPoints
String Utility Functions
Info_RemoveKey
Info_SetValueForKey
Info_ValueForKey
Q_CleanStr
Filesystem
trap_FS_FOpenFile
trap_FS_Read
trap_FS_Write
trap_FS_Rename
trap_FS_FCloseFile
Sounds and Models
G_SoundIndex
G_ModelIndex
G_globalSound
G_Sound
G_ClientSound
Entities
G_Spawn
G_TempEntity
G_FreeEntity
G_EntitiesFree
G_GetSpawnVar
G_SetSpawnVar
trap_LinkEntity
trap_UnlinkEntity
gentity_get
gentity_set
G_AddEvent
Shrubbot
G_shrubbot_permission
G_shrubbot_level
Time
trap_Milliseconds
Callbacks
et_InitGame
et_ShutdownGame
et_RunFrame
et_ClientConnect
et_ClientDisconnect
et_ClientBegin
et_ClientUserinfoChanged
et_ClientSpawn
et_ClientCommand
et_ConsoleCommand
et_UpgradeSkill
et_SetPlayerSkill
et_Print
et_Obituary
References
- Document was constructed using information at http://wolfwiki.anime.net/index.php/ETPro:Lua_Mod_API as well as reading the mod source.
- Official Lua http://www.lua.org/