Lua/Userdata structures

From SRB2 Wiki
< Lua(Redirected from Player t)
Jump to: navigation, search

This page lists all the userdata types available for Lua included with SRB2, as well as all possible variables that can be used for each.

Notes

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

Column headers

  • Name: Indicates the required name to be used
  • Type: Indicates what type of (or what range of) values/userdata the variable takes/returns, see list below for types that aren't themselves userdata variables.
  • Accessibility: Indicates whether it is possible to read (retrieve) or write (modify) the variable's value.
  • Description/Misc notes: Gives additional information about how the variable is to be used.

Variable types

This section gives a list of variable types that can appear under the Type column for tables in this article:

Non-numerical

  • string - Accepts or returns only text (e.g. "sonic" or "eggman").
  • boolean - Accepts or returns only true or false.
  • userdata (mobj_t, player_t, etc) - Accepts or returns only variables with a specific userdata type

Basic numerical

Signed:

  • SINT8 - Signed 8-bit integer; values accepted or returned range from -128 to 127.
  • INT16 - Signed 16-bit integer; values accepted or returned range from -32768 to 32767.
  • INT32 - Signed 32-bit integer; values accepted or returned range from -2147483647 to 2147483648.

Unsigned:

  • UINT8 - Unsigned 8-bit integer; values accepted or returned range from 0 to 255.
  • UINT16 - Unsigned 16-bit integer; values accepted or returned range from 0 to 65535.
  • UINT32 - Unsigned 32-bit integer; for technical reasons, this is treated as identical to INT32 in Lua.

Derived numerical

  • fixed_t - same as INT32; this indicates that the integer is a fixed-point value, and so should be a multiple of FRACUNIT unless otherwise stated. Note that the minimum and maximum limits 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 integer is an angle value, and so should be used with the ANG*/ANGLE_* constants unless otherwise stated. Note that ANGLE_180 and larger (including ANGLE_MAX) will be negative numbers due to being confined to INT32 limits in Lua. See also Lua/Functions > Angle math.
  • tic_t - same as UINT32; this indicates that the integer is a time in tics, unless otherwise stated. For a time in seconds expressed in tics, multiply the number of seconds by TICRATE (35 tics = TICRATE = 1 second).

Other

  • enum (prefix) - An enumerated type integer. This is intended to accept or return specific integers from a list represented by constants, but can still hold any kind of integer even outside the list. prefix displays the common prefix for the relevant group of constants that should be assigned or returned to this variable, and links to the article containing them.
  • type array - This a table containing multiple entries; type is the variable type of the returned value of entries within the table. The type of variables accepted as keys may be given in the Description/Misc notes column.

General

mobj_t

General
Accessibility Read+Write
Allows custom variables Yes

(Example uses will use mobj as the mobj_t variable here, with mobj.var to point to any of the mobj_t variables.)

mobj_t structure
Name Type Accessibility Description/Misc notes
valid boolean Read-only Returns true if the object is valid (i.e. still exists), returns false otherwise.
x fixed_t Read-only The object's absolute x-position in the map. To modify this value, use a function such as P_TeleportMove 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_TeleportMove 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 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)
sprite enum (SPR_*) Read+Write The current sprite prefix the object is displaying. Each time an object switches states, it is reset to the new state's sprite prefix; this can be modified to be anything else at any time keeping this in mind.
frame UINT32 Read+Write The current sprite frame the object is displaying, plus additional state info such as full brightness, animation, and translucency. Each time an object switches states, it is reset to the new state's sprite frame; this can be modified to be anything else at any time keeping this in mind.
anim_duration UINT16 Read+Write If mobj.frame currently has the frame flag FF_ANIMATE, 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.
touching_sectorlist N/A None Unusable by Lua - not yet implemented.
subsector subsector_t Read-only The current subsector the object is in. To obtain the sector the object is in, use mobj.subsector.sector, though 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 will change if the object is for instance above a solid FOF or solid object, or has just moved to a different sector. For reverse gravity objects however, this does not switch to ceilings.
ceilingz fixed_t Read-only The absolute "ceiling" position for the object, i.e the height that it considers to be the ceiling. This will change if the object is for instance below a solid FOF or solid object, or has just moved to a different sector. For reverse gravity objects however, this does not switch to floors.
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 type the Object belongs to, adjusted according to the new scale. Otherwise this is freely adjustable (minimum limit 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 type the Object belongs to, adjusted according to the new scale. Otherwise this is freely adjustable (minimum limit is 0). For players however, note that this is continuously corrected/modified to be either the default height or a set misc. height such as the "spinning" height.
momx fixed_t Read+Write The object's current x-axis momentum. +ve values shift the object to the East, -ve values to the West. To modify this property properly with respect to an angle, this should be set to the full horizontal speed multiplied by cos(angle), angle being the absolute horizontal plane angle expressed as angle_t. For speeds also involving the z-axis, this should be also multiplied by cos(v-angle), v-angle being the vertical plane angle (assuming v-angle of 0 faces completely horizontal).
momy fixed_t Read+Write The object's current y-axis momentum. +ve values shift the object to the North, -ve values to the South. To modify this property properly with respect to an angle, this should be set to the full speed multiplied by sin(angle), angle being the absolute horizontal plane angle expressed as angle_t. For speeds also involving the z-axis, this should be also multiplied by cos(v-angle), v-angle being the vertical plane angle (assuming v-angle of 0 faces completely horizontal).
momz fixed_t Read+Write The object's current z-axis momentum. +ve values shift the object upwards, -ve values downwards. To modify this property properly with respect to a vertical plane angle, this should be set to the full speed multiplied by sin(v-angle), v-angle being the vertical horizontal plane angle expressed as angle_t (assuming angle of 0 faces completely horizontal). For completely horizontal movement this should just be 0.
pmomz fixed_t Read+Write The object's "platform" z-axis momentum, i.e. the z-momentum from the platform the object is currently standing on.
tics INT32 Read+Write The current value of the object's state timer, which goes down by 1 each tic until it reaches 0 (when the object will switch to a new state). Each time an object switches states, it is reset to the new state's tic duration; this can be modified to be anything else at any time keeping this in mind. A value of -1 will make the current state have infinite duration.
state enum (S_*) Read+Write The current state number of the object. 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, but this cannot be used on player objects.

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 current primary flags the object has. When the Object is first spawned, this is automatically set to the flags attribute for the Object type the Object belongs to, but can freely be adjusted afterwards. (Use MF_* constants)
flags2 UINT32 Read+Write The current secondary flags the object has. (Use MF2_* constants)
eflags UINT16 Read+Write The current extra object flags the object has. (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; however, Extra Life Monitors, Level End Signs, ghost trails, and player thok trails will also apply a skin when needed.
color UINT8 Read+Write The current skin color applied to the object (SKINCOLOR_* constants are to be used). 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.
bnext mobj_t Userdata: Read-only
Userdata variables: Read+Write
The next object in the blockmap.
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 mode's 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 mode's hoops, but is usable for other purposes as well.
type enum (MT_*) Read+Write The current Object type number of the Object. It is possible to modify this variable, though this is not usually needed in most circumstances; note that mobj.info will automatically be modified at the same time to give the attributes 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 allows access to the attributes for the Object type the Object belongs to (used as a shortcut for mobjinfo[mobj.type]). mobj.info itself cannot be modified directly; if mobj.type is modified however, mobj.info will automatically be modified to give the attributes for the new Object type instead.
health INT32 Read+Write The Object's current health point amount. When the Object is first spawned, this is automatically set to the spawnhealth attribute for the Object type the Object belongs to, but can freely be adjusted afterwards. For objects that don't necessarily need a health value, this can be used for miscellaneous purposes if needed.
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 # 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 not available/taken up. 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. Otherwise, this can be used to link any related object at all if needed.
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/speed up the object when touching the ground, so in a sense the higher the value of mobj.friction 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), or 0.90625 * FRACUNIT, or 29/32 * FRACUNIT (29*FRACUNIT/32 should be used if you want to set this yourself)

movefactor fixed_t Read+Write The object's current "movefactor" value. Formerly may have been used for friction-related purposes, but is currently used only for miscellaneous purposes instead.
fuse INT32 Read+Write Commonly used as a timer before the object disappears or does something else, which automatically goes down 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 Absolute "water top" position for the object, i.e. the top height of the water FOF currently touching the object. This will change if the object has just moved to a different water block or is not in a water block at all (defaults to mobj.subsector.sector.floorheight - 1000*FRACUNIT in this situation).
waterbottom fixed_t Read+Write Absolute "water bottom" position for the object, i.e. the bottom height of the water FOF currently touching the object. This will change if the object has just moved to a different water block or is not in a water block at all (defaults to mobj.subsector.sector.floorheight - 1000*FRACUNIT in this situation).
mobjnum N/A None Unusable by Lua - this is a networking thing used for $$$.sav and so shouldn't be available for Lua usage.
scale fixed_t Read+Write The object's current scale, normal 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 is not currently this scale, it will gradually change mobj.scale's value 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 mobj.destscale's value. The default value used for most cases is FRACUNIT/12, but this can be adjusted to speed up/slow down scaling if needed.
extravalue1 INT32 Read+Write An extra variable for objects to use in SRB2's source code. This is freely available for any object to use for any purpose whatsoever, though some regular SRB2 objects may already use this.
extravalue2 INT32 Read+Write An extra variable for objects to use in SRB2's source code. This is freely available for any object to use for any purpose whatsoever, though some regular SRB2 objects may already use this. Mind that A_Repeat in particular currently uses this internally to set the repeat count.
cusval INT32 Read+Write The object's current "custom value" variable, ported from the v2.0 modification SRB2Morphed. This is intended to be used by the numerous Actions also implemented for this and mobj.cvmem (such as A_CheckCustomValue or A_CusValAction), though can be freely used for any purpose whatsoever.
cvmem INT32 Read+Write The object's "custom value" variable saved in memory, ported from the v2.0 modification SRB2Morphed. This is intended to be used by the numerous Actions also implemented for this and mobj.cusval (such as A_CheckCustomValue or A_CusValAction), though can be freely used for any purpose whatsoever.

player_t

General
Accessibility Read+Write
Allows custom variables Yes
# (Length) #player → player number
#player.powers → total number of powers (23)

(Example uses will use player as the player_t variable here, with player.var to point to any of the player_t variables.)

player_t structure
Name Type Accessibility Description/Misc notes
valid boolean Read-only Returns true if the player is valid (i.e. still exists), returns false otherwise.
name string Read-only Returns the player's current name.
mo mobj_t Read+Write Points to the player's mobj_t properties (such as x/y/z position and angle).

Note: By default player.mo is a pre-determined Object of the type MT_PLAYER; however, player.mo can be changed to Objects of any type (but cannot be set to nil). It is not recommended to use non-MT_PLAYER Objects though – 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.

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 and similar. 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).
viewz fixed_t Read+Write The player's absolute viewing height (or viewing Z position) used in 1st person camera mode. 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. If the player is not on the ground, or not currently using the 1st person camera, then this extra value will not be added on regardless of the player's walking speed.

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 in 1st person camera mode. This 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 in 1st person camera mode, 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.

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.

health INT32 Read+Write A copy of the player's current health to display on the HUD. Modifying this does not affect the player's actual health; to do that you would need to use player.mo.health instead of player.health. (However, player.health should nevertheless be updated as well to match player.mo.health's value)

Note: the actual "RINGS" value displayed on the HUD is normally calculated as player.health - 1.

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)
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 A_CustomPower 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_JUMP
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 states S_PLAY_RUN1 to S_PLAY_RUN8). 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.
skincolor UINT8 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. Values above SKINCOLOR_GOLD should not be used for this variable.

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.

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 gametypes and NiGHTS mode.
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.
dashtime INT32 Read+Write The time the player has been charging up spin in tics, used to determine when to play the spindash charging sound.
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.
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.
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).
jumping boolean Read+Write Determines whether the player's jump can be cut or not when the jump button is released; when player.jumping is set to true jump momentum cutting can be done, false if not.
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 ONE, 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 ALL, 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 player's "real" time displayed in the 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, this timer will stop increasing, marking the time the player finished the level 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.
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.
mare UINT8 Read+Write Used in NiGHTS mode to determine the current mare 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.
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.
lastmare UINT8 Read+Write Used in NiGHTS mode to store the previous mare's number.
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 with either the Wind/Current or Conveyor Belt specials, 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.
bot UINT8 Read-only Determines whether the player is a bot or not:
  • 0 - The player is a normal player
  • 1 - The player is a bot player currently using bot AI
  • 2 - The player is a bot player currently controlled by Player 2 controls
jointime tic_t Read+Write The amount of time the player has been in-game, and even counts up when the game is paused.
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.

ticcmd_t

General
Accessibility Read+Write
Allows custom variables No

(Example uses will use cmd as the ticcmd_t variable here, with cmd.var to point to any of the ticcmd_t variables.)

ticcmd_t structure
Name Type Accessibility Description/Misc 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).

skin_t

See also: S_SKIN
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/Misc notes
valid boolean Read-only Returns true if the skin is valid (i.e. it exists), returns false otherwise.
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").
charsel string Read-only Returns the name for the character select graphic for the skin set by the S_SKIN (e.g. skins["sonic"].charsel would return "CHRSONIC").
face string Read-only Returns the name for the life icon graphic for the skin set by the S_SKIN (e.g. skins["sonic"].face would return "LIVSONIC").
superface string Read-only Returns the name for the life icon graphic for the skin when super set by the S_SKIN (e.g. skins["sonic"].superface would return "LIVSUPER").
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)
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).
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)
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).
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.

SOC

mobjinfo_t

See also: Object > Object type attributes
General
Accessibility Read+Write
Allows custom variables Yes
# (Length) #info → Object type number
mobjinfo_t structure
Name Type Accessibility Description/Misc 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 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
General
Accessibility Read+Write
Allows custom variables No
# (Length) #state → State number
state_t structure
Name Type Accessibility Description/Misc 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
General
Accessibility Read+Write
Allows custom variables No
# (Length) #info → Sound number
sfxinfo_t structure
Name Type Accessibility Description/Misc 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 changable by the skin this will be -1. (See SKS* constants)

hudinfo_t

See also: Heads-up display > HUD item modification
General
Accessibility Read+Write
Allows custom variables No
# (Length) #info → HUD item number
hudinfo_t structure
Name Type Accessibility Description/Misc 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.

mapheader_t

See also: Level header
General
Accessibility Read-only
Allows custom variables SOC-only
# (Length) #mapheader → Map number
mapheader_t structure
Name Type Accessibility Description/Misc notes
lvlttl string Read-only LevelName
subttl string Read-only SubTitle
actnum UINT8 Read-only Act
typeoflevel UINT16 Read-only TypeOfLevel, as an integer. (See TOL_* constants)
nextlevel INT16 Read-only NextLevel, as an integer.
musname string Read-only Music
mustrack UINT16 Read-only MusicTrack
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
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 unlock required, 0 = unlockable #1 required, etc.
levelselect UINT8 Read-only LevelSelect
bonustype SINT8 Read-only BonusType:
  • -1 = None
  • 0 = Normal
  • 1 = Boss
  • 2 = ERZ3
levelflags UINT8 Read-only LevelFlags (See LF_* constants)
menuflags UINT8 Read-only MenuFlags (See LF2_* constants)

Map

mapthing_t

General
Accessibility Read+Write
Allows custom variables No
mapthing_t structure
Name Type Accessibility Description/Misc notes
valid boolean Read-only Returns true if the map thing is valid (i.e. it exists), returns false otherwise.
x INT16 Read+Write The x-coordinate of the map thing on the map, in fracunits.
y INT16 Read+Write The y-coordinate of the map thing on the map, in fracunits.
angle INT16 Read+Write The angle the map thing is facing, in degrees. For some object types this is used for other purposes; mapthing.angle can be a value from -32768 to 32767. For most purposes though this is usually a value from 0 to 360 - 0 is East, 90 is North, 180 is West and 270 is South.
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 map thing flags for the map thing (see MTF_* constants). Also contains z-height information, shifted up by 4 bits. (options = flags + z<<4)
z INT16 Read+Write The z-height 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 objects for extra effects.
mobj mobj_t Read+Write Points to the object spawned by the map thing (this is not set for special placement object types, so mapthing.mobj would be nil in these cases).

sector_t

General
Accessibility Read+Write
Allows custom variables No
# (Length) #sector → Sector number
#sector.lines → Number of lines belonging to sector
sector_t structure
Name Type Accessibility Description/Misc notes
valid boolean Read-only Returns true if the sector is valid (i.e. it exists), returns false otherwise.
floorheight fixed_t Read+Write The sector's absolute floor height z-position in the map.
ceilingheight fixed_t Read+Write The sector's absolute ceiling height z-position in the map.
floorpic string Read+Write The name of the sector's floor flat texture.
ceilingpic string Read+Write The name of the sector's ceiling flat texture.
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 number set for 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.
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.

subsector_t

General
Accessibility Read-only
Allows custom variables No
# (Length) #subsector → Subsector number
subsector_t structure
Name Type Accessibility Description/Misc notes
valid boolean Read-only Returns true if the subsector is valid (i.e. it exists), returns false otherwise.
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.

line_t

General
Accessibility Read-only
Allows custom variables No
# (Length) #line → Linedef number
line_t structure
Name Type Accessibility Description/Misc notes
valid boolean Read-only Returns true if the linedef is valid (i.e. it exists), returns false otherwise.
v1 vertex_t Read-only Points to the first of the two vertexes the linedef is connected to.
v2 vertex_t Read-only Points to the second of the two vertexes 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 special 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).
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 Read-only Points to the linedef's front sidedef (same as sides[line.sidenum[0]]).
backside side_t Read-only Points to the linedef's back sidedef, if it exists (same as sides[line.sidenum[1]]); this will return nil if not.
slopetype string Read-only Outputs any of the following, depending on 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.
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 Concatination of all front and back texture name strings, for linedef types that require text in any of them.
callcount INT16 Read-only

side_t

General
Accessibility Read+Write
Allows custom variables No
# (Length) #side → Sidedef number
side_t structure
Name Type Accessibility Description/Misc notes
valid boolean Read-only Returns true if the sidedef is valid (i.e. it exists), returns false otherwise.
textureoffset fixed_t Read+Write The sidedef's texture x-offsets (negative is to the left, positive is to the right).
rowoffset fixed_t Read+Write The sidedef's texture y-offsets (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.
bottomtexture INT32 Read+Write The sidedef's lower texture number. This is 0 if no valid texture is set.
midtexture INT32 Read+Write The sidedef's middle texture number. This is 0 if no valid texture is set.
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 Concatination of the upper, middle and lower texture name strings, for linedef types that require text in any of them.

vertex_t

General
Accessibility Read-only
Allows custom variables No
# (Length) #vertex → Vertex number
vertex_t structure
Name Type Accessibility Description/Misc notes
valid boolean Read-only Returns true if the vertex is valid (i.e. it exists), returns false otherwise.
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.
z fixed_t Read-only Sometimes used as an absolute z-coordinate in some special cases, but for all Lua purposes this is unused.

ffloor_t

General
Accessibility Read+Write
Allows custom variables No
ffloor_t structure
Name Type Accessibility Description/Misc notes
valid boolean Read-only Returns true if the FOF is valid (i.e. it exists), returns false otherwise.
topheight fixed_t Read+Write The FOF's absolute top height z-position in the map. Modifying this will also modify the FOF's control sector's ceiling height at the same time.
toppic string Read+Write The name of the FOF's top flat texture. Modifying this will also modify the FOF's control sector's ceiling flat 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 FOF's control sector's brightness level at the same time.
bottomheight fixed_t Read+Write The FOF's absolute bottom height z-position in the map. Modifying this will also modify the FOF's control sector's floor height at the same time.
bottompic string Read+Write The name of the FOF's bottom flat texture. Modifying this will also modify the FOF's control sector's floor flat at the same time.
sector sector_t Userdata: Read-only
Userdata variables: Read+Write
The FOF's control sector.
flags enum (FF_*) 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 level. This should be a value between 1 and 256.

Miscellaneous

camera_t

General
Accessibility Read-only
Allows custom variables No
camera_t structure
Name Type Accessibility Description/Misc notes
chase boolean Read-only Returns true if chasecam is enabled, otherwise this will return false.
aiming angle_t Read-only 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-only The camera's absolute z-position in the map.
angle angle_t Read-only 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 Current subsector the camera is in. To obtain the sector the camera is in, use camera.subsector.sector.
floorz fixed_t Read-only Absolute "floor" position for the camera, i.e the height that it considers to be the floor. This will change if the camera is for instance above a solid FOF, or has just moved to a different sector.
ceilingz fixed_t Read-only Absolute "ceiling" position for the camera, i.e the height that it considers to be the ceiling. This will change if the camera is for instance below a solid FOF, or has just moved to a different sector.
radius fixed_t Read-only The current radius of the camera. By default this is 20*FRACUNIT, but will automatically scale accordingly with the corresponding player if their scale was modified.
height fixed_t Read-only The current height of the camera. By default this is 16*FRACUNIT, but will automatically scale accordingly with the corresponding player if their scale was modified.
momx fixed_t Read-only The camera's current x-axis momentum. +ve values shift the camera to the East, -ve values to the West.
momy fixed_t Read-only The camera's current y-axis momentum. +ve values shift the camera to the North, -ve values to the South.
momz fixed_t Read-only The camera's current z-axis momentum. +ve values shift the camera upwards, -ve values downwards.

consvar_t

General
Accessibility Read-only
Allows custom variables No
consvar_t structure
Name Type Accessibility Description/Misc notes
name string Read-only The name of the console variable to be used for the console.
defaultvalue string Read-only The default value set for the console variable, expressed as a string.
flags INT32 Read-only Contains the consvar flags 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

General
Accessibility Read-only
Allows custom variables No
patch_t structure
Name Type Accessibility Description/Misc notes
valid boolean Read-only Returns true if the patch is valid (i.e. it exists), returns false otherwise.
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.
  Lua [view]

BasicsFunctionsGlobal variablesHooksUserdata structures

Tutorials:

Freeslots and Object resourcesCustom player ability