User:RedEnchilada/Lua/Utility scripts

From SRB2 Wiki
Jump to navigation Jump to search
To do
Should this page go into main wiki userspace? Discuss on the talk page. C:

This page contains links to various scripts intended to make writing various functionality in Lua easier, or make certain blanket map features easier to implement. These are not standalone scripts. All content posted here is free to use for any purpose, with no attribution required unless otherwise stated. Usage instructions are posted alongside each script.

If you want to add a script to this page, bring it up on the talk page first. Note that scripts posted here should not be for specific gimmicks; only blanket functionality should be listed. If adding to the level utilities section, considering releasing on the SRB2MB (along with an example) and linking to the topic here.


Level utilities

These scripts are intended to be used in maps to create additional functionality. Most scripts do not require alteration, and can simply be put in their own script lump in the WAD, although some might offer methods to modify the script to tweak its functionality, particularly when sector specials are involved.

Axis2D

Release (Attribution required to RedEnchilada and Pac)
A script to add 2D movement along defined paths to a level. Installation and usage instructions are included in the download.


Scripting utilities

These scripts are intended to be used to make certain scripting behaviors easier to implement. Most of these scripts will do nothing on their own. Usage will typically involve placing the script in its own lump that comes before any other scripts, or placing it at the top of the script it's being used in.

Button state management

Script
A convenience script to make reading button taps or extended holds easier.

  • Installation: Copy the script into its own lump, or to the top of the Lua file it's being used in. The script checks for other instances of itself, so there will be no conflicts.
  • Usage: Read the state of specific buttons by checking player.buttonstate[button]. button can be a BT_ constant for individual buttons, the weapon button number (1, 2, 3... 7) for weapon quick-select buttons, and "up", "down", "left" or "right" for directional inputs. Returned value will be positive if the button is held (the exact number being how many tics the button has been held), or negative if the button is not held (the exact number being how many tics the button has been released, converted to negative sign).

One-line custom monitor setup

Script
A convenience function that makes it easier to declare custom monitors. Useful if you want to create many monitors in one addon.

  • Installation: Copy the script to the top of the Lua file that you wish to declare the custom monitors in.
  • Usage: Use the function MONITOR(doomednum, name, sprite, action, var1, var2) to declare a custom monitor. Sample arguments are listed within the script.