Lua/Userdata structures

From SRB2 Wiki
< Lua
(Redirected from Line t)
Jump to navigation Jump to search
To do
https://wiki.srb2.org/wiki/User:LJ_Sonik/List_of_outdated_Lua_stuff
To do
Document UDMF-related things.

This article lists all the userdata types available for Lua in SRB2, as well as the variables they contain.

Notes

Refer to this section to help understand the contents of the following tables.

Column headers

  • Name: The name of the variable.
  • Type: The variable's type. See Variable types for a list of possible types.
  • Accessibility: Indicates whether it is possible to read (retrieve) or write (modify) the variable's value. Note that in some cases where the variable is a table or another userdata object, it may be not be possible to change the variable's value (i.e., exchange the table/userdata object for a different one), but it may still be possible to access and modify the variables of the table/userdata object. In these cases, the column makes a distinction between Table/Userdata, which is marked as Read-only, and Table/Userdata variables, which are marked as Read+Write.
  • Description/Notes: Gives additional information about the variable and how it can be used.

Variable types

This section lists the variable types that can appear under the Type column for tables in this article:

Non-numerical

  • string: Plain text (e.g., "sonic" or "eggman").
  • boolean: Can only have the value true or false.
  • function: The variable is a function.
  • userdata (mobj_t, player_t, etc.): One of the userdata types listed in this article.

Basic numerical

Signed:

  • SINT8: Signed 8-bit integer. Values range from -128 to 127.
  • INT16: Signed 16-bit integer. Values range from -32768 to 32767.
  • INT32: Signed 32-bit integer. Values range from -2147483647 to 2147483648.

Unsigned:

  • UINT8: Unsigned 8-bit integer. Values range from 0 to 255.
  • UINT16: Unsigned 16-bit integer. Values range from 0 to 65535.
  • UINT32: Unsigned 32-bit integer. For technical reasons, this is treated as identical to INT32 in Lua.

Derived numerical

These types are identical to one of the basic numerical types listed above, but they use a different name to indicate that the variable's value has a special significance.

  • fixed_t: Same as INT32. This indicates that the variable is a fixed-point number, where multiples of FRACUNIT represent integer numbers and values in-between represent non-integer real numbers (e.g., 3*FRACUNIT/2 represents 1.5). The minimum and maximum values for this type can be expressed as -32768*FRACUNIT and (32768*FRACUNIT)-1. See also Lua/Functions > Fixed-point math.
  • angle_t: Same as UINT32. This indicates that the variable represents an angle, and so should be used with the ANG*/ANGLE_* constants unless otherwise stated. Note that ANGLE_180 and larger (including ANGLE_MAX) will be shown as negative numbers in Lua due to being confined to INT32 limits. See also Lua/Functions > Angle math.
  • tic_t: Same as UINT32. This indicates that the variable represents a time in tics. To convert a time in seconds to tics, multiply the number of seconds by TICRATE (35 tics = TICRATE = 1 second).

Other

  • enum (prefix): The variable is an enumerated type. While it can have any integer value, it is intended to have the value of one of the constants with the prefix prefix. For example, if a variable's type is denoted as "enum (MT_*)", its value is expected to be equal to one of the MT_* constants. The type description will link to an article listing the available constants with the given prefix.
  • type array: This a table containing multiple entries of type type. The type of variables accepted as keys may be given in the Description/Notes column.

General

These userdata types represent components of the game related to Objects or players.

mobj_t

This userdata type represents an Object. In the examples below, mobj is used as the name of the mobj_t variable. An access to a variable var of mobj_t is written as mobj.var.

General
Accessibility Read+Write
Allows custom variables Yes
mobj_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the Object is valid (i.e., still exists), false if not.
x fixed_t Read-only The Object's absolute X position in the map. To modify this value, use a function such as P_SetOrigin or P_MoveOrigin rather than editing it directly.
y fixed_t Read-only The Object's absolute Y position in the map. To modify this value, use a function such as P_SetOrigin or P_MoveOrigin rather than editing it directly.
z fixed_t Read+Write The Object's absolute Z position in the map.
snext mobj_t Userdata: Read-only
Userdata variables: Read+Write
The next Object in the linked list that contains all Objects in the sector.
sprev N/A None Unusable by Lua – this is just the previous Object's snext pointer, which points to this Object.
angle angle_t Read+Write The absolute angle the Object is facing horizontally. 0 is East, ANGLE_90 is North, ANGLE_180 is West, and ANGLE_270 is South.
pitch angle_t Read+Write The absolute angle the Object is facing vertically. 0 is looking at the center, ANGLE_90 is looking up, and -ANGLE_90 is looking down.

Currently only used for Custom Maces, NiGHTS's Hoops and NiGHTS's Bumpers in the base game,

roll angle_t Read+Write The absolute angle the Object is rotated on it's own axis.

Currently has no use in the base game.

spriteroll

(rollangle)

angle_t Read+Write The roll angle of the Object's sprite, that is, the rotation of the sprite on-screen relative to the center of the sprite, if SpriteInfo is not set.

Positive angles roll the sprite in a counterclockwise manner.

Note that mobj.spriteroll and mobj.rollangle are the same variable – they both do the same thing, and changing one will also change the other.

sprite enum (SPR_*) Read+Write The sprite prefix of the sprite the Object is currently displaying. Note that each time an Object switches states, this value is automatically reset to the new state's sprite prefix.
frame UINT32 Read+Write The sprite frame the Object is currently displaying, plus additional frame flags that set further properties of the current state, including full brightness, animation, and translucency (see State > Attributes). Note that each time an Object switches states, this value is automatically reset to the new state's sprite frame.
sprite2 UINT32 Read+Write Usable when sprite is SPR_PLAY. Refers to the current sprite2, plus additional sprite2 flags. Note that each time an Object switches states containing sprite2, this value is automatically reset to the new state's sprite2, otherwise it defaults to 0.
anim_duration UINT16 Read+Write If mobj.frame currently has the frame flag FF_ANIMATE set, this is the duration in tics between each frame in the state's animation. Otherwise, this has no effect on the Object's animation. By default, this is set to the current state's Var2 value.
renderflags UINT32 Read+Write The Object's current render flags (use RF_* constants).
blendmode enum (AST_*) Read+Write The Object's current blend mode, which changes the way it is drawn whenever it has some degree of transparency.
spritexscale fixed_t Read+Write The horizontal scale of the Object's sprite. Is FRACUNIT by default.
spriteyscale fixed_t Read+Write The vertical scale of the Object's sprite. Is FRACUNIT by default.
spritexoffset fixed_t Read+Write The relative horizontal offset of the Object's sprite. This value is added to the sprite's original X offset, except when the Object has the RF_ABSOLUTEOFFSETS render flag, where it's used as the X offset itself.
spriteyoffset fixed_t Read+Write The relative vertical offset of the Object's sprite. This value is added to the sprite's original Y offset, except when the Object has the RF_ABSOLUTEOFFSETS render flag, where it's used as the Y offset itself.
floorspriteslope pslope_t Userdata: Read-only
Userdata variables: Read+Write
The plane on which the Object's sprite will be drawn if it is a sloped floor sprite (RF_SLOPESPLAT). The P_CreateFloorSpriteSlope function is necessary to modify this field. It has no effect on non-sloped floor sprites.
touching_sectorlist N/A None Unusable by Lua – not yet implemented.
subsector subsector_t Read-only The subsector the Object is currently in. To obtain the sector the Object is in, use mobj.subsector.sector. Note that mobj.subsector will be nil for Objects currently being removed.
floorz fixed_t Read-only The absolute "floor" position for the Object, i.e., the height that it considers to be the floor. This can be different from the floor height of the sector the Object is in, for example if it is above a solid FOF. Note that this value is not flipped to a ceiling position if the Object is in reverse gravity.
ceilingz fixed_t Read-only The absolute "ceiling" position for the Object, i.e., the height that it considers to be the ceiling. This can be different from the ceiling height of the sector the Object is in, for example if it is below a solid FOF. Note that this value is not flipped to a floor position if the Object is in reverse gravity.
floorrover ffloor_t Read-only If the floor beneath the Object is a FOF, this index will return that FOF.
ceilingrover ffloor_t Read-only If the ceiling above the Object is a FOF, this index will return that FOF.
radius fixed_t Read+Write The current radius of the Object. When the Object's scale is modified, this is reset to the default radius for the Object's Object type, multiplied with the new scale. Otherwise this is freely adjustable; the minimum value is 0.
height fixed_t Read+Write The current height of the Object. When the Object's scale is modified, this is reset to the default height for the Object's Object type, multiplied with the new scale. Otherwise this is freely adjustable; the minimum value is 0. For players, however, note that this value is continuously corrected/modified to be either the default player height or a specific height used in special situations, such as when spinning.
momx fixed_t Read+Write The Object's current X-axis momentum. Positive values will cause the Object to move to the East, negative values to the West. If you want the Object to move horizontally at an angle that is not entirely along the X-axis, the X-axis momentum should be the desired momentum multiplied by the cosine of the angle – if mom is the desired momentum and h-angle is an angle_t variable representing the angle between the X-axis and Y-axis, then you should set mobj.momx = mom*cos(h-angle). If the movement has a vertical component as well, you need to multiply the cosine of the vertical angle between the Z-axis and the horizontal plane as well – if v-angle is the vertical angle (with a value of 0 being completely horizontal), then you should set mobj.momx = mom*cos(h-angle)*cos(v-angle).
momy fixed_t Read+Write The Object's current Y-axis momentum. Positive values will cause the Object to move to the North, negative values to the South. If you want the Object to move horizontally at an angle that is not entirely along the Y-axis, the Y-axis momentum should be the desired momentum multiplied by the sine of the angle – if mom is the desired momentum and h-angle is an angle_t variable representing the angle between the X-axis and Y-axis, then you should set mobj.momy = mom*sin(h-angle). If the movement has a vertical component as well, you need to multiply the cosine of the vertical angle between the Z-axis and the horizontal plane as well – if v-angle is the vertical angle (with a value of 0 being completely horizontal), then you should set mobj.momy = mom*sin(h-angle)*cos(v-angle).
momz fixed_t Read+Write The Object's current Z-axis momentum. Positive values cause the Object to move upwards, negative values downwards. If you want the movement to have a horizontal component as well, you need to multiply the sine of the vertical angle between the Z-axis and the horizontal plane as well – if mom is the desired momentum and v-angle is an angle_t variable representing the vertical angle (with a value of 0 being completely horizontal), then you should set mobj.momz = mom*sin(v-angle).
pmomz fixed_t Read+Write If the Object is standing on a moving floor, this is the Z-axis momentum of the floor.
tics INT32 Read+Write The current value of the Object's state timer, which decreases by 1 each tic until it reaches 0. At this point, the Object will switch to a new state and this value will be reset to the new state's tic duration. If the value is -1, the current state will have infinite duration.
state enum (S_*) Read+Write The number of the state the Object is currently in. When the value of this is changed, Lua will automatically switch the current state to the new value. mobj.sprite, mobj.frame, mobj.tics will be changed to the new state's sprite, frame and tics values respectively. Additional adjustments may be made for player Objects specifically however (such as player animation speeds and switching to superform states). Switching to the state S_NULL will make the Object disappear, unless it is a player Object (this will cause the game to print an error in the console instead).

Note that changing the value of mobj.state directly in Lua will cause the new state's action to be called automatically. To avoid this, the function P_SetMobjStateNF should be used instead.

flags UINT32 Read+Write The Object's current primary Object flags (use MF_* constants). When the Object is first spawned, this is automatically set to the flags attribute of the Object's Object type. Afterwards it can be adjusted freely.
flags2 UINT32 Read+Write The Object's current secondary Object flags (use MF2_* constants).
eflags UINT16 Read+Write The Object's current extra Object flags (use MFE_* constants).
skin string Read+Write The current skin applied to the Object. For Objects with mobj.sprite set to SPR_PLAY, this will change the appearance of the Object's sprites to that of the character the skin is associated with. This is most commonly used by players, but Extra Life Monitors, Level End Signs, ghost trails, and player thok trails also apply a skin in some situations.
color enum (SKINCOLOR_*) Read+Write The current skin color applied to the Object. When modifying this for regular Objects, this will by default re-map the green range of colors (palette color #s 160–175) to the specified range for the color name given. However, for Objects using SPR_PLAY this can use the current skin's startcolor parameter instead to set the range of colors to color remap.
colorized boolean Read+Write Whether this Object will use the rainbow colormap, tinting the sprite using the color set in color.
drawonlyforplayer player_t Read+Write When set to a player, this Object is only visible for that player and anyone spectating that player.
dontdrawforviewmobj mobj_t Read+Write When set to an Object, mobj will be hidden if mobj.dontdrawforviewmobj is the current camera.

For example, if mobj.dontdrawforviewmobj is set to a player Object, then mobj will be hidden for that player if the player is in first-person.
If a player's awayviewmobj is in use and is set to the same Object as mobj.dontdrawforviewmobj, then mobj is hidden for that player.

bnext mobj_t Userdata: Read-only
Userdata variables: Read+Write
The next Object in the linked list that contains all Objects in the blockmap's current block.
bprev N/A None Unusable by Lua – this is just the previous Object's bnext pointer, which points to this Object.
hnext mobj_t Read+Write The next Object in the "hoop". Originally intended for use with NiGHTS hoops, but is usable for other purposes as well.
hprev mobj_t Read+Write The previous Object in the "hoop". Originally intended for use with NiGHTS hoops, but is usable for other purposes as well.
type enum (MT_*) Read+Write The Object's current Object type. If the value is changed via Lua (which is usually not necessary), mobj.info will automatically be modified at the same time to point to the mobjinfo_t entry for the new Object type.

Important note: For Objects spawned on the map via a Thing, modifying mobj.type to an Object type without a corresponding Thing type (i.e., mobj.info.doomednum has a value of -1) will cause the Object and its Thing to not be linked properly for players joining a netgame. This is because, when creating the $$$.sav file, the networking code incorrectly assumes Objects of these types will never have a corresponding Thing, regardless of the value of mobj.spawnpoint for any particular Object. This results in mobj.spawnpoint for such an Object becoming nil for any players joining the netgame.

info mobjinfo_t Userdata: Read-only
Userdata variables: Read+Write
This points to the mobjinfo_t entry for the Object's Object type, which lists the Object type's properties. As such, it is a shortcut for mobjinfo[mobj.type]. mobj.info itself cannot be changed directly, but if mobj.type is changed, mobj.info will automatically be changed to point to the mobjinfo_t for the new Object type.
health INT32 Read+Write The Object's current amount of health points. When the Object is first spawned, this is automatically set to the spawnhealth attribute of the Object's Object type. Afterwards it can be adjusted freely. For Objects that do not need a health value, this can be used for miscellaneous purposes if desired.
movedir angle_t Read+Write Used to indicate movement direction for A_Chase and related, using the DI_* constants. Otherwise, this can be used for any miscellaneous purpose whatsoever.
movecount INT32 Read+Write Used as a timer before the Object changes direction (usually if mobj.movecount == 0) for A_Chase and related. Otherwise, this can be used for any miscellaneous purpose whatsoever.
target mobj_t Read+Write Generally used as a "target" Object for enemies and similar to chase towards/fire at. Projectiles (Objects with MF_MISSILE) should set this to the Object that fired them, so they cannot harm/crash into the firer. Otherwise, this can be used to link any related Object at all if needed.
reactiontime INT32 Read+Write Used as a timer to delay certain behavior such as attacks (usually if mobj.reactiontime == 0) for a number of actions, including A_Chase and related. When the Object is first spawned, this is automatically set to the reactiontime attribute for the Object type the Object belongs to, but can freely be adjusted afterwards. For players, this is used by some types of teleports to prevent the them from moving until it has reached 0. Otherwise, this can be used for any miscellaneous purpose whatsoever.
threshold INT32 Read+Write Used as a timer before switching targets (usually if mobj.threshold == 0) for A_Chase and related. Otherwise, this can be used for any miscellaneous purpose whatsoever.
player player_t Userdata: Read-only
Userdata variables: Read+Write
For player Objects, this points to the player's properties (e.g., mobj.player.pflags or mobj.player.powers[pw_invulnerability]). It is recommended mobj.player.mo is not used as this just points back to mobj itself, which is redundant. For regular Objects mobj.player will return nil.
lastlook INT32 Read+Write Used to store the player number of the last player targeted for A_Chase and related. Otherwise, this can be used for any miscellaneous purpose whatsoever.
spawnpoint mapthing_t Read+Write For Objects that have been spawned on the map via a Thing (or "spawn point"), this points to the Thing that spawned it by default. If one doesn't exist, this returns nil. However, this variable can be adjusted to point to a different Thing if needed, or to not point to any Thing at all by using mobj.spawnpoint = nil.

Important notes:

  • If an Object belongs to an Object type that does not have a corresponding Thing type number (i.e., mobj.info.doomednum has a value of -1), modifying mobj.spawnpoint to a non-nil value will cause the Object and its Thing to not be linked properly for players joining a netgame. This is because, when creating the $$$.sav file, the networking code incorrectly assumes the Object will never have a corresponding Thing, regardless of the value of mobj.spawnpoint. This results in mobj.spawnpoint for such an Object becoming nil for any players joining the netgame.
  • It is recommended not to make multiple Objects point to the same Thing; for players joining a netgame, $$$.sav will edit mobj.spawnpoint.mobj for all Objects with a mobj.spawnpoint value (except for Object types with no corresponding Thing type; see note above) to point back to mobj, assuming it is the Object that the Thing (mobj.spawnpoint) originally spawned. As mobj.spawnpoint.mobj can only point to one Object at a time, this may result in it pointing to a different Object for players who have just joined the game.
  • For special placement patterns and player starts, mobj.spawnpoint is nil for all Objects spawned by these Thing types. For standard and customizable Hoops, only the hoop center Object will have a non-nil mobj.spawnpoint value.
tracer mobj_t Read+Write Generally used as a secondary "target" Object when mobj.target is already in use. For players, this is often used to link players to the next waypoint to move towards, or the Object the player is being carried by currently.
friction fixed_t Read+Write The Object's current "friction" value. Contrary to real-life friction physics, this is used as a multiplier for mobj.momx and mobj.momy to slow down or speed up the Object when touching the ground. The higher the value of mobj.friction is, the less sludgy/more slippery the floor surface becomes to the Object.
In general:
  • mobj.friction values smaller than FRACUNIT will slow down the Object on the ground.
  • mobj.friction values greater than FRACUNIT will speed up the Object on the ground.
  • mobj.friction values equal to FRACUNIT will not slow down nor speed up the Object at all.

The default mobj.friction value for most Objects is 59392 (hexadecimal: 0xe800), which is equivalent to 29*FRACUNIT/32.

movefactor fixed_t Read+Write In Doom, this variable originally determined an Object's "move factor", which affected how fast a player could move. However, in SRB2, it is instead used for miscellaneous purposes.
fuse INT32 Read+Write Commonly used as a timer before the Object disappears or does something else (see Lua/Hooks > MobjFuse to customize the end effect per Object type), which automatically decreases by 1 each tic until it reaches 0. This is also used for miscellaneous purposes, but this has to be kept the same value always for this to work.
watertop fixed_t Read+Write The absolute "water top" position for the Object. If the Object is currently touching a water FOF, this is the top height of the water FOF. Otherwise, it defaults to mobj.z - 1000*FRACUNIT.
waterbottom fixed_t Read+Write The absolute "water bottom" position for the Object. If the Object is currently touching a water FOF, this is the bottom height of the water FOF. Otherwise, it defaults to mobj.z - 1000*FRACUNIT.
mobjnum N/A None Unusable by Lua – this is used by the networking code to number the Objects in the game inside $$$.sav and so shouldn't be available for Lua usage.
scale fixed_t Read+Write The Object's current scale. The default scale is FRACUNIT. When this is modified by Lua with mobj.scale = newvalue, this will automatically use P_SetScale(mobj, newvalue) internally to adjust the Object's radius and height, but will also change mobj.destscale to match. This means using P_SetScale itself directly is not redundant as it does not affect mobj.destscale internally, allowing gradual scale changes (rather than instantaneous) to be possible.
destscale fixed_t Read+Write The Object's destination scale. If the Object does not currently have this scale, it will gradually change the value of mobj.scale to match this value.
scalespeed fixed_t Read+Write The Object's scale-changing speed, for when the Object is gradually changing scale to reach the value of mobj.destscale. The value used in most cases is FRACUNIT/12, but this can be adjusted to speed up or slow down the scale-changing if needed.
extravalue1 INT32 Read+Write An extra variable that can be used for miscellaneous purposes. Note that some of SRB2's default Objects already use this variable.
extravalue2 INT32 Read+Write An extra variable that can be used for miscellaneous purposes. Note that some of SRB2's default Objects already use this variable. In particular, A_Repeat uses it to set the repeat count.
cusval INT32 Read+Write The Object's "custom value", ported from the v2.0 modification SRB2Morphed. It is unused by SRB2's default Objects and was originally intended as an extra variable for SOC scripting, although it can be used freely for any purpose. Several actions, such as A_CheckCustomValue or A_CusValAction, are available that make use of this value and mobj.cvmem.
cvmem INT32 Read+Write This is intended as a "memory" for the Object's "custom value", allowing you to store a copy of the custom value and then recall it later, after the actual custom value may have changed. The actions A_CheckCusValMemo and A_UseCusValMemo are available for using the custom value memory.
standingslope pslope_t Userdata: Read-only
Userdata variables: Read+Write
The slope that the Object is standing on, or nil if the Object is not standing on a slope.
mirrored boolean Read+Write If true, this Object will be visually mirrored relative to its angle — its left-side sprites will be seen from the right, and vice-versa, and all sprites will be horizontally flipped accordingly.
shadowscale fixed_t Read+Write This controls whether the Object casts a shadow, and how large the shadow is relative to the Object's radius.
dispoffset INT32 Read+Write Used to resolve ordering conflicts when drawing sprites that are in the same position in Software rendering. Sprites with a higher display offset are always drawn in front of sprites with a lower display offset. For instance, the shield orbs all have this set to 1, which means they are always displayed in front of the player when both are in the exact same position. Any integer value can be used here, including negative values; SRB2's Objects only use values up to 2, so anything above that will make the Object take precedence over all of SRB2's default Objects. For most Objects, this can be set to 0.

player_t

This userdata type represents the properties of a player that are independent of the player Object and may carry over between maps. In the examples below, player is used as the name of the player_t variable. An access to a variable var of player_t is written as player.var.

General
Accessibility Read+Write
Allows custom variables Yes
# (Length) #player → player number
#player.powers → total number of powers (23)
player_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the player is valid (i.e., still exists), false if not.
name string Read-only The player's name.
mo mobj_t Read+Write Points to the mobj_t data representing the player Object.

Note: By default, player.mo is a pre-determined Object of the type MT_PLAYER. It is possible to change player.mo to a different Object of any type, but not to nil. However, it is not recommended to use a different Object type than MT_PLAYER – the sprites for the player's character will still appear when walking, running, etc. regardless of the Object's type, and the player may also not behave properly when using particular special map effects if they are not using an MT_PLAYER Object.

If the player is currently a spectator, player.mo will return nil.

realmo mobj_t Read+Write Points to the mobj_t data representing the player Object. However unlike player.mo, it won't return nil if the player is a spectator
cmd ticcmd_t Userdata: Read-only
Userdata variables: Read+Write
Points to the player's button information, i.e., what buttons are currently being pressed. Properties of this can be modified freely, but player.cmd itself cannot be assigned a new value.
playerstate enum (PST_*) Read+Write The player's current player state (either living, dead or respawned).
camerascale fixed_t Read+Write The scale of the third-person camera's distance from the player. This is normally set from the relevant value of a character's S_SKIN.
shieldscale fixed_t Read+Write The scale of this player's Shield orbs. This is normally set from the relevant value of a character's S_SKIN.
viewz fixed_t Read+Write The player's absolute viewing height (or viewing Z position) used by the first-person camera. The game will automatically update this variable every tic; the exact calculation used depends on the player's gravity direction:
  • Normal gravity: player.mo.z + player.viewheight + (bobbing displacement)
  • Reverse gravity: player.mo.z + player.mo.height - player.viewheight + (bobbing displacement)

In both cases, (bobbing displacement) is a displacement value calculated using player.bob, which causes the player's view to appear to "bob" up and down as they walk. It is only added if the player is on the ground and using the first-person camera.

Note: If not modified by Lua, this value is only calculated by the game for local players, and thus isn't network safe. Use at your own risk.

viewheight fixed_t Read+Write The player's relative viewing height used by the first-person camera. This is normally set to the value of the console variable viewheight (scaled to the player's current scale), though sometimes it may be reduced for effects such as landing on the ground – in these cases, player.deltaviewheight is used to gradually return player.viewheight to its normal value.

Note: If not modified by Lua, this value is only calculated by the game for local players, and thus isn't network safe. Use at your own risk.

deltaviewheight fixed_t Read+Write The value to re-adjust player.viewheight by the next tic when it has moved away from the normal height (e.g., when landing on the ground, the viewheight dips a bit then rises back up – both the lowering and rising is done by player.deltaviewheight).

Note: If not modified by Lua, this value is only calculated by the game for local players, and thus isn't network safe. Use at your own risk.

bob fixed_t Read+Write The current range of the player's "bobbing" displacement used by the first-person camera, relative to the base viewing height. The value of this variable normally depends on the player's current speed:
player.bob = (FixedMul(player.rmomx,player.rmomx)­ + FixedMul(player.rmomy­,player.rmomy­))/4

The actual bobbing displacement calculated for player.viewz oscillates between -(player.bob/2) and +(player.bob/2). The maximum value for player.bob itself is 16*FRACUNIT.

Note: If not modified by Lua, this value is only calculated by the game for local players, and thus isn't network safe. Use at your own risk.

viewrollangle angle_t Read+Write The angle at which to roll the player's view — 0 is default, and positive angles roll the view clockwise. This is usually a purely cosmetic effect, but players in NiGHTS mode will have their controls adjusted to the rolled view as well.
aiming angle_t Read+Write The player's current vertical viewing angle; player.aiming = 0 would be facing directly forward, player.aiming > 0 would face upwards, and player.aiming < 0 would face downwards. If player.pflags has the flag PF_FLIPCAM, the value of player.aiming will be flipped whenever the player is given reverse gravity or reverts back to normal gravity.

Note: This value is limited to a maximum of ANGLE_90 -1 in either direction; however, the Software renderer limits what is seen in-game to ANGLE_90 - ANG10.

drawangle angle_t Read+Write The absolute angle at which the player will be drawn. 0 is East, ANGLE_90 is North, ANGLE_180 is West, and ANGLE_270 is South. This is usually purely a visual effect, but has some gameplay implications, such as affecting the direction of Amy's heart projectiles.
rings INT16 Read+Write The amount of rings the player possesses.
spheres INT16 Read+Write The amount of spheres the player possesses.
pity SINT8 Read+Write The player's "pity" hit counter for Match/CTF modes; normally when player.pity reaches 3 or above, this will spawn a Pity Shield around the player and player.pity will be reset to 0.
currentweapon INT32 Read+Write The weapon the player currently has selected to be fired (use WEP_* constants)
ringweapons INT32 Read+Write Contains all the weapons the player is currently able to use, stored as flags (use RW_* constants)
ammoremoval UINT16 Read+Write The amount of ammo being removed from the player's current weapon in Ringslinger modes. This is used in combination with ammoremovaltimer and ammoremovalweapon to display the ammo removal penalty text on the HUD.
ammoremovaltimer tic_t Read+Write The amount of tics to display the ammo removal penalty text on the HUD.
ammoremovalweapon INT32 Read+Write The weapon on which to display the ammo removal penalty text on the HUD.
powers[powername] UINT16 array Table: Read-only
Table entries: Read+Write
A table containing the current values for all powers for the player, where powername is an integer expected to be one of the pw_* constants. The table itself cannot be directly reassigned, but entries in it can be accessed or modified. Use of the values depends on the power selected – see the Powers article for more information on each power.

Example usages of this variable:

player.powers[pw_super] = 0
player.powers[pw_invulnerability] = 20*TICRATE
player.powers[pw_shield] = ($1 & ~SH_NOSTACK)|SH_WHIRLWIND
pflags enum (PF_*) Read+Write Contains the internal player flags currently applied to the player, e.g., PF_JUMPED for when the player is currently jumping.
panim enum (PA_*) Read+Write The player's current animation – in the source code, this variable is frequently used as a shortcut in place of explicitly checking a range of states for each player animation (e.g., PA_WALK covers a state S_PLAY_WALK). This can also be modified to allow for custom states to act as if they were the animation for certain extra effects to work with them. Do note that player.panim is corrected every time the player's state is changed.
flashcount UINT16 Read+Write Amount of time the player is set to the palette set by player.flashpal. P_FlashPal can be used to set this along with player.flashpal.
flashpal UINT16 Read+Write Sets the palette number displayed on the screen for the player. player.flashcount also has to be set for this to have any affect when modified. P_FlashPal can be used to set this along with player.flashcount.
skin INT32 Read-only The player's current skin number. In multiplayer, it is the player's chosen skin selected in the Player Setup menu or through the console variable skin.

It is important to note that player.skin is not the actual skin displayed in-game (which would be player.mo.skin), but a backup skin variable for the game to reference for drawing the lives display and the player's icon on the multiplayer scoreboard.

Use R_SetPlayerSkin to set this to a different value (and also alters player.mo.skin too). However, in almost every case, it's better to use player.mo.skin.

skincolor enum (SKINCOLOR_*) Read+Write The player's "normal" skin color (SKINCOLOR_* constants are to be used). In Single Player, this is basically a copy of the prefcolor set for the player's character; in multiplayer, it is the player's chosen skin color selected in the Player Setup menu or through the console variable color.

It is important to note that player.skincolor is not the actual skin color displayed in-game (which would be player.mo.color), but a backup skin color variable for player.mo.color to reference – this is useful for when the player has turned Super or collected a power-up that changes their skin color (e.g., the Fire Flower, or Mario mode's invincibility), where player.skincolor can then be used to restore the player's "normal" skin color when they are no longer Super or have lost the power-up.

For instance, when the player has collected a Fire Flower powerup, player.mo.color is changed to SKINCOLOR_WHITE, while player.skincolor remains the original skin color the player had before. Afterwards, if the player lost this power-up, player.mo.color is re-set to the value of player.skincolor, restoring the player's original skin color.

availabilities UINT32 Read-only The player's current available unlockable skins unlocked that can use.
score UINT32 Read+Write The player's current score. In most cases, this should be modified using P_AddPlayerScore to account for limits, extra life bonuses, Team Match team scores and NiGHTS mode.
recordscore UINT32 Read+Write The player's current score on the level. Gets reset when changing to a different map or when the player dies and respawns.
dashmode tic_t Read+Write A counter for the player's dashmode ability. By default this counter is incremented by 1 each tic, until it exceeds 3*TICRATE at which point the player will enter into their dashmode state. This variable can be used to check if player is using the ability set by their skin flags SF_DASHMODE (see S_SKIN).

For example: if player.dashmode > 3*TICRATE - This would check if the player is in dashmode.

dashspeed fixed_t Read+Write The thrust speed currently charged up for the player's spindash. Normally, this has a value of zero; while the Spin key control is being held down, however, it will slowly increase its value. During the latter phase, player.mindash and player.maxdash are the minimum and maximum values that player.dashspeed can possibly have. When the Spin key is released, player.dashspeed becomes the final speed the player's spindash is released at; after this occurs, player.dashspeed itself is reset to zero.
normalspeed fixed_t Read+Write The player's current normalspeed value for the character skin used. This is a copy of the skin's actual normalspeed value from the S_SKIN (multiplied by FRACUNIT) and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
runspeed fixed_t Read+Write The player's current runspeed value for the character skin used. This is a copy of the skin's actual runspeed value from the S_SKIN (multiplied by FRACUNIT) and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
thrustfactor UINT8 Read+Write The player's current thrustfactor value for the character skin used. This is a copy of the skin's actual thrustfactor value from the S_SKIN and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
accelstart UINT8 Read+Write The player's current accelstart value for the character skin used. This is a copy of the skin's actual accelstart value from the S_SKIN and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
acceleration UINT8 Read+Write The player's current acceleration value for the character skin used. This is a copy of the skin's actual acceleration value from the S_SKIN and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
charability UINT8 Read+Write The player's current ability value for the character skin used (CA_* constants should be used). This is a copy of the skin's actual ability value from the S_SKIN and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
charability2 UINT8 Read+Write The player's current ability2 value for the character skin used (CA2_* constants should be used). This is a copy of the skin's actual ability2 value from the S_SKIN and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
charflags UINT32 Read+Write The player's current flags value for the character skin used (SF_* constants should be used, combined together as flags). This is a copy of the skin's actual flags value from the S_SKIN and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
thokitem enum (MT_*) Read+Write The player's current thokitem value for the character skin used. This is a copy of the skin's actual thokitem value from the S_SKIN (unless it was set to -1, which will default to MT_THOK) and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
spinitem enum (MT_*) Read+Write The player's current spinitem value for the character skin used. This is a copy of the skin's actual spinitem value from the S_SKIN (unless it was set to -1, which will default to MT_THOK) and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
revitem enum (MT_*) Read+Write The player's current revitem value for the character skin used. This is a copy of the skin's actual revitem value from the S_SKIN (unless it was set to -1, which will default to MT_THOK) and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
followitem enum (MT_*) Read+Write The Object type of this player's followitem.
followmobj mobj_t Read+Write This serves as a pointer to the actual object being used as the player's followitem.
actionspd fixed_t Read+Write The player's current actionspd value for the character skin used. This is a copy of the skin's actual actionspd value from the S_SKIN (multiplied by FRACUNIT) and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
mindash fixed_t Read+Write The player's current mindash value for the character skin used. This is a copy of the skin's actual mindash value from the S_SKIN (multiplied by FRACUNIT) and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
maxdash fixed_t Read+Write The player's current maxdash value for the character skin used. This is a copy of the skin's actual maxdash value from the S_SKIN (multiplied by FRACUNIT) and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
jumpfactor fixed_t Read+Write The player's current jumpfactor value for the character skin used. This is a copy of the skin's actual jumpfactor value from the S_SKIN (multiplied by FRACUNIT) and can be modified freely, keeping in mind it will be reset whenever the skin is switched.
height fixed_t Read+Write The standing height for this player's skin, at default scale. Use the P_GetPlayerHeight function to get the player's height at their current scale.
spinheight fixed_t Read+Write The spinning height for this player's skin, at default scale. Use the P_GetPlayerSpinHeight function to get the player's height at their current scale.
lives SINT8 Read+Write The player's current lives count.
continues SINT8 Read+Write The player's current continues count.
xtralife SINT8 Read+Write The ring extra life bonus counter, used to check how many extra lives have been given from collecting 100 rings so that it can stop rewarding them after a certain amount (set by MaxXtraLife in the MainCfg block).
gotcontinue UINT8 Read+Write Used in NiGHTS special stages to signify whether the player has collected a continue or not from the current map. This is used as a boolean despite being defined as an integer.
speed fixed_t Read+Write The absolute "real" speed the player is currently moving at in any direction. This is calculated using player.rmomx and player.rmomy normally – however, when playing as NiGHTS Super Sonic this is handled completely differently. Modifying this will not change the player's actual speed (modify player.mo.momx and player.mo.momy to do this).
secondjump UINT8 Read+Write Used by some abilities (Float, Slow fall and Air drill) to set what state in using an ability during a jump the player is in:
  • CA_FLOAT: 0 = ability not used yet; 1 = jump button held; 2 = ability has already been used.
  • CA_SLOWFALL: 0 = ability not used yet; 1 = jump button held.
  • CA_AIRDRILL: Increases when spin button is held to speed up falling down during use of the ability.
fly1 UINT8 Read+Write Used by CA_FLY/CA_SWIM abilities (the non-multiability versions) to boost the player up for as long as player.fly1 is not 0.
scoreadd UINT8 Read+Write The player's combo bonus counter. Goes up by one every time an enemy is hurt, the higher this gets the greater the score bonus for destroying enemies given. Normally resets to 0 when the player is touching the ground (unless invincibility is being used) or climbing a wall.
glidetime tic_t Read+Write The player's glide timer, the amount of time the player has been gliding for. Used to gradually speed up the horizontal gliding thrust over time.
climbing UINT8 Read+Write Used by the climbing ability to determine what state of climbing the player is currently in:
  • player.climbing == 0: not climbing
  • player.climbing == 1: climbing
  • player.climbing > 1: the player thrusts in the direction they are facing to press against the wall, and player.climbing decreases until it reaches 1
deadtimer INT32 Read+Write The player's death timer, the amount of time the player has been dead for. Used to automatically trigger effects after some time such as respawning, switching to the continue screen, changing back to the map's usual music, or just ending the game.
exiting tic_t Read+Write The player's "exiting" timer, or the amount of time left in tics until the level automatically ends. By default player.exiting is set to 0, to mark that the player is not currently "exiting" the level. When it is set to a non-zero value, the following effects occur:
  • The player becomes invincible but unable to move.
  • The camera moves to a larger distance away from the player (except when playing as NiGHTS Super Sonic).
  • If playing as NiGHTS Super Sonic in a NiGHTS level, the player will rise up towards the ceiling and rotate constantly.
  • Lastly, player.exiting itself will automatically decrease over time until it reaches the value 2, after which the level will automatically be finished.

In multiplayer, however, the last of these effects differ depending on the value of playersforexit – if set to all, all living players are required to be in an "exiting" state (i.e., they must all have a non-zero player.exiting value) before the level can end; if set to one, the level will automatically finish for everyone regardless.

For reference, P_DoPlayerExit by default sets player.exiting to a value of (14*TICRATE)/5 + 1 (99 tics, or about 2.8 seconds). If the gametype is Race or Competition and all players have finished, a value of 3*TICRATE (105 tics, or 3 seconds) is given instead.

homing UINT8 Read+Write The player's homing timer, for CA_HOMINGTHOK. This will decrease until it reaches 0. For as long as player.homing is > 0 the player will be able to home in on a set target enemy, but once player.homing reaches 0 this will stop.
skidtime tic_t Read+Write The player's skidding timer, for when the player skids to slow down or land from gliding. This will decrease until it reaches 0. For as long as player.skidtime is > 0 the skidding sound is played and skid particles will be spawned behind the player, and for regular skidding this will freeze the state to one of the walking states, but once player.skidtime reaches 0 this will stop.
cmomx fixed_t Read+Write The player's "conveyor" momx, i.e., the x-momentum from conveyor belts, wind, or currents.
cmomy fixed_t Read+Write The player's "conveyor" momy, i.e., the y-momentum from conveyor belts, wind, or currents.
rmomx fixed_t Read+Write The player's "real" momx, i.e., the x-momentum from the player themselves (player.mo.momx - player.cmomx). Modifying this will not change the player's actual x-momentum (modify player.mo.momx to do this).
rmomy fixed_t Read+Write The player's "real" momy, i.e., the y-momentum from the player themselves (player.mo.momy - player.cmomy). Modifying this will not change the player's actual y-momentum (modify player.mo.momy to do this).
numboxes INT16 Read+Write Competition mode counter for the number of monitors the player has broken.
totalring INT16 Read+Write Competition mode counter for the number of rings the player has collected in total during the level. (When rings are lost this is not affected)
realtime tic_t Read+Write The "real" time displayed in the player's HUD. In most gametypes, there is normally no difference between the values of this and leveltime (i.e., player.realtime == leveltime). However, in Race and Competition modes, the 4-second pre-timer means this variable has to start at zero 4 seconds after the level has loaded (i.e., player.realtime == leveltime - 4*TICRATE instead).

Note that when the player has finished the level, player.realtime will stop increasing, marking the time the player finished the level at. This final value is then used by the game for awards or bonuses, depending on the game mode or gametype:

  • If in Single Player or Cooperative, it will then be used by the game to calculate the time bonus, if it is awarded in the level.
  • If in Race, it is compared with that of other players' to calculate the winners of the round.
  • If in Competition, it is compared with that of other players' to calculate who gets the point for the Time category.
  • If in Record Attack, it is saved as the time the replay finished at.
laps UINT8 Read+Write Used in Circuit Race maps to count the current number of laps the player has passed.
ctfteam INT32 Read+Write Used in Team Match/CTF to determine which team the player is in:
  • 0 = spectator
  • 1 = red team
  • 2 = blue team
gotflag UINT16 Read+Write Used in CTF to determine which flag the player is carrying:
  • 0 – no flags
  • 1 (or GF_REDFLAG) – carrying the red flag
  • 2 (or GF_BLUEFLAG) – carrying the blue flag
weapondelay INT32 Read+Write The player's weapon delay timer; the player cannot shoot again until this has fallen back to 0. This is set whenever a player has fired a weapon to cap the player's firing rate.
tossdelay INT32 Read+Write The player's flag/emerald toss delay timer; the player cannot toss or collect flags/emeralds again until this has fallen back to 0. This is set whenever a player tosses a flag or emeralds, to prevent the player from accidentally collecting them again as soon as they are thrown.
starpostx INT16 Read+Write The saved x-position for the last checkpoint the player has touched, to be used when the player respawns at the checkpoint after dying.
starposty INT16 Read+Write The saved y-position for the last checkpoint the player has touched, to be used when the player respawns at the checkpoint after dying.
starpostz INT16 Read+Write The saved z-position for the last checkpoint the player has touched, to be used when the player respawns at the checkpoint after dying.
starpostnum INT32 Read+Write The saved starpost number for the last checkpoint the player has touched. Used to prevent the player from skipping starposts in Circuit mode maps, as they need to touch every single starpost number in order before completing a lap.
starposttime tic_t Read+Write The saved level time for the last checkpoint the player has touched, to be used for resetting the level time to a particular time when the player respawns at a starpost after dying.
starpostangle angle_t Read+Write The saved angle for the last checkpoint the player has touched, to be used when the player respawns at the checkpoint after dying.
starpostscale fixed_t Read+Write The saved scale for the last checkpoint the player has touched, to be used when the player respawns at the checkpoint after dying.
angle_pos angle_t Read+Write Used in NiGHTS mode for getting the current angle between the player and the axis the player is circling around.
old_angle_pos angle_t Read+Write Used in NiGHTS mode for getting the previous angle between the player and the axis the player is circling around.
axis1 mobj_t Read+Write Used in NiGHTS mode as a pointer to the first of 2 axis transfer points the player is travelling between.
axis2 mobj_t Read+Write Used in NiGHTS mode as a pointer to the second of 2 axis transfer points the player is travelling between.
bumpertime tic_t Read+Write The player's bumper timer, for when the player has just hit a NiGHTS Bumper. This will decrease until it reaches 0. This is used to prevent the player from continuously touching the same bumper, so the player can be sprung away from it.
flyangle INT32 Read+Write Used in NiGHTS mode to determine the player's current horizontal flying angle (values will range from 0 to 359). This is also used by CA_AIRDRILL to determine the thrust angle, eventually pointing downwards for falling down.
drilltimer tic_t Read+Write Used in NiGHTS mode as a drilling timer, mainly for handling which drilling sound to use and when. This will decrease towards 0 whenever the player is drilling, but may not necessarily be at 0 when not drilling.
linkcount INT32 Read+Write Used in NiGHTS mode to count the number of links the player has achieved in a chain, so that more points are awarded the longer the link chain is. This resets back to 0 if player.linktimer gets to 0 before the next link however.
linktimer tic_t Read+Write Used in NiGHTS mode as the link timer; the player must touch another hoop, ring or wing logo before player.linktimer reaches 0, otherwise the whole link chain will be broken.
anotherflyangle INT32 Read+Write Used in NiGHTS mode to determine the player's current vertical flying angle (values will range from 0 to 359). This also determines which set of states the player uses for flying or drilling.
nightstime tic_t Read+Write Used in NiGHTS mode as the timer before the player returns back to normal gameplay from NiGHTS gameplay. This will decrease until it reaches 0.
drillmeter INT32 Read+Write Used in NiGHTS mode for the drilling meter, the amount of drilling power the player has left. For as long as this value isn't 0 the player will still be able to drill when NiGHTS Super Sonic.
drilldelay tic_t Read+Write Used in NiGHTS mode as the drilling delay timer. This will decrease until it reaches 0. This is used to prevent the player from drilling again immediately after the player has stopped drilling.
bonustime boolean Read+Write Used in NiGHTS mode to determine whether the player is in "bonus time" mode or not. This will be false normally, but will be true after the player has destroyed the capsule, allowing the player to be rewarded with more points for links before finishing the mare/level.
capsule mobj_t Read+Write Used in NiGHTS mode as a pointer to the current mare's Ideya Capture.
drone mobj_t Read+Write Used in NiGHTS mode as a pointer to the current mare's Ideya Drone.
oldscale fixed_t Read+Write When the player transforms into NiGHTS, this variable stores the player Object's pre-transformation scale. When the player falls back into 3D mode, if the player Object's scale isn't already equal to this value, the player Object's destscale is set to this value.
mare UINT8 Read+Write Used in NiGHTS mode to determine the current mare the player is in.
marelap UINT8 Read+Write Used in NiGHTS mode to determine the current mare lap the player is in.
marebonuslap UINT8 Read+Write Used in NiGHTS mode to determine the current mare lap from bonus time the player is in.
marebegunat tic_t Read+Write Used in NiGHTS mode to save the level time the current mare the player is in started.
startedtime tic_t Read+Write Used in NiGHTS mode to save the starting time for player.nightstime in the current mare. This will be reset for each next mare the player plays through.
finishedtime tic_t Read+Write Used in NiGHTS mode to save the finishing time for player.nightstime for the mare just completed by the player.
lapbegunat tic_t Read+Write Used in NiGHTS mode to determine the tic when the player started the lap in by leveltime.
lapstartedtime tic_t Read+Write Used in NiGHTS mode to determine the tic when the player started the lap in by player.nightstime.
finishedspheres INT16 Read+Write Used in NiGHTS mode to save the finishing sphere count for the for the mare just completed by the player.
finishedrings INT16 Read+Write Used in NiGHTS mode to save the finishing ring count for the for the mare just completed by the player.
marescore UINT32 Read+Write Used in NiGHTS mode to store the player's score in the current mare. In most cases, this should be modified using P_AddPlayerScore to account for limits and continue bonuses.
lastmarescore UINT32 Read+Write Used in NiGHTS mode to store the player's score from the previous mare.
totalmarescore UINT32 Read+Write Used in NiGHTS mode to store the total mare score from all mares.
lastmare UINT8 Read+Write Used in NiGHTS mode to store the previous mare's number.
lastmarelap UINT8 Read+Write Used in NiGHTS mode to store the previous mare's lap.
lastmarebonuslap UINT8 Read+Write Used in NiGHTS mode to store the previous mare's lap from bonus time the player was in.
totalmarelap UINT8 Read+Write Used in NiGHTS mode to store the total mare lap.
totalmarebonuslap UINT8 Read+Write Used in NiGHTS mode to store the total mare lap from bonus time the player is in.
maxlink INT32 Read+Write Used in NiGHTS mode to store the highest link count obtained by the player.
texttimer UINT8 Read+Write Used in NiGHTS mode as a timer before displayed text disappears from the screen. This will decrease until it reaches 0. This is also used to gradually fade away the text on the screen during the last half-second.
textvar UINT8 Read+Write Used in NiGHTS mode to determine the text displayed on the screen, for as long as player.texttimer has not reached 0:
  • 0 = No text
  • 1 = Bonus time start text: "GET TO THE GOAL!" "SCORE MULTIPLIER START!"; also displays "TIME: (finishing time)" "BONUS: (time left * 100)"
  • 2 = "GET (capsule health) RING(S)"; in special stages "SPHERE(S)" replaces "RING(S)"
  • 3 = "GET (capsule health) MORE RING(S)"; in special stages "SPHERE(S)" replaces "RING(S)"
  • 4 = Ending bonuses: "RINGS: (rings)" "BONUS: (rings * 50)" "(score)"; in special stages "ORBS" replaces "RINGS"; in NiGHTS attack mode "* NEW RECORD *" may also be displayed if a new record was obtained.
lastsidehit INT16 Read+Write Used to store the number of the sidedef a character with CA_GLIDEANDCLIMB is currently climbing on. If not currently climbing this is set to -1.
lastlinehit INT16 Read+Write Used to store the number of the linedef a character with CA_GLIDEANDCLIMB is currently climbing on. If not currently climbing this is set to -1.
losstime tic_t Read+Write The player's ring loss timer, used for determining how far spilled rings will be flung depending on how many times within a given period the player has been hit. This will decrease until it reaches 0, but whenever the player's rings are spilled this is increased by 10*TICRATE each time.
timeshit UINT8 Read+Write The counter for the number of times the player has been hurt by something; used for the Guard Bonus at the end of boss levels.
onconveyor INT32 Read+Write When the player is in a sector affected by a pushing or scrolling effect, player.onconveyor will be set to 2 or 4 respectively. player.onconveyor is then used to determine when and whether to set player.cmomx and player.cmomy to 0 or not.
awayviewmobj mobj_t Read+Write Pointer to the player's current alternate view camera Object, this will be the viewpoint of the player for as long as player.awayviewtics has not reached 0.
awayviewtics INT32 Read+Write The player's alternate view camera timer. This will decrease until it reaches 0. Otherwise when player.awayviewtics is set, player.awayviewmobj is the viewpoint of the player. if player.awayviewmobj is not already set when player.awayviewtics is set, this will auto-set player.awayviewmobj to the player itself (player.mo).
awayviewaiming angle_t Read+Write The player's alternate view camera vertical aiming angle. Similar to player.aiming except this applies to the alternative view point rather than the actual player's camera for when the camera switches back.
spectator boolean Read+Write Returns true if the player is a spectator, otherwise this will return false.
outofcoop boolean Read+Write Determines if the player has a Game Over or failed the Special Stage.
bot UINT8 Read-only Determines whether the player is a bot or not:
  • 0 (or BOT_NONE) – The player is a normal player
  • 1 (or BOT_2PAI) – The player is a bot player currently using bot AI with Singleplayer Player 2's behaviour
  • 2 (or BOT_2PHUMAN) – The player is a bot player currently controlled by Player 2's controls
  • 3 (or BOT_MPAI) – The player is a bot player currently using bot AI and considered as a individual player
botleader player_t Read+Write Determines bot players what player is actually chasing to. If not set, it will determine it automatically to a nearby player to chase.
lastbuttons UINT16 Read+Write The previous buttons pressed from player_t.cmd.buttons last tic.
blocked boolean Read+Write Whether or not player's movement was blocked due to a solid wall or object, it automatically clears each player think.

At the moment, this variable is not used at all by the vanilla game. And can be freely used by modders.

jointime tic_t Read+Write The amount of time the player has been in-game, and even counts up when the game is paused.
quittime tic_t Read+Write The amount of time the user has been disconnected, or zero if the user is currently connected.
fovadd fixed_t Read+Write The amount to add to the FOV in the OpenGL renderer. This is automatically corrected every tic so you will need to set this continually for any real effect.

Note: If not modified by Lua, this value is only calculated by the game locally if the OpenGL renderer is being used and gr_fovchange is turned on (otherwise, it is set to zero), and thus isn't network safe. Use at your own risk.

ping UINT32 Read-only The amount of ping the player has in miliseconds while connected to a netgame.

ticcmd_t

This userdata type represents a player's current button information, i.e., what buttons are being pressed currently. In the examples below, cmd is used as the name of the ticcmd_t variable. An access to a variable var of ticcmd_t is written as cmd.var.

General
Accessibility Read+Write
Allows custom variables No
ticcmd_t structure
Name Type Accessibility Description/Notes
forwardmove SINT8 Read+Write Value related to forwards/backwards buttons; positive values move the player forward, negative values move the player backwards. Ranges from -50 to 50.
sidemove SINT8 Read+Write Value related to strafe left/right buttons; positive values move the player right, negative values move the player left. Ranges from -50 to 50.
angleturn INT16 Read+Write Value related to turn left/right buttons; to use as angle_t this needs to be shifted up by 16 bits (cmd.angleturn<<16 or cmd.angleturn*65536).
aiming INT16 Read+Write Value related to look up/down buttons; to use as angle_t this needs to be shifted up by 16 bits (cmd.aiming<<16 or cmd.aiming*65536).
buttons UINT16 Read+Write Contains flags representing buttons currently pressed (BT_* constants should be used).
latency UINT8 Read-only The amount of tics it took to receive the player's ticcmd up to 12 tics.

skin_t

This userdata type represents the properties of a character skin, which are defined in a character's S_SKIN lump. In the examples below, skin is used as the name of the skin_t variable. An access to a variable var of skin_t is written as skin.var.

General
Accessibility Read-only
Allows custom variables No
# (Length) #skin → skin number
#skin.soundsid → total number of skin sounds (21)
skin_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the skin is valid (i.e., it exists), false if not.
name string Read-only Returns the internal name string for the skin set by the S_SKIN (e.g., skins["sonic"].name would return "sonic").
spritedef N/A None Unusable by Lua – not yet implemented
wadnum N/A None Unusable by Lua – not network safe, may differ between clients due to music wads
flags enum (SF_*) Read-only Returns the flags given to the skin by the S_SKIN.
realname string Read-only Returns the displayed name string for the skin set by the S_SKIN (e.g., skins["sonic"].realname would return "Sonic").
hudname string Read-only Returns the HUD name string for the skin set by the S_SKIN (e.g., skins["knuckles"].hudname would return "K.T.E").
ability UINT8 Read-only Returns the primary ability number for the skin set by the S_SKIN. (see CA_* constants)
ability2 UINT8 Read-only Returns the secondary ability number for the skin set by the S_SKIN. (see CA2_* constants)
thokitem INT32 Read-only Returns the thok item Object type for the skin set by the S_SKIN. (note that this can be -1, which is expected to be changed to MT_THOK by default; otherwise, see MT_* constants)
spinitem INT32 Read-only Returns the spin item Object type for the skin set by the S_SKIN. (note that this can be -1, which is expected to be changed to MT_THOK by default; otherwise, see MT_* constants)
revitem INT32 Read-only Returns the rev item Object type for the skin set by the S_SKIN. (note that this can be -1, which is expected to be changed to MT_THOK by default; otherwise, see MT_* constants)
followitem INT32 Read-only Returns the follow item Object type for the skin set by the S_SKIN (see MT_* constants).
actionspd fixed_t Read-only Returns the ability speed for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
mindash fixed_t Read-only Returns the minimum spindashing speed for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
maxdash fixed_t Read-only Returns the maximum spindashing speed for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
normalspeed fixed_t Read-only Returns the maximum movement speed for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
runspeed fixed_t Read-only Returns the speed to switch to running animations for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
thrustfactor UINT8 Read-only Returns the thrust factor value for the skin set by the S_SKIN.
accelstart UINT8 Read-only Returns the starting acceleration value for the skin set by the S_SKIN.
acceleration UINT8 Read-only Returns the acceleration value for the skin set by the S_SKIN.
jumpfactor fixed_t Read-only Returns the jump thrust factor for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
radius fixed_t Read-only Returns the radius value of a hitbox for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
height fixed_t Read-only Returns the height value of a hitbox for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
spinheight fixed_t Read-only Returns the spinheight of a hitbox for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
shieldscale fixed_t Read-only Returns the scale of a shield's sprite size for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
camerascale fixed_t Read-only Returns the scale of the camera's position for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
starttranscolor UINT8 Read-only Returns the starting palette color # for the changeable 16-color range for the skin set by the S_SKIN (startcolor).
prefcolor UINT8 Read-only Returns the default skincolor for use in Single player for the skin set by the S_SKIN. (see SKINCOLOR_* constants).
prefoppositecolor UINT16 Read-only Returns the skincolor for the signpost background for the skin set by the S_SKIN. (see SKINCOLOR_* constants).
supercolor UINT16 Read-only Returns the default skincolor for a character's Super form for the skin set by the S_SKIN. (see SKINCOLOR_* constants).
highresscale fixed_t Read-only Returns the relative scale to display sprites at for the skin set by the S_SKIN (this will be the S_SKIN's value multiplied by FRACUNIT).
contspeed UINT8 Read-only Returns the value for the continue screen animation speed for the skin set by the S_SKIN.
contangle UINT8 Read-only Returns the value for the inital angle on the continue screen for the skin set by the S_SKIN.
availability UINT8 Read-only Returns the value for the unlockable entry required to access and play a character for the skin set by the S_SKIN.
soundsid[SKSNAME] enum (sfx_*) array Read-only A table containing all of the corresponding sound numbers for all skinsound slots for the skin, where SKSNAME is an integer that is expected to be one of the SKS* constants. For example, skins["sonic"].soundsid[SKSTHOK] returns sfx_thok, the default sound for the SKSTHOK skinsound slot; for custom characters who may have a custom sound set for any of the skin sounds, this returns the sound number for the custom sound instead.
sprites skin_t.sprites[] Read-only A table containing all of the corresponding sprites for the skin, where it's index it's one of the SPR2_* constants. For example, skins["sonic"].sprites[SPR2_STND] returns a skin_t.sprites[] userdata..

Note: Using SPR2_STND gives a warning instead due to a bug currently present.

supername string Read-only Returns the displayed super form name string for the skin set by S_SKIN (e.g skins["sonic"].supername would return "Super Sonic")

skin_t.sprites

This userdata type represents the table structure of the Skin's sprites. In the examples below, sprites is used as the name of the skin_t.sprites[] variable. An access to a variable var of skin_t.sprites is written as sprites.var.

General
Accessibility Read-only
Allows custom variables No
# (Length) #sprites → Number of sprites
skin_t structure
Name Type Accessibility Description/Notes
numframes number Read-only Returns the number of frames this sprite has.

SOC

These userdata types represent components of the game that can also be modified by SOC.

mobjinfo_t

See also: Object > Object type attributes

This userdata type represents the properties of an Object type. In the examples below, info is used as the name of the mobjinfo_t variable. An access to a variable var of mobjinfo_t is written as info.var.

General
Accessibility Read+Write
Allows custom variables Yes
# (Length) #info → Object type number
mobjinfo_t structure
Name Type Accessibility Description/Notes
doomednum INT32 Read+Write MapThingNum: The Thing type number, should be a number between 1 and 4095. If set to -1, the Object type cannot be placed through Things on the map.
spawnstate enum (S_*) Read+Write SpawnState: The state that this type of Object calls when it is spawned. Its duration may not be 0. If the SpawnState has an action, it will not be performed when the Object is first spawned unless the MF_RUNSPAWNFUNC flag is set on the Object. If the SpawnState is called again after that, however, the action will be performed even without the flag.
spawnhealth INT32 Read+Write SpawnHealth: The initial value for the health variable for mobj_t.
seestate enum (S_*) Read+Write SeeState: Called once an Object spots a player, which can be done with the action A_Look and certain actions that are made specifically for some of SRB2's specific enemies.
seesound enum (sfx_*) Read+Write SeeSound: Usually played when the SeeState is executed. A_PlaySeeSound is made specifically to call this sound.
reactiontime INT32 Read+Write ReactionTime: The initial value for the reactiontime variable for mobj_t.
attacksound enum (sfx_*) Read+Write AttackSound: Usually played by certain attack actions for enemies. The action A_PlayAttackSound is made specifically to call this sound.
painstate enum (S_*) Read+Write PainState: The state that Objects with the flag MF_SHOOTABLE go to when they are damaged but not yet dead.
painchance INT32 Read+Write PainChance: Used for miscellaneous purposes and will be unused for most Objects.
painsound enum (sfx_*) Read+Write PainSound: Usually played when the PainState is executed. The action A_Pain is made specifically to call this sound.
meleestate enum (S_*) Read+Write MeleeState: The first of two attack states. Actions call this or MissileState when the Object should attack.
missilestate enum (S_*) Read+Write MissileState: The second of two attack states. Actions call this or MeleeState when the Object should attack.
deathstate enum (S_*) Read+Write DeathState: The state that Objects go to when they are destroyed, i.e., have no health points left. For regular enemies, this sequence of states should eventually point to S_NULL, which is used for Objects that have disappeared.
xdeathstate enum (S_*) Read+Write XDeathState: Usually used as the fleeing state for bosses. It is called by the action A_BossDeath.
deathsound enum (sfx_*) Read+Write DeathSound: Usually played when the DeathState is executed. The action A_Scream is made specifically to call this sound.
speed fixed_t Read+Write Speed: Usage depends on situation; can be just a regular number in some cases, other cases this needs to be a multiple of FRACUNIT
radius fixed_t Read+Write Radius: The initial value for the radius variable for mobj_t. This may also be referenced when an Object's scale is modified.
height fixed_t Read+Write Height: The initial value for the height variable for mobj_t. This may also be referenced when an Object's scale is modified.
dispoffset INT32 Read+Write DispOffset: Used to resolve ordering conflicts when drawing sprites that are in the same position in Software rendering. Sprites with a higher display offset are always drawn in front of sprites with a lower display offset. For instance, the shield orbs all have this set to 1, which means they are always displayed in front of the player when both are in the exact same position. Any integer value can be used here, including negative values; SRB2's Objects only use values up to 2, so anything above that will make the Object take precedence over all of SRB2's default Objects. For most Objects, this can be set to 0.
mass INT32 Read+Write Mass: Used to determine the damage type of Objects with the primary flags MF_PAIN or MF_MISSILE. Otherwise, it's used for miscellaneous purposes and will be unused for most Objects. It has no relation to the heaviness of an Object.
damage INT32 Read+Write Damage: Used for miscellaneous purposes and will be unused for most Objects.
activesound enum (sfx_*) Read+Write ActiveSound: Used for miscellaneous sounds that are part of an Object's animation. A_PlayActiveSound is made specifically to call this sound.
flags INT32 Read+Write Flags: The initial value given to the flags variable for mobj_t. (Use MF_* constants)
raisestate enum (S_*) Read+Write RaiseState: Used for miscellaneous purposes. For example, A_ShootBullet, A_DropMine and A_JetgShoot all spawn Objects with this state.

state_t

See also: State > Attributes

This userdata type represents the properties of a state. In the examples below, state is used as the name of the state_t variable. An access to a variable var of state_t is written as state.var.

General
Accessibility Read+Write
Allows custom variables No
# (Length) #state → State number
state_t structure
Name Type Accessibility Description/Notes
sprite enum (SPR_*) Read+Write SpriteName: Sprite prefix number used for the state.
frame UINT32 Read+Write SpriteFrame: Frame number of the sprite used for the state; also contains full brightness/translucency information. (See tr_* and FF_* constants)
tics INT32 Read+Write Duration: Duration of the state, in tics. -1 is infinite, 0 is instantaneous.
action function Read+Write Action: The action used by the state, run when an Object switches to the state. Can be set to a pre-existing action, or a custom one created using Lua, or be just nil if none is set. The return value is the function the action calls.
var1 INT32 Read+Write Var1: The Var1 value built-in to be used by state.action, when an Object first switches to the state.
var2 INT32 Read+Write Var2: The Var2 value built-in to be used by state.action, when an Object first switches to the state
nextstate enum (S_*) Read+Write Next: The next state number to go to after the state has finished being used. A state.nextstate of S_NULL will make the Object using the current state be removed from the map when about to switch to the new state.

sfxinfo_t

See also: Sound > Attributes

This userdata type represents the properties of a sound. In the examples below, info is used as the name of the sfxinfo_t variable. An access to a variable var of sfxinfo_t is written as info.var.

General
Accessibility Read+Write
Allows custom variables No
# (Length) #info → Sound number
sfxinfo_t structure
Name Type Accessibility Description/Notes
name string Read-only The name of the sound following the sfx_ prefix, e.g., S_sfx[sfx_thok].name would return "thok".
singular boolean Read+Write Singular: Determines whether only one of the sound can be played at a time (true) or not (false).
priority INT32 Read+Write Priority: The priority of the sound, i.e., this determines how important it is to play this sound; if a sound with a higher priority is playing this sound will be drowned out, otherwise if vice versa this sound will drown out the other instead. Usually a value between 0 and 255.
flags INT32 Read+Write Flags: (Known as "pitch" in the source code) Sets/returns the sound flags set for the sound. (use SF_* constants, not to be confused with skin flags)
skinsound INT32 Read-only Skin sound id number; for sounds that are not changeable by the skin this will be -1. (See SKS* constants)
caption string Read+Write Caption: The caption to display onscreen when this sound is played with Closed Captioning enabled.

hudinfo_t

See also: Heads-up display > HUD item modification

This userdata type represents the properties of a HUD item. In the examples below, info is used as the name of the hudinfo_t variable. An access to a variable var of hudinfo_t is written as info.var.

General
Accessibility Read+Write
Allows custom variables No
# (Length) #info → HUD item number
hudinfo_t structure
Name Type Accessibility Description/Notes
x INT32 Read+Write X coordinate of the HUD item (from the left of the screen). Should be a value between 0 and 320.
y INT32 Read+Write Y coordinate of the HUD item (from the top of the screen). Should be a value between 0 and 200.
f INT32 Read+Write Video flags of the HUD item (use V_* constants). Note that some flags are always applied for certain HUD items in addition to those that you set here.

mapheader_t

This userdata type represents the properties of a level header. In the examples below, mapheader is used as the name of the mapheader_t variable. An access to a variable var of mapheader_t is written as mapheader.var.

General
Accessibility Read-only
Allows custom variables SOC-only
# (Length) #mapheader → Map number
mapheader_t structure
Name Type Accessibility Description/Notes
lvlttl string Read-only LevelName
subttl string Read-only SubTitle
actnum UINT8 Read-only Act
typeoflevel UINT16 Read-only TypeOfLevel, as a set of flags stored in an integer. See TOL_* constants.
nextlevel INT16 Read-only NextLevel, as an integer.
marathonnext INT16 Read-only MarathonNext, as an integer.
keywords string Read-only Keywords
musname string Read-only Music
mustrack UINT16 Read-only MusicTrack
muspos UINT32 Read-only MusicPos
musinterfadeout UINT32 Read-only MusicInterFadeOut
musintername string Read-only MusicInter
muspostbossname string Read-only MusicPostBoss
muspostbosstrack UINT16 Read-only MusicPostBossTrack
muspostbosspos UINT32 Read-only MusicPostBossPos
muspostbossfadein UINT32 Read-only MusicPostBossFadeIn
musforcereset INT8 Read-only ForceResetMusic:
  • -1 = uses user's settings
  • 0 = Music is always restarted.
  • 1 = Music is never restarted.
forcecharacter string Read-only ForceCharacter
weather UINT8 Read-only Weather. See PRECIP_* constants.
skynum INT16 Read-only SkyNum
skybox_scalex INT16 Read-only SkyboxScaleX
skybox_scaley INT16 Read-only SkyboxScaleY
skybox_scalez INT16 Read-only SkyboxScaleZ
ltactdiamond string Read-only TitleCardActDiamond
maxbonuslives INT8 Read-only MaxBonusLives
ltzzpatch string Read-only TitleCardZigZag
ltzztext string Read-only TitleCardZigZagText
interscreen string Read-only InterScreen
runsoc string Read-only RunSOC
scriptname string Read-only ScriptName
precutscenenum UINT8 Read-only PreCutsceneNum
cutscenenum UINT8 Read-only CutsceneNum
countdown INT16 Read-only Countdown
palette UINT16 Read-only Palette
numlaps UINT8 Read-only NumLaps
unlockrequired SINT8 Read-only Unlockable minus 1:
  • -1 = no unlockable required
  • 0 = unlockable #1 required
  • etc.
levelselect UINT8 Read-only LevelSelect
bonustype SINT8 Read-only BonusType:
  • -1 = None
  • 0 = Normal
  • 1 = Boss
  • 2 = ERZ3
saveoverride SINT8 Read-only SaveOverride. See SAVE_* constants.
levelflags UINT8 Read-only LevelFlags. See LF_* constants.
menuflags UINT8 Read-only MenuFlags. See LF2_* constants.
selectheading string Read-only SelectHeading
startrings UINT16 Read-only StartRings
sstimer INT32 Read-only SpecialStageTime
ssspheres UINT32 Read-only SpecialStageSpheres
gravity fixed_t Read-only Gravity

skincolor_t

This userdata type represents the properties of a skin color. In the examples below, skincolor is used as the name of the skincolor_t variable. An access to a variable var of skincolor_t is written as skincolor.var.

General
Accessibility Read+Write
Allows custom variables No
# (Length) #skincolor → Skincolor number
skincolor_t structure
Name Type Accessibility Description/Misc notes
name string Read+Write The name of the skincolor. Used in the console and Player Setup menu. Names containing spaces must be put in quotes in the console.
ramp UINT8 array Read+Write An array of 16 palette indices, which in whole represent the skincolor's color ramp.
invcolor UINT8 Read+Write The opposite skincolor. Used on the Goal Sign.
invshade UINT8 Read+Write The shade of the opposite skincolor, from 0 (lightest) to 15 (darkest). Used on the Goal Sign.
chatcolor UINT16 Read+Write Color to use when coloring a player name in the chat. Accepts V_*MAP constants.
accessible boolean Read+Write Skincolor accessibility. Determines whether the color can be accessed from the Player Setup menu or from the console.

Note: This attribute is read-only for default skincolors.

spriteframepivot_t

This userdata type represents the properties of a pivot of one of a sprite's frames. In the examples below, pivot is used as the name of the spriteframepivot_t variable. An access to a variable var of spriteframepivot_t is written as pivot.var.

General
Accessibility Read+Write
Allows custom variables No
spriteframepivot_t structure
Name Type Accessibility Description/Misc notes
x INT32 Read+Write The X coordinate of the pivot from where to rotate this frame.
y INT32 Read+Write The Y coordinate of the pivot from where to rotate this frame.
rotaxis enum (ROTAXIS_*) Read+Write The axis to rotate this frame in, for which ROTAXIS_X represents the roll axis, ROTAXIS_Y the pitch axis, and ROTAXIS_Z the yaw. This is set to ROTAXIS_X in all frames by default.

Map

These userdata types represent components of the the game that are part of a map.

mapthing_t

This userdata type represents a map Thing. In the examples below, mapthing is used as the name of the mapthing_t variable. An access to a variable var of mapthing_t is written as mapthing.var.

General
Accessibility Read+Write
Allows custom variables No
# (Length) #mapthing → Mapthing number
mapthing_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the Thing is valid (i.e., it exists), false if not.
x INT16 Read+Write The X coordinate of the Thing in the map, in fracunits.
y INT16 Read+Write The Y coordinate of the Thing in the map, in fracunits.
angle INT16 Read+Write The angle the map Thing is facing horizontally, in degrees. For most purposes, this is a value from 0 to 359 – 0 is East, 90 is North, 180 is West and 270 is South. However, some Object types use this variable for other purposes; in these cases, it can be any value from -32768 to 32767.
pitch INT16 Read+Write The angle the map Thing is facing vertically, in degrees. For most purposes, this is a value from 0 to 359 – 0 is Center, 90 is Up and -90 is Down. However, some Object types use this variable for other purposes; in these cases, it can be any value from -32768 to 32767.
roll INT16 Read+Write The angle the map Thing is rotating into it's own axis, in degress. For most purposes, this is a value from 0 to 359. However, some Object types use this variable for other purposes; in these cases, it can be any value from -32768 to 32767.
scale fixed_t Read+Write The scale of the map Thing, in fracunits.
type UINT16 Read+Write The map Thing number of the Object (or otherwise) to spawn with the map Thing. Does not include the multiples of 4096 added on by the map (see mapthing.extrainfo).
options UINT16 Read+Write The flags for the map Thing (see MTF_* constants). Also contains Z position information, shifted up by 4 bits (options = flags + z<<4).
z INT16 Read+Write The Z position of the map Thing above the sector floor, in fracunits. Usually pre-calculated by the game as mapthing.options>>4.
extrainfo UINT8 Read+Write An extra parameter calculated as the number of multiples of 4096 added onto the map Thing number. Used by a few Object types for extra effects.
mobj mobj_t Read+Write Points to the Object spawned by the map Thing. This is not set for Thing types that have no corresponding Object type, such as special placement patterns. In these cases, the value of mobj is nil.
tag INT16 Read+Write The tag of this map Thing, used for being referenced.
taglist taglist Userdata: Read-only
Userdata variables: Read+Write
The list of tags on this map Thing, used for being referenced.
args mapthing_t.args Read-only A table of arguments as integers, indexed from 0 to 9.
stringargs mapthing_t.stringargs Read-only A table of arguments as strings, indexed from 0 to 1.
spritexscale fixed_t Read+Write The sprite's X scale of this map Thing, in fracunits.
spriteyscale fixed_t Read+Write The sprite's Y scale of this map Thing, in fracunits.

sector_t

This userdata type represents a sector. In the examples below, sector is used as the name of the sector_t variable. An access to a variable var of sector_t is written as sector.var.

General
Accessibility Read+Write
Allows custom variables No
# (Length) #sector → Sector number
#sector.lines → Number of linedefs belonging to sector
sector_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the sector is valid (i.e., it exists), false if not.
floorheight fixed_t Read+Write The absolute height of the sector's floor in the map.
ceilingheight fixed_t Read+Write The absolute height of the sector's ceiling in the map.
floorpic string Read+Write The name of the sector's floor flat.
ceilingpic string Read+Write The name of the sector's ceiling flat.
lightlevel INT16 Read+Write The brightness level of the sector. This should be a value between 0 and 255.
special INT16 Read+Write The total of the sector's sector special values in all 4 sections given to the sector (section1 + section2<<4 + section3<<8 + section4<<12). Use GetSecSpecial(sector.special, n) to get the sector special set in a particular section n.
tag INT16 Read+Write The tag of the sector. Due to the way this is set up, all tags from 32768 to 65535 (seen when using map editors) are in fact -32768 to -1, although either can be used for assigning a new tag value (it will be automatically converted to the latter version anyway). Changing the value of sector.tag will have the same effect as changing it with Linedef type 409 or Linedef type 410.
taglist taglist Userdata: Read-only
Userdata variables: Read+Write
The list of tags of this sector.
thinglist() function Read-only To be used in an iterator function, e.g., for mobj in sector.thinglist(). This iterates through all the Objects within the sector, returning a mobj_t variable for use within the loop's contents.
heightsec sector_t Userdata: Read-only
Userdata variables: Read+Write
The control sector for a sector's Fake Floor/Ceiling Planes linedef special, if one exists.
camsec sector_t Userdata: Read-only
Userdata variables: Read+Write
The control sector for a sector's camera clipping heights, if one exists – this is set by combining the Special Sector Properties linedef special with the Intangible to the Camera sector special in the linedef's front sector.
lines[i] line_t array Read-only A table storing all the sector's linedefs.
ffloors() function Read-only To be used in an iterator function, e.g., for rover in sector.ffloors(). This iterates through all the FOFs within the sector, returning a ffloor_t variable for use within the loop's contents.
f_slope pslope_t Userdata: Read-only
Userdata variables: Read+Write
The sector's floor slope. This is nil if no floor slope is set.
c_slope pslope_t Userdata: Read-only
Userdata variables: Read+Write
The sector's ceiling slope. This is nil if no ceiling slope is set.
floorxoffset fixed_t Read+Write The sector's X floor texture offset (negative is to the left, positive is to the right).
flooryoffset fixed_t Read+Write The sector's Y floor texture offset (negative is downwards, positive is upwards).
floorangle angle_t Read+Write The sector's floor texture angle.
ceilingxoffset fixed_t Read+Write The sector's X ceiling texture offset (negative is to the left, positive is to the right).
ceilingyoffset fixed_t Read+Write The sector's Y ceiling texture offset (negative is downwards, positive is upwards).
ceilingangle angle_t Read+Write The sector's ceiling texture angle.
floorlightsec INT32 Read+Write The sector's floor light is copied from another sector's floor light with Linedef type 402.
ceilinglightsec INT32 Read+Write The sector's ceiling light is copied from another sector's ceiling light with Linedef type 402.
floorlightlevel INT16 Read+Write The sector's floor light level relative to the sector's brightness level.
floorlightabsolute boolean Read+Write If the sector's floor light level should be absolute from the sector's brightness level.
ceilinglightlevel INT16 Read+Write The sector's ceiling light level relative to the sector's brightness level.
ceilinglightabsolute boolean Read+Write If the sector's ceiling light level should be absolute from the sector's brightness level.
flags enum (MSF_*) Read+Write The sector's flags.
specialflags enum (SSF_*) Read+Write The sector's special flags.
damagetype enum (SD_*) Read+Write The sector's damage type.
triggertag INT16 Read+Write The sector calls the specified trigger tag upon triggering.
triggerer UINT8 Read+Write Determines what can trigger this sector's trigger.
  • 1 = Any player in the area.
  • 2 = All the players in the area.
  • 3 = Any mobj in the area.
friction fixed_t Read-only The sector's own friction, in fracunits.
gravity fixed_t Read+Write The sector's own gravity, in fracunits.

subsector_t

This userdata type represents a subsector. In the examples below, subsector is used as the name of the subsector_t variable. An access to a variable var of subsector_t is written as subsector.var.

General
Accessibility Read-only
Allows custom variables No
# (Length) #subsector → Subsector number
subsector_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the subsector is valid (i.e., it exists), false if not.
sector sector_t Userdata: Read-only
Userdata variables: Read+Write
Points to the sector this subsector is linked to.
numlines INT16 Read-only A variable used internally to get the number of segs within this subsector.
firstline UINT16 Read-only A variable used internally to get the number of the first seg within this subsector.
polyList() function Read-only To be used in an iterator function, e.g., for polyobj in subsector.polyList(). This iterates through all the PolyObjects witin the subsector, returning a polyobject_t variable for use within the loop's contents.

line_t

This userdata type represents a linedef. In the examples below, line is used as the name of the line_t variable. An access to a variable var of line_t is written as line.var.

General
Accessibility Read-only
Allows custom variables No
# (Length) #line → Linedef number
line_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the linedef is valid (i.e., it exists), false if not.
v1 vertex_t Read-only Points to the first of the two vertices the linedef is connected to.
v2 vertex_t Read-only Points to the second of the two vertices the linedef is connected to.
dx fixed_t Read-only Pre-calculated distance between the linedef's two vertex X coordinates (line.v2.x-line.v1.x).
dy fixed_t Read-only Pre-calculated distance between the linedef's two vertex Y coordinates (line.v2.y-line.v1.y).
flags INT16 Read-only Contains the linedef flags for the linedef (see ML_* constants).
special INT16 Read-only The linedef's linedef type number.
tag INT16 Read-only The tag number set for the linedef. Due to the way this is set up, all tags from 32768 to 65535 (seen when using map editors) are in fact -32768 to -1, although either can be used for assigning a new tag value (it will be automatically converted to the latter version anyway).
taglist taglist Userdata: Read-only
Userdata variables: Read+Write
The list of tags this linedef has.
args mapthing_t.args Read-only A table of arguments as integers, indexed from 0 to 9.
stringargs mapthing_t.stringargs Read-only A table of arguments as strings, indexed from 0 to 1.
sidenum[i] UINT16 array Read-only This is a small table containing the sidedef numbers for both the front sidedef (line.sidenum[0]) and the back sidedef if one exists (line.sidenum[1]). To get the sidedef userdata for these, use sides[line.sidenum[i]], i being either 0 (front) or 1 (back). To check if either sidedef is valid, use line.sidenum[i].valid, which will return either true or false.
frontside side_t Userdata: Read-only
Userdata variables: Read+Write
Points to the linedef's front sidedef (same as sides[line.sidenum[0]]).
backside side_t Userdata: Read-only
Userdata variables: Read+Write
Points to the linedef's back sidedef, if it exists (same as sides[line.sidenum[1]]); this will return nil if not.
alpha fixed_t Read-only The alpha of this linedef.
executordelay INT32 Read-only The amount of delay in tics this linedef trigger will hold to execute.
slopetype string Read-only A string representing the linedef's orientation in the map:
  • "horizontal": directly horizontal (line.dy is 0)
  • "vertical": directly vertical (line.dx is 0)
  • "positive": gradient is positive (line.dy/line.dx > 0)
  • "negative": gradient is negative (line.dy/line.dx < 0)
frontsector sector_t Userdata: Read-only
Userdata variables: Read+Write
Points to the linedef's front sector.
backsector sector_t Userdata: Read-only
Userdata variables: Read+Write
Points to the linedef's back sector, if it exists.
polyobj polyobj_t Userdata: Read-only
Userdata variables: Read+Write
Points to the linedef's poly object, if it exists.
firsttag INT16 Read-only A variable used internally by functions that search for linedefs by tag.
nexttag INT16 Read-only A variable used internally by functions that search for linedefs by tag.
text string Read-only Concatenation of all front and back texture name strings, for linedef types that require text in any of them.
callcount INT16 Read-only The number of calls left before triggering, used for "X calls" linedefs specials.

side_t

This userdata type represents a sidedef. In the examples below, side is used as the name of the side_t variable. An access to a variable var of side_t is written as side.var.

General
Accessibility Read+Write
Allows custom variables No
# (Length) #side → Sidedef number
side_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the sidedef is valid (i.e., it exists), false if not.
textureoffset fixed_t Read+Write The sidedef's X texture offset (negative is to the left, positive is to the right).
rowoffset fixed_t Read+Write The sidedef's Y texture offset (negative is downwards, positive is upwards).
toptexture INT32 Read+Write The sidedef's upper texture number. This is 0 if no valid texture is set. See List of textures by number for the numbers of SRB2's textures.
bottomtexture INT32 Read+Write The sidedef's lower texture number. This is 0 if no valid texture is set. See List of textures by number for the numbers of SRB2's textures.
midtexture INT32 Read+Write The sidedef's middle texture number. This is 0 if no valid texture is set. See List of textures by number for the numbers of SRB2's textures.
line line_t Read-only Points to the line this sidedef belongs to.
sector sector_t Userdata: Read-only
Userdata variables: Read+Write
Points to the sector the sidedef is facing.
special INT16 Read-only The linedef type special of the linedef the sidedef belongs to.
repeatcnt INT16 Read+Write The number of times to repeat the sidedef's middle texture.
text string Read-only Concatenation of the upper, middle and lower texture name strings, for linedef types that require text in any of them.
offsetx_top fixed_t Read+Write The sidedef's X top texture offset (negative is to the left, positive is to the right).
offsety_top fixed_t Read+Write The sidedef's Y top texture offset (negative is downwards, positive is upwards).
offsetx_mid fixed_t Read+Write The sidedef's X medium texture offset (negative is to the left, positive is to the right).
offsety_mid fixed_t Read+Write The sidedef's Y medium texture offset (negative is downwards, positive is upwards).
offsetx_bot fixed_t Read+Write The sidedef's X bottom texture offset (negative is to the left, positive is to the right).
offsety_bot fixed_t Read+Write The sidedef's Y bottom texture offset (negative is downwards, positive is upwards).

vertex_t

This userdata type represents a vertex. In the examples below, vertex is used as the name of the vertex_t variable. An access to a variable var of vertex_t is written as vertex.var.

General
Accessibility Read-only
Allows custom variables No
# (Length) #vertex → Vertex number
vertex_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the vertex is valid (i.e., it exists), false if not.
x fixed_t Read-only The absolute X coordinate of the vertex in the map.
y fixed_t Read-only The absolute Y coordinate of the vertex in the map.
floorz fixed_t Read-only The absolute Z floor coordinate of the vertex in the map, only if the floor Z is set.
floorzset boolean Read-only Returns true if the vertex's Z floor coordinate is set, false if not.
ceilingz fixed_t Read-only The absolute Z ceiling coordinate of the vertex in the map, only if the Ceiling Z is set.
ceilingzset boolean Read-only Returns true if the vertex's Z ceiling coordinate is set, false if not.

ffloor_t

This userdata type represents an FOF.

General
Accessibility Read+Write
Allows custom variables No
ffloor_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the FOF is valid (i.e., it exists), false if not.
topheight fixed_t Read+Write The absolute Z position of the FOF's top surface in the map. Modifying this will also modify the ceiling height of the FOF's control sector at the same time.
toppic string Read+Write The name of the FOF's top surface flat. Modifying this will also modify the ceiling flat of the FOF's control sector at the same time.
toplightlevel INT16 Read+Write The brightness level of the FOF. This should be a value between 0 and 255. Modifying this will also modify the brightness level of the FOF's control sector at the same time.
bottomheight fixed_t Read+Write The absolute Z position of the FOF's bottom surface in the map. Modifying this will also modify the floor height of the FOF's control sector at the same time.
bottompic string Read+Write The name of the FOF's bottom surface flat. Modifying this will also modify the floor flat of the FOF's control sector at the same time.
t_slope pslope_t Userdata: Read-only
Userdata variables: Read+Write
The FOF's top slope. This is nil if no top slope is set.
b_slope pslope_t Userdata: Read-only
Userdata variables: Read+Write
The FOF's bottom slope. This is nil if no bottom slope is set.
sector sector_t Userdata: Read-only
Userdata variables: Read+Write
The FOF's control sector.
flags enum (FOF_*) Read+Write The FOF's flags.
master line_t Read-only The FOF's control linedef.
target sector_t Userdata: Read-only
Userdata variables: Read+Write
The target sector the FOF is located in.
next ffloor_t Userdata: Read-only
Userdata variables: Read+Write
The next FOF in the target sector's FOF list. This is nil if the FOF is the last in the list.
prev ffloor_t Userdata: Read-only
Userdata variables: Read+Write
The previous FOF in the target sector's FOF list. This is nil if the FOF is the first in the list.
alpha INT32 Read+Write The FOF's alpha/translucency value. This should be a value between 1 and 256.
blend enum (AST_*) Read+Write The FOF's blending value.
bustflags enum (FB_*) Read-only The bustable flags this FOF has.
Decimal Hexadecimal Flag name Description
1 0x1 FB_PUSHABLES The bustable can be shattered by pushable objects.
2 0x2 FB_EXECUTOR The bustable triggers a linedef executor tag when shattered.
4 0x4 FB_ONLYBOTTOM The bustable can be only shattered from below.
busttype enum (BT_*) Read-only The FOF's bustable type.
Value Description
BT_TOUCH The bustable shatters on any form of contact by the player.
BT_SPINBUST The bustable shatters when the player in contact is spinning by either jumping or spindashing.
BT_REGULAR The bustable shatters when the player in contact is spinning but not jumping or has passible wall breaking or is into it's super form or is drilling in NiGHTS mode or is on a Metal Sonic recording.
BT_STRONG The bustable shatters when the player in contact has a strong ability.
busttag INT16 Read-only The linedef executor tag this bustable FOF will trigger when shattered only if has the FB_EXECUTOR flag.
sinkspeed fixed_t Read-only The speed to sink the player each tic when the FOF is a Quicksand.
friction fixed_t Read-only The amount of friction the Quicksand FOF has, which affects the player's momentum.
bouncestrength fixed_t Read-only The amount of bounce strength the Bouncy FOF has to bounce the player back.

pslope_t

This userdata type represents a slope. In the examples below, slope is used as the name of the pslope_t variable. An access to a variable var of pslope_t is written as slope.var.

General
Accessibility Read+Write
Allows custom variables No
pslope_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the slope is valid (i.e., it exists), false if not.
o vector3_t Userdata: Read+Write
Userdata variables: Read-only
The slope's origin vector.

For sector-based slopes, the origin's X/Y position is placed a fixed horizontal distance (known as the "extent" internally) away from the middle point of the linedef that defines the slope, at an angle of xydistance. The Z position is set as the un-sloped height of the floor or ceiling plane the slope is created for.

Currently, the only way to modify this variable is by assigning to it a custom table with x, y and z fields, such as below:

slope.o = {x = 1*FRACUNIT, y = 2*FRACUNIT, z = 3*FRACUNIT} -- change the origin's position to (1; 2; 3)

If SL_DYNAMIC is set in the slope's flags, the origin's Z position (slope.o.z) will be automatically corrected accordingly with the sector heights or vertices used to create the slope. This means that slope.o.z cannot be modified by Lua unless the flag is set.

d vector2_t Read-only The slope's 2D (X,Y) direction vector. Used to determine distance from the origin in 2D mapspace. The values are normalised, i.e.: they are equivalent to a thrust of FRACUNIT, though in the opposite direction to the angle xydirection.
zdelta fixed_t Read+Write The rate at which Z changes based on distance from the origin.

For sector-based slopes, this is calculated as the un-sloped height of the sector plane on the other side of the linedef that defines the slope's plane, minus the un-sloped height of the slope's own plane, and divided by the slope's "extent" value (see o for explanation). (i.e.: zdelta = (plane2-plane1)/ extent)

If SL_DYNAMIC is set in the slope's flags, this value will be automatically corrected accordingly with the sector heights or vertices used to create the slope. This means that this value cannot be modified by Lua unless the flag is set. Otherwise, modifying this value will also automatically update zangle and normal accordingly.

normal vector3_t Read-only The normal vector of the slope's plane.

If SL_DYNAMIC is set in the slope's flags, this value will be automatically corrected accordingly with the sector heights or vertices used to create the slope.

zangle angle_t Read+Write The vertical angle of the slope's plane, going up from the ground (i.e. a "flat" slope plane would have a zangle of 0).

If SL_DYNAMIC is set in the slope's flags, this value will be automatically corrected accordingly with the sector heights or vertices used to create the slope. This means that this value cannot be modified by Lua unless the flag is set. Otherwise, modifying this value will also automatically update zdelta and normal accordingly.

ANGLE_90 and ANGLE_270 are not accepted as values for this variable; the game will print an error message if you attempt to assign them to it.

xydirection angle_t Read+Write The horizontal angle of the slope's plane.

Modifying this value will also automatically update d and normal accordingly.

flags UINT8 Read-only The slope's flags (see SL_* constants).

polyobj_t

This userdata type represents a PolyObject. In the examples below, polyobj is used as the name of the polyobj_t variable. An access to a variable var of polyobj_t is written as polyobj.var.

General
Accessibility Read+Write
Allows custom variables No
polyobj_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the polyobject is valid (i.e., it exists), false if not.
id INT32 Read-only The ID used to reference the PolyObject in the map.
parent INT32 Read+Write The ID of the parent PolyObject, or -1 if it doesn't have one.
vertices vertex_t array Userdata: Read-only
Userdata variables: Read+Write
An array containing all the PolyObject's vertices. Use #polyobj.vertices to get the number of vertices it has.
lines line_t array Userdata: Read-only
Userdata variables: Read+Write
An array containing all the PolyObject's linedefs. Use #polyobj.lines to get the number of lines it has.
sector sector_t Userdata: Read-only
Userdata variables: Read+Write
The PolyObject's control sector.
angle angle_t Read-only The PolyObject's angle.
damage INT32 Read-only Setting this value to non-zero will make the PolyObject able to crush players.
thrust fixed_t Read-only Amount of thrust applied to objects that block the PolyObject's movement. By default this is set to FRACUNIT, but it may be modified by some of the linedef executor actions for PolyObjects.
flags INT32 Read+Write The PolyObject's flags (POF_*).
translucency INT32 Read+Write The PolyObject's translucency level, as a number from 0-9.
triggertag INT32 Read-only The tag of linedef executor to trigger on touch.
polyobj_t methods
Name Return value Description/Notes
polyobj:pointInside(fixed_t x, fixed_t y) boolean Special function to check if a XY position is inside the bounds of the PolyObject.
polyobj:mobjTouching(mobj_t mobj) boolean Special function to check if a mobj's XY position intersects with the lines of the PolyObject.
polyobj:mobjInside(mobj_t mobj) boolean Special function to check if a mobj's XY position is inside the bounds of the PolyObject.
polyobj:moveXY(fixed_t x, fixed_t y [, boolean checkmobjs?]) boolean Special function that moves a PolyObject horizontally, x is the X distance to move, y is the Y distance to move, checkmobjs? is a boolean to enable/disable physics with mobjs (enabled by default). Returns true if moved successfully, false if not.
polyobj:rotate(angle_t delta [, int turnthings [, boolean checkmobjs?]]) boolean Special function that rotates a PolyObject, delta is the angle to rotate, turnthingsis an integer to determine if and which mobjs should be rotated with it (0 = nothing, 1 = turn only non-players, 2 = turn everything), checkmobjs? is a boolean to enable/disable physics with mobjs (enabled by default). Returns true if rotated successfully, false if not.

taglist_t

This userdata type represents a list of tags. In the examples below, taglist is used as the name of the taglist_t variable. An access to a variable var of taglist_t is written as taglist.var.

General
Accessibility Read-only
Allows custom variables No
# (Length) #taglist → Number of tags in the list
taglist_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the list is valid (i.e., still exists), false if not.
taglist_t methods
Name Return value Description/Notes
taglist:iterate() function Returns an iterator function to iterate the list.
taglist:has(INT16 tag) boolean Returns true if the list contains tag.
taglist:find(INT16 tag) boolean Alias for taglist:has.
taglist:shares(taglist_t othertaglist) boolean Returns true if the list shares at least one tag with othertaglist.
taglist:add(INT16 tag) nil Adds tag to the end of the list.
taglist:remove(INT16 tag) nil Removes tag from the list.

taggroup_t

To do
Verify if this is correct.

This userdata type represents a group of tags. In the examples below, taggroup is used as the name of the taglist_t variable. An access to a variable var of taggroup_t is written as taggroup.var.

General
Accessibility Read-only
Allows custom variables No
# (Length) #taggroup → Number of elements in the group
taggroup_t methods
Name Return value Description/Notes
taggroup.iterate(INT16 tag) function Returns an iterator function to iterate the group with the specified tag. E.g for element in taggroup.tagged(1) do.

Miscellaneous

These userdata types represent components of the game that do not fit into the above groups.

camera_t

This userdata type represents a player's camera. In the examples below, camera is used as the name of the camera_t variable. An access to a variable var of camera_t is written as camera.var.

General
Accessibility Read+Write
Allows custom variables No
camera_t structure
Name Type Accessibility Description/Notes
chase boolean Read+Write Returns true if the third-person camera is enabled, false if not.
aiming angle_t Read+Write The vertical viewing angle of the camera.
x fixed_t Read-only The camera's absolute X position in the map.
y fixed_t Read-only The camera's absolute Y position in the map.
z fixed_t Read+Write The camera's absolute Z position in the map.
angle angle_t Read+Write The absolute angle the camera is facing. 0 is East, ANGLE_90 is North, ANGLE_180 is West, and ANGLE_270 is South.
subsector subsector_t Read-only The subsector the camera is currently in. To obtain the sector the camera is in, use camera.subsector.sector.
floorz fixed_t Read-only The absolute "floor" position for the camera, i.e., the height that it considers to be the floor. This can be different from the floor height of the sector the camera is in, for example if it is above a solid FOF.
ceilingz fixed_t Read-only The absolute "ceiling" position for the camera, i.e., the height that it considers to be the ceiling. This can be different from the ceiling height of the sector the camera is in, for example if it is below a solid FOF.
radius fixed_t Read+Write The current radius of the camera. By default this is 20*FRACUNIT, but it will automatically scale along with the corresponding player's scale.
height fixed_t Read+Write The current height of the camera. By default this is 16*FRACUNIT, but it will automatically scale along with the corresponding player's scale.
momx fixed_t Read+Write The camera's current X-axis momentum. Positive values shift the camera to the East, negative values to the West.
momy fixed_t Read+Write The camera's current Y-axis momentum. Positive values shift the camera to the North, negative values to the South.
momz fixed_t Read+Write The camera's current Z-axis momentum. Positive values shift the camera upwards, negative values downwards.

mouse_t

This userdata type contains data related to a player's assigned mouse.

General
Accessibility Read-only
Allows custom variables No
# (Length) Mouse number
mouse_t structure
Name Type Accessibility Description/Notes
dx INT32 Read-only The change in position along the x-axis.
dy INT32 Read-only The change in position along the y-axis.
mlookdy INT32 Read-only The change in position along the y-axis for use in mouse-looking.
rdx INT32 Read-only The real change in position along the x-axis unadjusted for sensitivity settings.
rdy INT32 Read-only The real change in position along the y-axis unadjusted for sensitivity settings.
buttons UINT16 Read-only Contains flags representing mouse buttons currently pressed (See MB_* constants).

keyevent_t

This userdata type contains data about a single keyboard input event.

General
Accessibility Read-only
Allows custom variables No
keyevent_t structure
Name Type Accessibility Description/Notes
name string Read-only The name of the key that triggered this event.
num INT32 Read-only The number of the key that triggered this event.
repeated boolean Read-only Whether this event is a continuation of a previously triggered event. For the KeyDown hook, this is true when the key is being held; for the KeyUp hook, this is always false.

consvar_t

This userdata type represents a console variable.

General
Accessibility Read-only
Allows custom variables No
consvar_t structure
Name Type Accessibility Description/Notes
name string Read-only The name of the console variable, as it should be written in the console.
defaultvalue string Read-only The default value set for the console variable, expressed as a string.
flags INT32 Read-only Contains the flags set for the console variable (see CV_* constants).
value INT32 Read-only The current value set for the console variable, expressed as a number.
string string Read-only The current value set for the console variable, expressed as a string.
changed boolean Read-only Returns whether the console variable has been changed by the player (true) or not (false).

patch_t

This userdata type allows access to the properties of a graphics patch (see the HUD library).

General
Accessibility Read-only
Allows custom variables No
patch_t structure
Name Type Accessibility Description/Notes
valid boolean Read-only Returns true if the patch is valid (i.e., it exists), false if not.
width INT16 Read-only The width of the patch, in fracunits/pixels.
height INT16 Read-only The height of the patch, in fracunits/pixels.
leftoffset INT16 Read-only The X offset of the patch (positive is left, negative is right), in fracunits/pixels.
topoffset INT16 Read-only The Y offset of the patch (positive is down, negative is up), in fracunits/pixels.

file*

This userdata type represents a file handle, obtained by calling io.openlocal (See the I/O Library documentation).

General
Accessibility Read-only
Allows custom variables No
file* does not have any attributes.

In the below examples, file refers to a file handle.

file* methods
Method Return value(s) Description
file:close() boolean or (nil, string, and int) or (nil, string) Closes the file.

If the call was successful, returns true — otherwise, returns nil, an error message, and an error code. If an attempt is made to close one of the standard files stdin, stdout, or stderr, this function will return nil and an error message, but no error code.

file:flush() boolean or (nil, string, and int) Saves any written data to file.

If the call was successful, returns true — otherwise, returns nil, an error message, and an error code.

file:lines() function Returns an iterator function that, each time it is called, returns a new line from the file as a string. Therefore, the construction
for line in file:lines() do
    -- body
end

will iterate over all lines of the file.

file:read([* format]) various Reads the file file, according to the given formats, which specify what to read. For each format, the function returns a string (or a number) with the characters read, or nil if it cannot read data with the specified format. When called without formats, it uses a default format that reads the entire next line (see below).

The available formats are:

  • "*n": reads a number; this is the only format that returns a number instead of a string.
  • "*a": reads the whole file, starting at the current position. On end of file, it returns the empty string.
  • "*l": reads the next line (skipping the end of line), returning nil on end of file. This is the default format.
  • number: reads a string with up to this number of characters, returning nil on end of file. If number is zero, it reads nothing and returns an empty string, or nil on end of file.
file:seek([string whence], [int offset]) string or nil Sets and gets the file position, measured from the beginning of the file, to the position given by offset plus a base specified by the string whence, as follows:
  • "set": base is position 0 (beginning of the file);
  • "cur": base is current position;
  • "end": base is end of file;

In case of success, function seek returns the final file position, measured in bytes from the beginning of the file. If this function fails, it returns nil, plus a string describing the error.

The default value for whence is "cur", and for offset is 0. Therefore, the call file:seek() returns the current file position, without changing it; the call file:seek("set") sets the position to the beginning of the file (and returns 0); and the call file:seek("end") sets the position to the end of the file, and returns its size.

file:setvbuf(string mode, [int size]) boolean or (nil, string, and int) Sets the buffering mode for an output file. There are three available modes:
  • "no": no buffering; the result of any output operation appears immediately.
  • "full": full buffering; output operation is performed only when the buffer is full (or when you explicitly flush the file (see io.flush)).
  • "line": line buffering; output is buffered until a newline is output.

For the last two cases, size specifies the size of the buffer, in bytes. The default is an appropriate size.

If the call was successful, returns true — otherwise, returns nil, an error message, and an error code.

file:write(...) boolean or (nil, string, and int) Writes the value of each of its arguments to the file. The arguments must be strings or numbers. To write other values, use tostring or string.format before write.

If the file size surpasses 1 megabyte after a write operation, BLua will raise an error and discard any pending changes.

If the call was successful, returns true — if it failed, but not due to surpassing the file size limit, returns nil, an error message, and an error code.

  Lua [view]
Language features SyntaxMetatables
SRB2 data ActionsConstantsFunctionsGlobal variablesHooksUserdata structures
SRB2Kart data Kart Userdata structuresKart FunctionsKart HooksKart Global Variables and Constants
Tutorials Freeslots and Object resourcesCustom player ability