M32 script variables
This is a list of events, variables, arrays, constants and keys accessible in Mapster32-script.
Events
- EVENT_ENTER3DMODE
fired upon entering 3D mode.
- EVENT_ANALYZESPRITES
continuously fired event in 3D mode, used to modify the properties of drawn sprites for the current frame.
- EVENT_INSERTSPRITE2D
fired after a sprite is inserted in 2D mode, sets the current sprite.
- EVENT_INSERTSPRITE3D
fired after a sprite is inserted in 3D mode, sets the current sprite.
- EVENT_DRAW2DSCREEN
fired after the screen has been drawn in 2D mode, can be used to implement additional drawing.
- EVENT_KEYS2D
continuously fired event in 2D mode after most key checks have been made.
- EVENT_KEYS3D
continuously fired event in 3D mode after most key checks have been made.
- EVENT_PREKEYS2D
continuously fired event in 2D mode before most key checks have been made.
- EVENT_PREKEYS3D
continuously fired event in 3D mode before most key checks have been made.
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.
Variables
Legend: write-enabled variable
variables used or set by various commands
- RETURN (also used in Sort)
- LOTAG
- HITAG
- TEXTURE
- I (capital i; current sprite)
video variables
- xdim
- ydim
- windowx1
- windowx2
- windowy1
- windowy2
- rendmode
misc. variables
- totalclock (incremented by 120 per second)
See Setaspect for the following two variables
- viewingrange
- yxaspect
- randomseed
- numwalls
- numsectors
- numsprites
- numtiles
variables used in sort
- SV1
- SV2
number of drawn sprites (valid in EVENT_ANALYZESPRITES)
- spritesortcnt
position and orientation of "mapper arrow"
- posx
- posy
- posz
- ang
- horiz
- cursectnum (use updatecursectnum after changing position)
"aiming" and selection variables
mouse pointer screen coordinates
- searchx
- searchy
Mouse "aiming" variables in 3D mode. searchstat describes what is being aimed at: 0:wall 1:ceiling 2:floor 3:sprite 4:masked wall
- searchstat
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.
- searchwall
- searchsector
searchbottomwall is only valid if searchstat equals 0 and differs from searchwall only if the "swap bottom wall" (key '2') is set.
- searchbottomwall
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.
- pointhighlight
- linehighlight
highlightcnt is the number of currently highlighted (semi-permanently, with RSHIFT) points and sprites.
- highlightcnt
highlightsectorcnt is the number of currently highlighted (permanently, with RALT) sectors.
- highlightsectorcnt
In 2D mode, mousxplc and mousyplc are the BUILD coordinates under the current mouse crosshair position.
- mousxplc
- mousyplc
clipboard contents
- temppicnum
- tempcstat
- templotag
- temphitag
- tempextra
- tempshade
- temppal
- tempvis
- tempxrepeat
- tempyrepeat
start position
- startposx
- startposy
- startposz
- startang
- startsectnum
variables useful for 2D drawing
A zoom of 16384 corresponds to a scale of one pixel per BUILD unit.
- zoom
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.
- drawlinepat
- halfxdim16
- midydim16
- ydim16
Arrays
Legend:
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).
- highlight[highlightcnt]
highlightsector is an array of highlighted sectors.
- highlightsector[highlightsectorcnt]
These are the (head|next|prev)sprite(stat|sect) arrays.
- hsect[MAXSECTORS+1]
- nsect[MAXSPRITES]
- psect[MAXSPRITES]
- hstat[MAXSTATUS+1]
- nstat[MAXSPRITES]
- pstat[MAXSPRITES]
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.
- tilesizx[MAXTILES]
- tilesizy[MAXTILES]
- show2dsector[(MAXSECTORS+7)>>3] X (doesn't appear to contain highlighted sectors)
- show2dwall[(MAXWALLS+7)>>3]
show2dsprite is a bitmap of which sprites are highlighted with RSHIFT.
- show2dsprite[(MAXSPRITES+7)>>3]
- keystatus[256] Indexed by scancodes (= KEY_?? constants)
- alphakeys[27] Contains scancodes of SPACE ([0]) and A through Z ([1] - [26]) keys.
- numberkeys[10] Contains scancodes of 0 to 9 keys.
Constants
- CLIPMASK0
- CLIPMASK1
- MAXSPRITES
- MAXSECTORS
- MAXWALLS
- MAXTILES
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.
- MAXSTATUS
- MAXSOUNDS
- NO
- COLOR_WHITE (used with 3D text commands)
Keys
- 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
Keypad keys:
- 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