M32 script variables
This is a list of events, variables, arrays, constants and keys accessible in Mapster32-script.
triggered upon entering 3D mode.
continuously triggered event in 3D mode, used to modify the properties of drawn sprites for the current frame.
triggered after a sprite is inserted in 2D mode, sets the current sprite.
triggered after a sprite is inserted in 3D mode, sets the current sprite.
triggered after the screen has been drawn in 2D mode, can be used to implement additional drawing.
triggered after the scene, but before the overlays have been drawn in 3D mode.
continuously triggered event in 2D mode after most key checks have been made.
continuously triggered event in 3D mode after most key checks have been made.
continuously triggered event in 2D mode before most key checks have been made.
continuously triggered event in 3D mode before most key checks have been made.
triggered by the link-tagging system to query whether the tag of a particular sprite (which is the current sprite in this event) has a linking meaning. It is supposed to return in RETURN a bit-field of ORed values:
1: lotag has linking semantics
The PRE*-versions of the key handling events are recommended when you want to override default keys. However, careless use may lead to a binding of a key to multiple functions. Therefore the _KEYS(2|3)D events will activate after most hardcoded key checks, making overriding keys impossible.
Legend: write-enabled variable
variables used or set by various commands
- RETURN (also used in Sort)
- I (capital i; current sprite)
- DOSCRSHOT, if set to non-zero, schedules saving a screenshot between the next scene drawing and EVENT_DRAW3DSCREEN
- totalclock (incremented by 120 per second)
See Setaspect for the following two variables
variables used in sort
number of drawn sprites (valid in EVENT_ANALYZESPRITES)
position and orientation of "mapper arrow"
- cursectnum (use updatecursectnum after changing position)
"aiming" and selection variables
mouse pointer screen coordinates
Mouse "aiming" variables in 3D mode. searchstat describes what is being aimed at: 0:wall 1:ceiling 2:floor 3:sprite 4:masked wall
searchwall is the index of the aimed at sprite if searchstat equals 3, the index of the aimed at wall if searchstat equals 0 or 4, and the index of the wall that intersects the ray from the current position to the aimed at point (as seen from above) otherwise.
searchbottomwall is only valid if searchstat equals 0 and differs from searchwall only if the "swap bottom wall" (key '2') is set.
pointhighlight holds the current highlighted (blinking) point or sprite in 2D mode. If pointhighlight is less than 16384, then its value is the wall index of the highlighted point (A wall in BUILD actually only holds coordinates for one point; the wall.point2 is the other end point of the wall). Otherwise, pointhighlight-16384 is a sprite index of the currently highlighted sprite.
highlightcnt is the number of currently highlighted (semi-permanently, with RSHIFT) points and sprites.
highlightsectorcnt is the number of currently highlighted (permanently, with RALT) sectors.
In 2D mode, mousxplc and mousyplc are the BUILD coordinates under the current mouse crosshair position.
variables useful for 2D drawing
A zoom of 16384 corresponds to a scale of one pixel per BUILD unit.
drawlinepat is the stroke pattern for the 2D drawing function, e.g. 0xffffffff (-1) is a continuous line, 0x0000ffff is a broken line (long intervals) and 0x55555555 is a dotted line.
X: deprecated/do not use (yet)
The following is a listing of all accessible arrays along with their size in brackets. Where the size is variable, it indicates the maximum allowable index plus 1.
All of the builtin arrays are read-only.
highlight is an array of highlighted points/sprites. Its elements follow the same convention as the `pointhighlight' variable (see above).
highlightsector is an array of highlighted sectors.
These are the (head|next|prev)sprite(stat|sect) arrays.
The tilesiz(x/y) arrays are indexed by tile numbers and hold the x/y dimensions of the loaded tiles. If a tile doesn't exist, they will be 0.
- show2dsector[(MAXSECTORS+7)>>3] X (doesn't appear to contain highlighted sectors)
show2dsprite is a bitmap of which sprites are highlighted with RSHIFT.
- keystatus Indexed by scancodes (= KEY_?? constants)
- alphakeys Contains scancodes of SPACE () and A through Z ( - ) keys.
- numberkeys Contains scancodes of 0 to 9 keys.
MAXSTATUS is useful for checking whether a sprite number is valid (i.e, whether a sprite with the given sprite number is in the map). This is the case if sprite[spritenum].statnum is lower than MAXSTATUS. It is needed because sprite numbers need not be contiguous during a session.
- COLOR_WHITE (used with 3D text commands)
- KEY_SPACE, KEY_A through KEY_Z (in alphakeys)
- KEY_0 through KEY_9 (in numberkeys)
- KEY_ENTER, KEY_BS, KEY_TAB
- KEY_DASH, KEY_EQUAL, KEY_LBRACK, KEY_RBRACK, KEY_SEMI, KEY_QUOTE, KEY_BQUOTE, KEY_BSLASH, KEY_COMMA, KEY_PERIOD, KEY_SLASH
- KEY_LALT, KEY_LCTRL, KEY_LSHIFT, KEY_RALT, KEY_RCTRL, KEY_RSHIFT
- KEY_gDEL, KEY_gDOWN, KEY_gEND, KEY_gHOME, KEY_gINS, KEY_gKP5, KEY_gLEFT, KEY_gMINUS, KEY_gPGDN, KEY_gPGUP, KEY_gPLUS, KEY_gRIGHT, KEY_gSLASH, KEY_gSTAR, KEY_gUP
- KEY_HOME, KEY_UP, KEY_PGUP, KEY_LEFT, KEY_RIGHT, KEY_END , KEY_DOWN, KEY_PGDN, KEY_INSERT, KEY_DELETE
Some aliases for keypad keys:
- KEY_KP0 through KEY_KP9, KEY_KPCOMMA