Files
SRB2Kart-Saturn/LUASTUFF.md
T
GenericHeroGuy 913b374f9b Lua functions for colorization, offsets, drawing HUD items
Introduce drawinfo_t to pass coords/flags to both hardcode and Lua

* v.getDrawInfo: return X/Y/flags for the given HUD item
* v.drawItemBox: draw the item box, with support for all effects
* v.drawItemMul: draw multi sticker, for convenience
* v.getHudColor: return HUD color
* v.useColorHud: return true if colorization is enabled
* hud.getOffsets: return xoffset/yoffset for the given HUD item
2024-02-21 22:27:17 +01:00

2.3 KiB

SRB2Kart Saturn: Custom lua features

mobj.localskin and player.localskin fields

Allow reading and assigning localskins.

mobj.rollsum field

Not netsafe. Returns total sprite rotation value, taking sliptideroll and sloperoll cvars value into account. Mainly for use in visual-only addons like secondcolor.

player.sliproll field

Not netsafe. Returns player's current sliptide roll angle, taking sliptideroll cvar value into account.

hud.setVoteBackground(name)

Changes vote background texture prefix (game looks for PREFIX + "W" or "C" (depends on resolution) + FRAME_NUMBER).

hud.add(fn, "vote") and hud.add(fn, "intermission")

Hud hooks for vote screen and intermission screen. They only get drawer (v) as argument. To check if those hooks are available, check if globals FEATURE_VOTEHUD and FEATURE_INTERMISSIONHUD exist.

x, y = hud.getOffsets(item)

Returns the values of the given HUD item's xoffset/yoffset cvars, or nil if unsupported. Uses the same strings as hud.enabled.

x, y, flags = v.getDrawInfo(item)

Returns the X, Y and flags where the given HUD item will be drawn for the current displayplayer. Available for item, gametypeinfo and minimap.

v.drawItemBox(x, y, flags, small, dark, colormap)

Draws an item box at the given coordinates. small: true to draw small item box, false to draw large item box. dark: true if item box should be darkened. colormap: Colormap to draw the item box with. If nil, use displayplayer's HUD colormap.

v.drawItemMul(x, y, flags, small, colormap)

Draws a multi-item sticker at the given coordinates. small: true to draw small sticker, false to draw large sticker. colormap: Colormap to draw the sticker with. If nil, use displayplayer's HUD colormap.

hudcolor = v.getHudColor()

Returns the displayplayer's HUD color.

colorize = v.useColorHud()

Returns true if colorization is enabled, false otherwise.

mobj.spritexscale, mobj.spriteyscale, mobj.spritexoffset, mobj.spriteyoffset, mobj.rollangle, mobj.sloperoll, mobj.rollmodel fields

Same fields as in SRB2 2.2

S_StopSoundByNum

Allows stopping specific sound globally. Because this function starts with S_, like state, checking if it exists is a bit more complicated:

if rawget(_G, "S_StopSoundByNum") ~= nil then
    ... -- Can use it
end