M32 script commands

From EDukeWiki
Jump to navigation Jump to search
Build/Mapster32 Map Editing
Mapster32 Scripting

This is a categorized list of every command in Mapster32-script.

Legend:
I: acts on current sprite, S: acts on current sprite by pointer (also valid in "for i drawnsprites")
i: sets current sprite, s: only sets current sprite by pointer
D: differs from CON, X: deprecated/do not use (yet)
var/array/special: must be writable, [something]: optional command field

A note on the current sprite: when the current sprite index I is set (that is, greater or equal zero), all functions that act on sprites by pointer (S) are also available since the sprite pointer is set to point to the sprite[] array at index I in this case. The converse is not true, however: the sprite pointer could be set to a sprite structure other than the main sprite[] array (such as the tsprite[] array of sprites drawn on the screen), so code in a scope where the sprite pointer has been set (s) cannot use functions accessing the sprite[] array (I).

basic commands

control flow

struct access (redundant)

These are inaccessible in newer versions of Mapster32, use "set xyz zyx" instead.

  • Setsector
  • Getsector
  • Setwall
  • Getwall
  • Setsprite
  • Getsprite
  • Gettspr | X
  • Settspr | X

arrays

var commands

varvar commands

math commands

The trigonometric commands interpret values outside the range [0, 2047] correctly as angles modulo 2048.

special commands

  • Sort array count [comparison_state]
  • Collectsectors array count numcollectedsectors [comparison_state]
  • For itervar what [what2]

valid iteration types (what):
Note: where the current sprite is affected, it is restored at the end of the loop

  • allsprites (i), allsectors, allwalls, selsprites (i), selsectors, selwalls, drawnsprites (s, indexes tsprite[])
  • spritesofsector sector (i), loopofwall wall, wallsofsector sector, range num
examples

Using the for command you can create batch modifications in a few lines. (note: these examples don't claim to be useful)

  • making liztroops really big
for i allsprites, ifactor LIZTROOP, sizeat 128 128
  • translating the whole map by (x,y,z)
for i allsectors
{
   add sector[i].ceilingz z, add sector[i].floorz z
   for j wallsofsector i, { add wall[j].x x, add wall[j].y y }
   for j spritesofsector i, { add .x x, add .y y, add .z z }
}

var if* and while* commands

varvar if* and while* commands

other if* commands

BUILD functions

The following returns a (positive) game palette index "closest" to the RGB color passed.

debugging commands

quote commands

  • Definequote quotenum [text...] | (initial definition of a quote)
  • Redefinequote quotenum [text...] | (replacement occurs at runtime)
  • Print quotenum | (prints to the OSD)
  • Quote quotenum
  • Error quotenum
  • Printmessage16 quotenum | 2D mode only
  • Printmessage256 quotenum x y | 3D mode only
  • Printext256 quotenum x y color backcolor fontsize | 3D mode only, -color is looked up in editorcolors if color is negative
  • Printext16 quotenum x y color backcolor fontsize | 2D mode only, color is looked up in editorcolors

The following two commands query the user for a number from 0 to max, specifying a negative max argument will make the allowable number range be max to -max: (deprecated)

Valid flags are:

1: sign (allow values from -max to max)
2: autocomplete names
4: autocomplete taglabels
8: return -1 if cancelled. Otherwise, the initial value is returned, which is the one passed in var.

findnear* (not tested)

misc. commands

If what has bit 16384 set, the lower 14 bits of sprite_or_wall_num are taken as sprite index, else wall index

current sprite commands

drawing commands

The suffixes 16 and 256 mean that the commands are to be used in 2D and 3D modes, respectively.

used in EVENT_DRAW2DSCREEN

Specifying nonnegative values for the color will use the 16-color editor palette, whereas negative values -1 to -255 will use a palette of all colors available in 2D mode, where the palette is the base game palette.

used elsewhere

sound commands

All sound commands accept vars. Sounds should appear from current sprite if set and globally otherwise (not tested).