added functions, fields, constants, misc and cleanup

This commit is contained in:
Remy Marquis 2016-09-14 02:33:09 +02:00
parent 1b61756812
commit efab78cfa7
11 changed files with 1284 additions and 60 deletions

View file

@ -2,4 +2,6 @@
Legacy's Lua API is the interface for communication between Lua and Legacy mod. Legacy's Lua API is the interface for communication between Lua and Legacy mod.
This documentation can be read online at [legacy-lua-api.rtfd.io](http://legacy-lua-api.rtfd.io) This documentation is generated with [Sphinx](http://www.sphinx-doc.org/) using the [reStructuredText](http://www.sphinx-doc.org/en/stable/rest.html) markup language.
It can be read online at [legacy-lua-api.rtfd.io](http://legacy-lua-api.rtfd.io).

View file

@ -2,7 +2,7 @@
Callbacks Callbacks
========= =========
Here is a list of all the Lua callbacks of Legacy mod. Here are all available Lua callbacks.
qagame execution qagame execution
@ -56,7 +56,7 @@ Called when a client attempts to connect to the server.
* `firstTime` indicates if this is a new connection (1) or a reconnection (0). * `firstTime` indicates if this is a new connection (1) or a reconnection (0).
* `isBot` indicates if the client is a bot (1) or not (0). * `isBot` indicates if the client is a bot (1) or not (0).
If the mod accepts the connection, it should return `nil`. Otherwise, the mod should return a string describing the reason the client connection was rejected. If the mod accepts the connection, it returns `nil`. Otherwise, the mod should return a string describing the reason the client connection was rejected.
et_ClientDisconnect( clientNum ) et_ClientDisconnect( clientNum )
@ -108,7 +108,7 @@ Called when a command is received from a client.
* `clientNum` is the client slot id. * `clientNum` is the client slot id.
* `command` is the command. * `command` is the command.
The mod should return 1 if the command was intercepted by the mod, and 0 if the command was ignored by the mod and should be passed through to the server (and other mods in the chain). Returns 1 if the command was intercepted by the mod, and 0 if the command was ignored and passed through to the server (and other mods in the chain).
.. tip:: The actual command can be accessed through the argument handling functions, as seen in the `Sample Code <sample.html>`__. .. tip:: The actual command can be accessed through the argument handling functions, as seen in the `Sample Code <sample.html>`__.
@ -118,7 +118,7 @@ intercepted = et_ConsoleCommand()
Called when a command is entered on the server console. Called when a command is entered on the server console.
The mod should return 1 if the command was intercepted by the mod, and 0 if the command was ignored by the mod and should be passed through to the server (and other mods in the chain). Returns 1 if the command was intercepted, and 0 if the command was ignored and passed through to the server (and other mods in the chain).
.. tip:: The actual command can be accessed through the argument handling functions, as seen in the `Sample Code <sample.html>`__. .. tip:: The actual command can be accessed through the argument handling functions, as seen in the `Sample Code <sample.html>`__.
@ -128,25 +128,25 @@ XP
et_UpgradeSkill( clientNum, skill ) et_UpgradeSkill( clientNum, skill )
----------------------------- -----------------------------------
Called when a client gets a skill upgrade. Called when a client gets a skill upgrade.
* `clientNum` is the client slot. * `clientNum` is the client slot.
* `skill` is the skill number. * `skill` is the skill number.
Return -1 to override (abort) the qagame function, anything else to "passthrough". Callback may modify skills (or do anything else it wants) during passthrough. Returns -1 to override (abort) the qagame function, anything else to "passthrough". Callback may modify skills (or do anything else it wants) during passthrough.
et_SetPlayerSkill( clientNum, skill ) et_SetPlayerSkill( clientNum, skill )
------------------------------- -------------------------------------
Called when a client skill is set. Called when a client skill is set.
* `clientNum` is the client slot. * `clientNum` is the client slot.
* `skill` is the skill number. * `skill` is the skill number.
Return -1 to override (abort) the qagame function, anything else to "passthrough". Callback may modify skills (or do anything else it wants) during passthrough. Returns -1 to override (abort) the qagame function, anything else to "passthrough". Callback may modify skills (or do anything else it wants) during passthrough.
Miscellaneous Miscellaneous
@ -159,13 +159,13 @@ et_Print( text )
Called whenever the server or qagame prints a string to the console. Called whenever the server or qagame prints a string to the console.
.. warning:: Text may contain a player name and their chat message. This makes it very easy to spoof. .. warning:: **DO NOT TRUST STRINGS OBTAINED IN THIS WAY!**
DO NOT TRUST STRINGS OBTAINED IN THIS WAY! Text may contain a player name and their chat message, which makes it very easy to spoof.
et_Obituary( target, attacker, meansOfDeath ) et_Obituary( target, attacker, meansOfDeath )
------------------------------------------- ---------------------------------------------
Called whenever a player is killed. Called whenever a player is killed.
@ -174,16 +174,16 @@ Called whenever a player is killed.
* `meansOfDeath` is the means of death. * `meansOfDeath` is the means of death.
et_Damage( target, attaker, damage, damageFlags, meansOfDeath) et_Damage( target, attacker, damage, damageFlags, meansOfDeath)
------------------------------------------------------------- ---------------------------------------------------------------
Called whenever a player gets damage. Called whenever a player gets damage.
* `target` is the victim. * `target` is the victim.
* `attacker` is the killer. * `attacker` is the killer.
* `damage` is the amount of damage. * `damage` is the amount of damage.
* `damageFlags` is the flag that controls how damage is inflicted. * `damageFlags` is the `flag <damages.html#damage-flags>`__ that controls how damage is inflicted.
* `meansOfDeath` is the means of death. * `meansOfDeath` is the `means of death <damages.html#means-of-death>`__.
et_SpawnEntitiesFromString() et_SpawnEntitiesFromString()

View file

@ -2,12 +2,13 @@
Commands Commands
======== ========
Here is a list of all the Lua commands of Legacy mod. Here are all available Lua commands.
Server commands Server commands
=============== ===============
lua_status lua_status
----------- -----------

View file

@ -123,7 +123,7 @@ todo_include_todos = True
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
# #
html_theme = 'default' html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the

314
constants.rst Normal file
View file

@ -0,0 +1,314 @@
=========
Constants
=========
Here is a list of all the Lua constants.
CS constants
============
============================= ======================================================
Name Value
============================= ======================================================
et.CS_SERVERINFO 0
et.CS_SYSTEMINFO 1
et.CS_MUSIC 2
et.CS_MESSAGE 3
et.CS_MOTD 4
et.CS_WARMUP 5
et.CS_VOTE_TIME 6
et.CS_VOTE_STRING 7
et.CS_VOTE_YES 8
et.CS_VOTE_NO 9
et.CS_GAME_VERSION 10
et.CS_LEVEL_START_TIME 11
et.CS_INTERMISSION 12
et.CS_MULTI_INFO 13
et.CS_MULTI_MAPWINNER 14
et.CS_MULTI_OBJECTIVE 15
et.CS_SCREENFADE 17
et.CS_FOGVARS 18
et.CS_SKYBOXORG 19
et.CS_TARGETEFFECT 20
et.CS_WOLFINFO 21
et.CS_FIRSTBLOOD 22
et.CS_ROUNDSCORES1 23
et.CS_ROUNDSCORES2 24
et.CS_MAIN_AXIS_OBJECTIVE 25
et.CS_MAIN_ALLIES_OBJECTIVE 26
et.CS_MUSIC_QUEUE 27
et.CS_SCRIPT_MOVER_NAMES 28
et.CS_CONSTRUCTION_NAMES 29
et.CS_VERSIONINFO 30
et.CS_REINFSEEDS 31
et.CS_SERVERTOGGLES 32
et.CS_GLOBALFOGVARS 33
et.CS_AXIS_MAPS_XP 34
et.CS_ALLIED_MAPS_XP 35
et.CS_INTERMISSION_START_TIME 36
et.CS_ENDGAME_STATS 37
et.CS_CHARGETIMES 38
et.CS_FILTERCAMS 39
et.CS_LEGACYINFO 40
et.CS_SVCVAR 41
et.CS_CONFIGNAME 42
et.CS_TEAMRESTRICTIONS 43
et.CS_UPGRADERANGE 44
et.CS_MODELS 64
et.CS_SOUNDS 320 *(CS_MODELS + MAX_MODELS)*
et.CS_SHADER 576 *(CS_SOUNDS + MAX_SOUNDS)*
et.CS_SHADERSTATE 608 *(CS_SHADERS + MAX_CS_SHADERS)*
et.CS_SKINS 609 *(CS_SHADERSTATE + 1)*
et.CS_CHARACTERS 673 *(CS_SKINS + MAX_CS_SKINS)*
et.CS_PLAYERS 689 *(CS_CHARACTERS + MAX_CHARACTERS)*
et.CS_MULTI_SPAWNTARGETS 753 *(CS_PLAYERS + MAX_CLIENTS)*
et.CS_OID_TRIGGERS 769 *(CS_MULTI_SPAWNTARGETS + MAX_MULTI_SPAWNTARGETS)*
et.CS_OID_DATA 787 *(CS_OID_TRIGGERS + MAX_OID_TRIGGERS)*
et.CS_DLIGHTS 805 *(CS_OID_DATA + MAX_OID_TRIGGERS)*
et.CS_SPLINES 821 *(CS_DLIGHTS + MAX_DLIGHT_CONFIGSTRINGS)*
et.CS_TAGCONNECTS 829 *(CS_SPLINES + MAX_SPLINE_CONFIGSTRINGS)*
et.CS_FIRETEAMS 893 *(CS_TAGCONNECTS + MAX_TAGCONNECTS)*
et.CS_CUSTMOTD 905 *(CS_FIRETEAMS + MAX_FIRETEAMS)*
et.CS_STRINGS 911 *(CS_CUSTMOTD + MAX_MOTDLINES)*
et.CS_MAX 943 *(CS_STRINGS + MAX_CSSTRINGS)*
============================= ======================================================
MAX constants
=============
============================= ==================
Name Value
============================= ==================
et.MAX_CLIENTS 64
et.MAX_MODELS 256
et.MAX_SOUNDS 256
et.MAX_CS_SKINS 64
et.MAX_CSSTRINGS 32
et.MAX_CS_SHADERS 32
et.MAX_SERVER_TAGS 256
et.MAX_TAG_FILES 64
et.MAX_MULTI_SPAWNTARGETS 16
et.MAX_DLIGHT_CONFIGSTRINGS 16
et.MAX_SPLINE_CONFIGSTRINGS 8
et.MAX_OID_TRIGGERS 18
et.MAX_CHARACTERS 16
et.MAX_TAGCONNECTS 64
et.MAX_FIRETEAMS 12
et.MAX_MOTDLINES 6
============================= ==================
WP constants
============
============================= ================== ==================================
Name Value Description
============================= ================== ==================================
et.WP_NONE 0 No weapon
et.WP_KNIFE 1 Axis Knife Dagger
et.WP_LUGER 2 Luger
et.WP_MP40 3 MP40
et.WP_GRENADE_LAUNCHER 4 Axis Grenade
et.WP_PANZERFAUST 5 Panzerfaust
et.WP_FLAMETHROWER 6 Flamethrower
et.WP_COLT 7 Colt 1911
et.WP_THOMPSON 8 Thompson
et.WP_GRENADE_PINEAPPLE 9 Allies Grenade
et.WP_STEN 10 Sten
et.WP_MEDIC_SYRINGE 11 Syringe
et.WP_AMMO 12 Ammo pack
et.WP_ARTY 13 Artillery
et.WP_SILENCER 14 Silenced Luger
et.WP_DYNAMITE 15 Dynamite
et.WP_SMOKETRAIL 16 Artillery Initial smoke
et.WP_MAPMORTAR 17 Fixed Mortars
et.VERYBIGEXPLOSION 18 Airstrike Explosion effect
et.WP_MEDKIT 19 Medic pack
et.WP_BINOCULARS 20 Binoculars
et.WP_PLIERS 21 Pliers
et.WP_SMOKE_MARKER 22 Airstrike Marker
et.WP_KAR98 23 Kar98 (Axis Rifle)
et.WP_CARBINE 24 M1 Garand
et.WP_GARAND 25 Scoped M1 Garand
et.WP_LANDMINE 26 Landmine
et.WP_SATCHEL 27 Satchel
et.WP_SATCHEL_DET 28 Satchel Detonator
et.WP_SMOKE_BOMB 29 Smoke Grenade
et.WP_MOBILE_MG42 30 Mobile MG42
et.WP_K43 31 K43 (Axis Sniper Rifle)
et.WP_FG42 32 FG42
et.WP_DUMMY_MG42 33 Fixed MG42
et.WP_MORTAR 34 Allies Mortar
et.WP_AKIMBO_COLT 35 Akimbo Colts 1911
et.WP_AKIMBO_LUGER 36 Akimbo Lugers
et.WP_GPG40 37 Kar98 (Grenade Loaded)
et.WP_M7 38 M1 Garand (Grenade Loaded)
et.WP_SILENCED_COLT 39 Silenced Colt 1911
et.WP_GARAND_SCOPE 40 Scoped M1 Garand (Scoped Mode)
et.WP_K43_SCOPE 41 K43 (Scoped Mode)
et.WP_FG42SCOPE 42 FG42 (Scoped Mode)
et.WP_MORTAR_SET 43 Allies Deployed Mortar
et.WP_MEDIC_ADRENALINE 44 Adrenaline
et.WP_AKIMBO_SILENCEDCOLT 45 Akimbo Silenced Colts 1911
et.WP_AKIMBO_SILENCEDLUGER 46 Akimbo Silenced Lugers
et.WP_MOBILE_MG42_SET 47 Deployed Mobile MG42
et.WP_KNIFE_KABAR 48 Allies KA-BAR Knife
et.WP_MOBILE_BROWNING 49 Mobile Browning
et.WP_MOBILE_BROWNING_SET 50 Deployed Mobile Browning
et.WP_MORTAR2 51 Axis Mortar
et.WP_MORTAR2_SET 52 Axis Deployed Mortar
et.WP_BAZOOKA 53 Bazooka
et.WP_NUM_WEAPONS 54 Number of weapons
============================= ================== ==================================
MOD constants
=============
========================================= ==================
Name Value
========================================= ==================
et.MOD_UNKNOWN 0
et.MOD_MACHINEGUN 1
et.MOD_BROWNING 2
et.MOD_MG42 3
et.MOD_GRENADE 4
et.MOD_KNIFE 5
et.MOD_LUGER 6
et.MOD_COLT 7
et.MOD_MP40 8
et.MOD_THOMPSON 9
et.MOD_STEN 10
et.MOD_GARAND 11
et.MOD_SILENCER 12
et.MOD_FG42 13
et.MOD_FG42SCOPE 14
et.MOD_PANZERFAUST 15
et.MOD_GRENADE_LAUNCHER 16
et.MOD_FLAMETHROWER 17
et.MOD_GRENADE_PINEAPPLE 18
et.MOD_MAPMORTAR 19
et.MOD_MAPMORTAR_SPLASH 20
et.MOD_KICKED 21
et.MOD_DYNAMITE 22
et.MOD_AIRSTRIKE 23
et.MOD_SYRINGE 24
et.MOD_AMMO 25
et.MOD_ARTY 26
et.MOD_WATER 27
et.MOD_SLIME 28
et.MOD_LAVA 29
et.MOD_CRUSH 30
et.MOD_TELEFRAG 31
et.MOD_FALLING 32
et.MOD_SUICIDE 33
et.MOD_TARGET_LASER 34
et.MOD_TRIGGER_HURT 35
et.MOD_EXPLOSIVE 36
et.MOD_CARBINE 37
et.MOD_KAR98 38
et.MOD_GPG40 39
et.MOD_M7 40
et.MOD_LANDMINE 41
et.MOD_SATCHEL 42
et.MOD_SMOKEBOMB 43
et.MOD_MOBILE_MG42 44
et.MOD_SILENCED_COLT 45
et.MOD_GARAND_SCOPE 46
et.MOD_CRUSH_CONSTRUCTION 47
et.MOD_CRUSH_CONSTRUCTIONDEATH 48
et.MOD_CRUSH_CONSTRUCTIONDEATH_NOATTACKER 49
et.MOD_K43 50
et.MOD_K43_SCOPE 51
et.MOD_MORTAR 52
et.MOD_AKIMBO_COLT 53
et.MOD_AKIMBO_LUGER 54
et.MOD_AKIMBO_SILENCEDCOLT 55
et.MOD_AKIMBO_SILENCEDLUGER 56
et.MOD_SMOKEGRENADE 57
et.MOD_SWAP_PLACES 58
et.MOD_SWITCHTEAM 59
et.MOD_SHOVE 60
et.MOD_KNIFE_KABAR 61
et.MOD_MOBILE_BROWNING 62
et.MOD_MORTAR2 63
et.MOD_BAZOOKA 64
et.MOD_BACKSTAB 65
et.MOD_NUM_MODS 66
========================================= ==================
SAY constants
=============
================= ================== ==================
Name Value Description
================= ================== ==================
et.SAY_ALL 0 Message will be sent to everyone.
et.SAY_TEAM 1 Message will be sent to the client's team.
et.SAY_BUDDY 2 Message will be sent to the client's fireteam.
et.SAY_TEAMNL 3 Message will be sent to the client's team, without location.
================= ================== ==================
EXEC constants
==============
================= ==================
Name Description
================= ==================
et.EXEC_NOW Executes instantly, don't return until completed.
et.EXEC_INSERT Insert at current position, but don't run yet.
et.EXEC_APPEND Append at the end of the command buffer.
================= ==================
FS constants
============
================= ==================
Name Description
================= ==================
et.FS_READ Opens file in read only mode.
et.FS_WRITE Opens file in write mode, truncates old file if a file already exists.
et.FS_APPEND Opens file in write mode at the end of file, old file is not erased if it already exists.
et.FS_APPEND_SYNC Like et.FS_APPEND, but file buffer is flushed to file on hard drive directly after every write operation.
================= ==================
Misc constants
==============
================= ==================================== ==================
Name Value Description
================= ==================================== ==================
et.HOSTARCH "WIN32", "MACOS" or "UNIX" Host architecture
================= ==================================== ==================
Lua constants
=============
================= ==================================== ==================
Name Value Description
================= ==================================== ==================
LUA_PATH ./legacy/?.lua; Ease use of the require function
./legacy/lualibs/?.lua; to load scripts
fs_homepath/fs_game/?.lua;
fs_homepath/fs_game/lualibs/?.lua
LUA_CPATH ./legacy/lualibs/?.so; Ease use of the require function
fs_homepath/legacy/lualibs/?.so to load libraries
LUA_DIRSEP / Directory separator
_VERSION Lua 5.3 Lua version
================= ==================================== ==================

View file

@ -2,7 +2,7 @@
Cvars Cvars
===== =====
Here is a list of all the Lua cvars of Legacy mod. Here are all available Lua cvars.
.. note:: Changing either cvar will cause all currently loaded modules to quit and be unloaded until the next `map_restart`. .. note:: Changing either cvar will cause all currently loaded modules to quit and be unloaded until the next `map_restart`.
@ -21,4 +21,4 @@ lua_allowedmodules
**Default:** "" (disabled) **Default:** "" (disabled)
If set, only lua modules with the matching SHA1 signatures listed in this cvar will be allowed to load. If set, only lua modules with the matching SHA1 signatures listed in this cvar will be allowed to load. If empty, all loaded modules are allowed.

250
fields.rst Normal file
View file

@ -0,0 +1,250 @@
======
Fields
======
Here are all available Lua fields supported by `et.gentity_get() <functions.html#variable-et-gentity-get-entnum-fieldname-arrayindex>`__ and `et.gentity_set() <functions.html#et-gentity-set-entnum-fieldname-arrayindex-value>`__ functions.
Player fields
=============
================================= =========== ======== ==================================
Name Type Flag Description
================================= =========== ======== ==================================
noclip INT RO
lastKillTime INT RO
saved_persistant INT_ARRAY RO
lastConstructibleBlockingWarnTime INT RO
landmineSpottedTime INT RO
lasthurt_client INT RO
lasthurt_mod INT RO
lasthurt_time INT RO
respawnTime INT RO
inactivityTime INT RW
inactivityWarning INT RW
PCSpecialPickedUpCount INT RO
combatState INT RO
deathAnimTime INT RO
deathTime INT RO
disguiseClientNum INT RO
medals INT RO
acc FLOAT RO
hspct FLOAT RO
freezed INT RW
constructSoundTime INT RO
pers.connected INT RO
pers.netname STRING NOPTR
pers.localClient INT RW
pers.initialSpawn INT RW
pers.enterTime INT RW
pers.connectTime INT RO
pers.teamState.state INT RW
pers.voteCount INT RW
pers.complaints INT RW
pers.complaintClient INT RW
pers.complaintEndTime INT RW
pers.lastReinforceTime INT RW
pers.applicationClient INT RW
pers.applicationEndTime INT RW
pers.invitationClient INT RW
pers.invitationEndTime INT RW
pers.propositionClient INT RW
pers.propositionClient2 INT RW
pers.propositionEndTime INT RW
pers.autofireteamEndTime INT RW
pers.autofireteamCreateEndTime INT RW
pers.autofireteamJoinEndTime INT RW
pers.lastSpawnTime INT RO
pers.ready INT RW
pers.lastkilled_client INT RO
pers.lastrevive_client INT RO
pers.lastkiller_client INT RO
pers.lastammo_client INT RO
pers.lasthealth_client INT RO
pers.lastteambleed_client INT RO
pers.lastteambleed_dmg INT RO
pers.playerStats.hitRegions INT_ARRAY RO
pers.lastBattleSenseBonusTime INT RO
pers.lastHQMineReportTime INT RO
pers.maxHealth INT RO
pers.playerStats.selfkills INT RO
ps.pm_flags INT RO
ps.pm_time INT RO
ps.eFlags INT RO
ps.weapon INT RO
ps.weaponstate INT RO
ps.stats INT_ARRAY RW
ps.persistant INT_ARRAY RW
ps.ping INT RO
ps.powerups INT_ARRAY RW
ps.origin VEC3 RW
ps.ammo INT_ARRAY RW
ps.ammoclip INT_ARRAY RW
ps.classWeaponTime INT RW
sess.sessionTeam INT RW
sess.spectatorTime INT RW
sess.spectatorState INT RW
sess.spectatorClient INT RW
sess.playerType INT RW
sess.playerWeapon INT RW
sess.playerWeapon2 INT RW
sess.spawnObjectiveIndex INT RW
sess.latchPlayerType INT RW
sess.latchPlayerWeapon INT RW
sess.latchPlayerWeapon2 INT RW
sess.ignoreClients INT_ARRAY RW
sess.muted INT RW
sess.skillpoints FLOAT_ARRAY RO
sess.startskillpoints FLOAT_ARRAY RO
sess.startxptotal FLOAT RO
sess.skill INT_ARRAY RW
sess.rank INT RW
sess.medals INT_ARRAY RW
sess.referee INT RW
sess.rounds INT RW
sess.spec_invite INT RW
sess.spec_team INT RW
sess.kills INT RW
sess.deaths INT RW
sess.gibs INT RW
sess.self_kills INT RW
sess.team_kills INT RW
sess.team_gibs INT RW
sess.damage_given INT RW
sess.damage_received INT RW
sess.team_damage_given INT RW
sess.team_damage_received INT RW
sess.time_axis INT RW
sess.time_allies INT RW
sess.time_played INT RW
sess.mu FLOAT RW
sess.sigma FLOAT RW
sess.oldmu FLOAT RW
sess.oldsigma FLOAT RW
sess.uci INT RW
sess.aWeaponStats WEAPONSTAT RW
================================= =========== ======== ==================================
.. note:: All the session `sess.*` fields will return `nil` unless the entity is associated with a client slot.
.. note:: All array variables need to be get or set with an additional parameter.
Entity fields
=============
================================= =========== ======== ==================================
Name Type Flag Description
================================= =========== ======== ==================================
activator ENTITY RO
chain ENTITY RW
classname STRING RW
clipmask INT RW
closespeed FLOAT RW
count INT RW
count2 INT RW
damage INT RW
deathType INT RW
delay FLOAT RW
dl_atten INT RW
dl_color VEC3 RW
dl_shader STRING RO
dl_stylestring STRING RO
duration FLOAT RW
end_size INT RW
enemy ENTITY RW
entstate INT RO
flags INT RO
harc FLOAT RW
health INT RW
inuse INT RW
isProp INT RO
item STRING RO
key INT RW
message STRING RW
methodOfDeath INT RW
mg42BaseEnt INT RW
missionLevel INT RW
model STRING RO
model2 STRING RO
nextTrain ENTITY RW
noise_index INT RW
prevTrain ENTITY RW
props_frame_state INT RO
r.absmax VEC3 RO
r.absmin VEC3 RO
r.bmodel INT RO
r.contents INT RW
r.currentAngles VEC3 RW
r.currentOrigin VEC3 RW
r.eventTime INT RW
r.linked INT RO
r.maxs VEC3 RW
r.mins VEC3 RW
r.ownerNum INT RW
r.singleClient INT RW
r.svFlags INT RW
r.worldflags INT RO
radius INT RW
random FLOAT RW
rotate VEC3 RW
s.angles VEC3 RW
s.angles2 VEC3 RW
s.apos TRAJECTORY RW
s.clientNum INT RW
s.constantLight INT RW
s.density INT RW
s.dl_intensity INT RW
s.dmgFlags INT RW
s.eFlags INT RW
s.eType INT RW
s.effect1Time INT RW
s.effect2Time INT RW
s.effect3Time INT RW
s.frame INT RW
s.groundEntityNum INT RO
s.loopSound INT RW
s.modelindex INT RW
s.modelindex2 INT RW
s.number INT RO
s.onFireEnd INT RW
s.onFireStart INT RW
s.origin VEC3 RW
s.origin2 VEC3 RW
s.pos TRAJECTORY RW
s.powerups INT RO
s.solid INT RW
s.teamNum INT RW
s.time INT RW
s.time2 INT RW
s.weapon INT RO
s.eventParm INT RW
scriptName STRING RO
spawnflags INT RO
spawnitem STRING RO
speed INT RW
splashDamage INT RW
splashMethodOfDeath INT RW
splashRadius INT RW
start_size INT RW
tagName STRING NOPTR+RO
tagParent ENTITY RW
takedamage INT RW
tankLink ENTITY RW
target STRING RW
TargetAngles VEC3 RW
TargetFlag INT RO
targetname STRING RO
teamchain ENTITY RW
teammaster ENTITY RW
track STRING RO
varc FLOAT RW
wait FLOAT RW
waterlevel INT RO
watertype INT RO
================================= =========== ======== ==================================

665
functions.rst Normal file
View file

@ -0,0 +1,665 @@
=========
Functions
=========
Here are all available Lua functions of the `et` library.
Modules
=======
et.RegisterModname( modname )
-----------------------------
Registers a descriptive name for this mod.
* `modname` is the name to register the Lua module.
vmnumber = et.FindSelf()
------------------------
Returns the assigned Lua VM slot number.
* `vmnumber` is the returned slot number assigned to this Lua VM.
modname, signature = et.FindMod( vmnumber )
-------------------------------------------
Returns the name and SHA1 signature for the mod loaded in a VM slot.
* `vmnumber` is the VM slot number of the Lua module.
* `modname, signature` is the returned registered module's name and its SHA-1 signature. Returns `nil, nil` if the VM slot is invalid.
success = et.IPCSend( vmnumber, message )
-----------------------------------------
Sends the string `message` to the mod in the VM slot indicated by `vmnumber`.
* `vmnumber` is the VM slot number of the Lua module to send a message to.
* `message` is the message string to sent to the Lua module.
Returns 1 if the message is sent successfully, and 0 if it fails.
.. note:: The mod receiving message must have an `et_IPCReceive() <sample.html>`__ callback.
.. tip:: See the `Inter Process Communication (IPC) <sample.html>`__ for an example of communication between different loaded Lua modules.
Printing
========
et.G_Print( text )
------------------
Prints text to the server console.
* `text` is the printed string.
et.G_LogPrint( text )
---------------------
Prints text to the server console and writes it to the server log.
* `text` is the printed and logged string.
Argument handling
=================
These functions are to be used within the `command callback <callbacks.html#commands>`__ functions.
args = et.ConcatArgs( index )
-----------------------------
Returns all arguments beginning concatenated into a single string.
* `index` is the index of the first argument in the concatenated string.
* `args` is the returned concatenated string.
argcount = et.trap_Argc()
-------------------------
Returns the number of command line arguments in the server command.
* `argcount` is the returned count of arguments.
arg = et.trap_Argv( index )
---------------------------
Returns the contents of the command line argument.
* `index` is the index of the argument to return.
* `arg` is the returned argument.
Cvars
=====
cvarvalue = et.trap_Cvar_Get( name )
------------------------------------
Returns the value of the given cvar.
* `name` is the name of the cvar.
* `cvarvalue` is the returned string containing the value. If there is no cvar with the given name, the returning string has zero length.
et.trap_Cvar_Set( name, cvarvalue )
-----------------------------------
Sets value to a cvar.
* `name` is the name of the cvar to set.
* `cvarvalue` is the new value for the cvar.
Configstrings
=============
configstring = et.trap_GetConfigstring( index )
-----------------------------------------------
Returns content of the configstring index.
* `index` is the index of the configstring. See `et.CS_* constants <constants.html#cs-constants>`__ for possible values.
* `configstring` is the returned string containing the full configstring.
et.trap_SetConfigstring( index, value )
---------------------------------------
Sets the full configstring.
* `index` is the configstring index. See `et.CS_* constants <constants.html#cs-constants>`__ for possible values.
* `value` is the full configstring to set.
Server
======
et.trap_SendConsoleCommand( when, command )
-------------------------------------------
Sends command to the server console.
* `when` tells when the command is executed. See `et.EXEC_* constants <constants.html#exec-constants>`__ for possible values.
* `command` is the full command to execute.
Clients
=======
et.trap_SendServerCommand( clientnum, command )
-----------------------------------------------
Sends the command command to the client clientnum. If clientnum is -1, the command is broadcast to all connected clients.
.. tip:: See the `SendServerCommand <sample.html>`__ page for a detailed example usage of possible commands.
et.trap_DropClient( clientnum, reason, bantime )
-------------------------------------------------
Disconnects client from the server.
* `clientnum` is the slot number of the client.
* `reason` is the descriptive reason for the kick which is reported to the client.
* `bantime` is the length of the ban in seconds.
clientnum = et.ClientNumberFromString( string )
-----------------------------------------------
Searches for one partial match with player name.
* `string` is a pattern to match against client names.
* `clientnum` is the returned client slot number if one match is found, otherwise `nil` is returned (none or more than one match).
et.G_Say( clientNum, mode, text )
---------------------------------
Sends a chat command on behalf of client.
* `clientnum` is the slot number of the client.
* `mode` is the broadcast mode. See `et.SAY_* constants <constants.html#say-constants>`__.
* `text` is the chat text.
et.MutePlayer( clientnum, duration, reason )
--------------------------------------------
Mutes the specified player.
* `clientnum` is the slot number of the client to mute.
* `duration` is the optional duration of the mute in seconds.
* `reason` is the optional reason of the mute.
et.UnmutePlayer( clientnum )
----------------------------
Unmutes the specified player.
* `clientnum` is the slot number of the client to unmute.
Userinfo
========
userinfo = et.trap_GetUserinfo( clientNum )
-------------------------------------------
Returns the userinfo string of a client.
* `clientnum` is the slot number of the client.
* `userinfo` is the returned string of the specified client.
et.trap_SetUserinfo( clientnum, userinfo )
------------------------------------------
Sets the userinfo string of the client to the specified userinfo.
* `clientnum` is the slot number of the client.
* `userinfo` is the userinfo string that replaces the current userinfo.
.. note:: The `et.ClientUserinfoChanged( clientnum ) <#et-clientuserinfochanged-clientnum>`__ function must be called after this function for the changes to take effect.
et.ClientUserinfoChanged( clientnum )
-------------------------------------
Loads the new userinfo string of the client and sets the client settings to match it.
* `clientnum` is the slot number of the client.
String utility
==============
newinfostring = et.Info_RemoveKey( infostring, key )
----------------------------------------------------
Removes a key and its associated value from an infostring.
* `infostring` is the infostring from which to remove the key.
* `key` is the key to remove.
* `newinfostring` is the returned modified infostring without the key.
newinfostring = et.Info_SetValueForKey( infostring, key, value )
----------------------------------------------------------------
Sets a value in an infostring.
* `infostring` is the original infostring.
* `key` is the key to set.
* `value` is the value to set to the key. If empty, the key is removed from the infostring.
* `newinfostring` is the returned modified infostring.
keyvalue = et.Info_ValueForKey( infostring, key )
-------------------------------------------------
Returns a value from an infostring.
* `infostring` is the infostring from where to search the key.
* `key` is the key which value is returned.
* `keyvalue` is the returned value from the searched key. If key is not present in the infostring, an empty string is returned.
cleanstring = et.Q_CleanStr( string )
-------------------------------------
Returns string stripped of all color codes and special characters.
* `string` is the string to clean.
* `cleanstring` is the returned cleaned string.
Filesystem
==========
fd, len = et.trap_FS_FOpenFile( filename, mode )
------------------------------------------------
Opens a file in the local file system.
* `filename` is the name of the file to open. The file is opened under the current working directory and absolute paths will not work.
* `mode` is the access mode the file is opened. See `et.FS_* constants <constants.html#fs-constants>`__ for possible values.
* `fd, len` are returned descriptor of the file and the length of the file. On error, len returns -1.
filedata = et.trap_FS_Read( fd, count )
---------------------------------------
Reads from an open file.
* `fd` is the descriptor of the file to read.
* `count` is the amount of bytes to read.
* `filedata` is the returned value that have the read bytes.
count = et.trap_FS_Write( filedata, count, fd )
-----------------------------------------------
Writes at the end of an open file.
* `filedata` is a block of bytes to write.
* `count` is the size of the block to write.
* `fd` is the descriptor of the file.
* `count` is the returned amount of bytes written to the file.
et.trap_FS_FCloseFile( fd )
---------------------------
Closes an opened file.
* `fd` is the descriptor of the opened file.
et.trap_FS_Rename( oldname, newname )
-------------------------------------
Renames a file in the local file system.
* `oldname` is the name of the file to rename.
* `newname` is the name the old file name is changed to.
filelist = et.trap_FS_GetFileList( dirname, fileextension )
----------------------------------------------------------------
Retrieves list of files from a directory.
* `dirname` is the name of the directory.
* `filextension` is the file extension of file names to retrieve.
* `filelist` is the returned array of file names strings.
Indexes
=======
soundindex = et.G_SoundIndex( filename )
----------------------------------------
Returns the index to the searched soundfile.
* `filename` is the sound file name that is searched.
* `soundindex` is the returned string index that includes the filename or 0 if not found.
modelindex = et.G_ModelIndex( filename )
----------------------------------------
Returns the index to the searched model.
* `filename` is the name that is searched.
* `modelindex` is the returned string index that included the filename or 0 if not found.
Sound
=====
et.G_globalSound( sound )
-------------------------
Plays a sound to all connected clients.
* `sound` is the name of the sound to play.
et.G_Sound( entnum, soundindex )
--------------------------------
Plays a sound originating from position of an entity.
* `entnum` is the number of the entity which position is used as the sound origin.
* `soundindex` is the index of the sound that is played.
et.G_ClientSound( clientnum, soundindex )
-----------------------------------------
Plays a sound originating from a client entity to the team members of that client.
* `clientnum` is the slot number of the connected player.
* `soundindex` is the index to the sound to play.
Miscellaneous
=============
milliseconds = et.trap_Milliseconds()
-------------------------------------
Returns level time.
* `milliseconds` is the returned time in milliseconds.
success = et.isBitSet( bit, value )
-----------------------------------
Checks bit status of a bitmask value.
* `bit` is the checked bit.
* `value` is the bitmask value.
Returns 1 if the bit is set in the bitmask value, and 0 if it is not.
et.G_Damage( target, inflictor, attacker, damage, dflags, mod )
---------------------------------------------------------------
Damages target entity on behalf of the attacker entity.
* `target` is the entity number to damage.
* `inflictor` is the entity number that does the damage.
* `attacker` is the entity number that causes the `inflictor` entity to cause damage to `target`.
* `damage` is the amount of damage to inflict.
* `dflags` is the type of damage to inflict. See `Damage flags <misc.html#damage-flags>`__ for possible values.
* `mod` is the means of death. See `et.MOD_* constants <constants.html#mod-constants>`__ for possible values.
et.G_AddSkillPoints( clientNum, skill, points )
-----------------------------------------------
Adds points to the client's skill.
* `clientNum` is the slot number of the client.
* `skill` identifies the skill that the points are added to. See `Skill types <misc.html#skill-types>`__ for possible values.
* `points` is the amount of points to add.
et.G_LoseSkillPoints( clientNum, skill, points )
------------------------------------------------
Removes points to the client's skill.
* `clientNum` is the slot number of the client.
* `skill` identifies the skill that the points are removed from. See `Skill types <misc.html#skill-types>`__ for possible values.
* `points` is the amount of points to remove.
et.G_XP_Set ( clientNum , xp, skill, points )
---------------------------------------------
Sets XP of the client.
* `clientNum` is the slot number of the client.
* `xp` is the cumulative number of XP points.
* `skill` identifies the skill that the points are added to. See `Skill types <misc.html#skill-types>`__ for possible values.
* `points` is the amount of points to add.
et.G_ResetXP ( clientNum )
--------------------------
Resets XP of the client.
* `clientNum` is the slot number of the client.
et.AddWeaponToPlayer( clientNum, weapon, ammo, ammoclip, setcurrent )
---------------------------------------------------------------------
Adds a weapon to a client.
* `clientNum` is the slot number of the client.
* `weapon` is the weapon to add. See `et.WP_* constants <constants.html#wp-constants>`__ for possible values.
* `ammon` is the number of ammo to add.
* `ammoclip` is the number of ammo clip to add.
* `setcurrent` sets the weapon as current weapon if 1, or does not select it if 0.
et.RemoveWeaponFromPlayer( clientNum, weapon )
----------------------------------------------
Removes a weapon from a client.
* `clientNum` is the slot number of the client.
* `weapon` is the weapon to add. See `et.WP_* constants <constants.html#wp-constants>`__ for possible values.
Entities
========
entnum = et.G_CreateEntity( params )
------------------------------------
Creates a new entity.
* `params` are mapscript parameters.
* `entnum` is the returned number of the new entity.
et.G_DeleteEntity( params )
---------------------------
Deletes an entity.
* `params` are mapscript parameters.
entnum = et.G_TempEntity( origin, event )
-----------------------------------------
Spawns a new temp entity to a location.
* `origin` is the location the temp entity is placed.
* `event` is the event type of the entity. See `Event types <misc.html#event-types>`__ for possible values.
* `entnum` is the returned the number of the new entity.
et.G_FreeEntity( entnum )
-------------------------
Deletes an entity.
* `entnum` is the entity number.
count = et.G_EntitiesFree()
---------------------------
Calculates all free entities.
* `count` is the returned number of free entities.
.. note:: Free client entities (slots) are not counted.
et.G_SetEntState( entnum, newstate )
------------------------------------
Sets an entity state.
* `entnum` is the entity number.
* `newstate` is the new entity state.
et.trap_LinkEntity( entnum )
----------------------------
Links an entity.
* `entnum` is the entity number to link.
et.trap_UnlinkEntity( entnum )
------------------------------
Unlinks an entity.
* `entnum` is the entity number to unlink.
spawnval = et.G_GetSpawnVar( entnum, key )
------------------------------------------
Returns a value of a spawnvar.
* `entnum` is the entity number of the target.
* `key` is the key for the value to return. See `Entity fields <fields.html#entity-fields>`__ for possible values.
* `spawnval` is the returned spawn value.
et.G_SetSpawnVar( entnum, key, value )
--------------------------------------
Sets spawn value to an entity.
* `entitynum` is the target entity.
* `key` is the key for the value. See `Entity fields <fields.html#entity-fields>`__ for possible values.
* `value` is the new value for the key.
variable = et.gentity_get ( entnum, fieldname, arrayindex )
-----------------------------------------------------------
Returns a field value associated with an entity.
* `entnum` is the number of the entity.
* `fieldname` is the name of the field to get. See `Fields <fields.html>`__ for possible values.
* `arrayindex`, if present, specifies which element of an array entity field to get.
* `variable` is the returned field value. For NULL entities or clients, `nil` is returned.
.. note:: `arrayindex` is required when accessing array type fields. Array indexes start at 0.
et.gentity_set( entnum, fieldname, arrayindex, value )
------------------------------------------------------
Sets a value in an entity.
* `entnum` is the entity number that is manipulated.
* `fieldname` is the name of the field to manipulate. See `Fields <fields.html>`__ for possible values.
* `value` is the new value.
* `arrayindex`, if present, specifies which element of an array entity field to set.
et.G_AddEvent( ent, event, eventparm )
--------------------------------------
Adds an event to the entity event sequence.
* `ent` is the entity which event sequnce is handled.
* `event` is the event to add.
* `eventparm` is optional parameter for the event.
Shaders
=======
et.G_ShaderRemap( oldShader, newShader )
----------------------------------------
Remaps shader.
* `oldShader` is the old shader.
* `newShader` is the new shader.
et.G_ResetRemappedShaders()
---------------------------
Resets remapped shaders.
et.G_ShaderRemapFlush()
-----------------------
Flushes remapped shaders.
et.G_SetGlobalFog( params )
---------------------------
Sets global fog to a specific color and density.
* `params` are mapscript fog parameters.

View file

@ -8,28 +8,40 @@ Legacy Lua API
Welcome to the Legacy Lua API's documentation! Welcome to the Legacy Lua API's documentation!
The **Legacy mod** is the default mod shipped with `ET: Legacy <http://www.etlegacy.com>`_. It supports server-side modifications via the `Lua <http://www.lua.org/>`_ scripting language. The **Legacy mod** is the default mod shipped with `ET: Legacy <http://www.etlegacy.com>`_. It supports server-side modifications via the `Lua <http://www.lua.org/>`_ scripting language, with the Legacy Lua API being the interface for communication between them.
If present, the embedded **Lua 5.3** interpreter will load user-defined scripts from the Legacy directory. It also provides an "et" library of function calls for Lua that allow access to the server engine, and provides callbacks so a server side mod may trigger on specific server events. The embedded **Lua 5.3** interpreter will load user-defined scripts if present in the `Legacy` directory. The Lua API provides an "et" library of `function calls <functions.html>`__ that allow access to the server engine, and also provides `callbacks <callbacks.html>`__ so a server side mod may trigger on specific server events.
For more information about Lua, check out the `Reference Manual <http://www.lua.org/manual/5.3/>`_, the online edition of the book `Programming in Lua <http://www.lua.org/pil/>`_ or the `Lua-users wiki <http://lua-users.org/wiki/>`_. In some cases values can be returned to Legacy mod, whenever something is intercepted (i.e. a command) and prevented to be further handled. This way, new commands can easily be defined or existing ones can be altered.
Through special functions, it is also possible to alter internal structures or entities (manipulate client XP, set and read cvars, remap shaders, etc.).
For example, if a player dies the `et_Obituary( victim, killer, meansOfDeath ) <callbacks.html#et-obituary-target-attacker-meansofdeath>`__ function is executed, and the Lua API allows you to manipulate and control this information.
If you want to see some ET-specific Lua examples, you can check the `ET Legacy Lua scripts <https://github.com/etlegacy/etlegacy-lua_scripts>`_ repository. If you want to see some ET-specific Lua examples, you can check the `ET Legacy Lua scripts <https://github.com/etlegacy/etlegacy-lua_scripts>`_ repository.
Implementation
==============
Legacy's Lua API follows mostly the `ETPub <http://www.etpub.org/>`_ implementation with partial code of the `NoQuarter <http://shitstorm.org/noquarter/>`_ implemention. The ETPub implementation being built to be compatible with `ETPro's Lua <http://wolfwiki.anime.net/index.php/Lua_Mod_API>`_, all scripts written in ETPro's documentation should be valid and more or less compatible with Legacy mod's Lua API.
.. important:: As Legacy uses the newer Lua 5.3, you might want to check the **Incompatibilities with the Previous Version** sections of the `Lua 5.1 <https://www.lua.org/manual/5.1/manual.html#7>`_, `Lua 5.2 <https://www.lua.org/manual/5.2/manual.html#8>`_, and `Lua 5.3 <https://www.lua.org/manual/5.3/manual.html#8>`_ manuals while porting scripts written for other mods.
Contents Contents
-------- ========
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 1
intro standard
cvars cvars
commands commands
functions functions
callbacks callbacks
fields fields
constants constants
misc
database database
sample sample
@ -38,5 +50,4 @@ Indices and tables
------------------ ------------------
* :ref:`genindex` * :ref:`genindex`
* :ref:`search`

View file

@ -1,33 +0,0 @@
============
Introduction
============
Legacy's Lua API is the interface for communication between Lua and Legacy mod.
The basic idea for this Lua API is event-management. After a certain event, the lua-interaction-code in Legacy executes a predefined function, with additional predefined arguments.
For example, if a player dies the `et_Obituary( victim, killer, meansOfDeath ) <callbacks.html#et-obituary-target-attacker-meansofdeath>`__ function is executed. The Lua API allows you to manipulate and control this information.
In some cases you can also return a value to Legacy, whenever you intercepted something (i.e. a command), and prevent Legacy to handle it further.
This way, you can easily define new commands, or alter existing ones. Through special functions, it is also possible to alter Legacy's internal structures or Entities (remap shaders, manipulate client XP, set and read cvars, etc.).
Implementation
==============
Legacy's Lua API follows mostly the `ETPub <http://www.etpub.org/>`_ implementation with partial code of the `NoQuarter <http://shitstorm.org/noquarter/>`_ implemention. The ETPub implementation being built to be compatible with `ETPro's Lua <http://wolfwiki.anime.net/index.php/Lua_Mod_API>`_, all scripts written in ETPro's documentation should be valid and more or less compatible with Legacy mod's Lua API.
.. important:: As Legacy uses the newer Lua 5.3, you might want to check the *Incompatibilities with the Previous Version* sections of the `Lua 5.1 <https://www.lua.org/manual/5.1/manual.html#7>`_, `Lua 5.2 <https://www.lua.org/manual/5.2/manual.html#8>`_, and `Lua 5.3 <https://www.lua.org/manual/5.3/manual.html#8>`_ manuals while porting scripts written for other mods.
Standard libraries
==================
The following standard Lua libraries are initialized by default and available to Legacy Lua scripts:
* `basic <http://www.lua.org/manual/5.3/manual.html#6.1>`_
* `string <http://www.lua.org/manual/5.3/manual.html#6.4>`_
* `table <http://www.lua.org/manual/5.3/manual.html#6.6>`_
* `math <http://www.lua.org/manual/5.3/manual.html#6.7>`_
* `i/o <http://www.lua.org/manual/5.3/manual.html#6.8>`_
* `os <http://www.lua.org/manual/5.3/manual.html#6.9>`_ (available features vary depending on your OS)

14
standard.rst Normal file
View file

@ -0,0 +1,14 @@
==================
Standard libraries
==================
The following standard Lua libraries are initialized by default and available to Legacy Lua scripts:
* `basic <http://www.lua.org/manual/5.3/manual.html#6.1>`_
* `string <http://www.lua.org/manual/5.3/manual.html#6.4>`_
* `table <http://www.lua.org/manual/5.3/manual.html#6.6>`_
* `math <http://www.lua.org/manual/5.3/manual.html#6.7>`_
* `i/o <http://www.lua.org/manual/5.3/manual.html#6.8>`_
* `os <http://www.lua.org/manual/5.3/manual.html#6.9>`_ (available features vary depending on your OS)
.. tip:: For more information about Lua, check out the `Reference Manual <http://www.lua.org/manual/5.3/>`_, the online edition of the book `Programming in Lua <http://www.lua.org/pil/>`_ or the `Lua-users wiki <http://lua-users.org/wiki/>`_.