Difference between revisions of "Des-file format (UnNetHack)"

From NetHackWiki
Jump to navigation Jump to search
m (small improvements)
m
Line 22: Line 22:
 
==Level definitions==
 
==Level definitions==
  
A level definition consists of {{sa|LEVEL}}, optional {{sa|FLAGS}} and any number of {{sa|Level statements}}.
+
A level definition consists of {{sa|LEVEL}}, followed by an optional {{sa|FLAGS}} and any number of {{sa|Level statements}}.
  
 
===LEVEL===
 
===LEVEL===
Line 30: Line 30:
 
===FLAGS===
 
===FLAGS===
 
  FLAGS:noteleport,mazelevel
 
  FLAGS:noteleport,mazelevel
Defines special flags for the whole level. Parameters are a comma-separated list of flags: <tt>noteleport</tt>, <tt>sheol</tt>, <tt>hardfloor</tt>, <tt>nommap</tt>, <tt>arboreal</tt>, <tt>shortsighted</tt>, <tt>noflipx</tt>, <tt>noflipy</tt>, <tt>noflip</tt>, <tt>mazelevel</tt>, <tt>premapped</tt>, <tt>shroud</tt>, <tt>stormy</tt>, <tt>graveyard</tt>, and <tt>sky</tt>.
+
Defines special flags for the whole level. Parameters are a comma-separated list of flags:
 +
*<tt>noteleport</tt>: Player cannot teleport within the level.
 +
*<tt>sheol</tt>: Level is a [[Sheol]]-type level, with special rules.
 +
*<tt>hardfloor</tt>: The floor is too hard to dig.
 +
*<tt>nommap</tt>: [[magic mapping]] does not work.
 +
*<tt>arboreal</tt>: supposedly an outdoor map. Solid walls and secret corridors will be shown as trees, digging makes floor instead of corridor and randomly created corridors are made out of floor instead of corridor.
 +
*<tt>shortsighted</tt>: Monsters cannot see you from far away.
 +
*<tt>noflipx</tt>, <tt>noflipy</tt> and <tt>noflip</tt> prevent the level from being flipped horizontally, vertically and both.
 +
*<tt>mazelevel</tt>
 +
*<tt>premapped</tt>: The level map is automatically known by player (a la [[Sokoban]]).
 +
*<tt>shroud</tt>
 +
*<tt>stormy</tt>
 +
*<tt>graveyard</tt>
 +
*<tt>sky</tt>
  
 
==Level statements==
 
==Level statements==
Line 37: Line 50:
  
 
===MESSAGE===
 
===MESSAGE===
  MESSAGE:"any string goes here"
+
  MESSAGE:"string"
 +
 
 +
The message string is shown when player first enters the level. Each message line gets separated with a <tt>--more--</tt> -prompt in the game.
 +
 
 +
Example:
 +
MESSAGE: "Well done, mortal!"
 +
$foo = "Hello, World!"
 +
MESSAGE: $foo
  
 
===INIT_MAP===
 
===INIT_MAP===
Line 54: Line 74:
 
  GRAVE:{{sa|coord or variable}}, random
 
  GRAVE:{{sa|coord or variable}}, random
 
  GRAVE:{{sa|coord or variable}}
 
  GRAVE:{{sa|coord or variable}}
 +
Creates a grave at given location, with a given epitaph, a random epitaph, or with no text.
  
 
===MON_GENERATION===
 
===MON_GENERATION===
Line 76: Line 97:
 
===SHUFFLE===
 
===SHUFFLE===
 
  SHUFFLE:any_array_variable
 
  SHUFFLE:any_array_variable
 +
Shuffles the array elements.
 +
 +
Example:
 +
$foo = MONSTER:{ 'd', 'T', 'e', 'L' }
 +
SHUFFLE: $foo
  
 
===NON_DIGGABLE===
 
===NON_DIGGABLE===
 
  NON_DIGGABLE:region_or_variable
 
  NON_DIGGABLE:region_or_variable
 +
Sets the walls inside the region as non-diggable.
 +
 +
Example:
 +
NON_DIGGABLE:(00,00,13,12)
  
 
===NON_PASSWALL===
 
===NON_PASSWALL===
 
  NON_PASSWALL:region_or_variable
 
  NON_PASSWALL:region_or_variable
 +
Players and monsters cannot phase through the walls inside the region.
 +
 +
Example:
 +
NON_PASSWALL:(00,00,13,12)
  
 
===ROOMDOOR===
 
===ROOMDOOR===
 
  ROOMDOOR:secret, door_state, door_wall, door_pos
 
  ROOMDOOR:secret, door_state, door_wall, door_pos
secret can be one of <tt>true</tt>, <tt>false</tt>, or <tt>random</tt>.
+
Creates a door with certain state on the previously defined {{sa|ROOM}} or {{sa|SUBROOM}}.
door_state can be one of open, closed, locked, nodoor, broken, secret, or <tt>random</tt>.
+
 
door_wall can be one of north, south, west, or east, a pipe-delimited list of those, or <tt>random</tt>.
+
*secret can be one of <tt>true</tt>, <tt>false</tt>, or <tt>random</tt>.
door_pos is a positive integer value.
+
*door_state can be one of <tt>open</tt>, <tt>closed</tt>, <tt>locked</tt>, <tt>nodoor</tt>, <tt>broken</tt>, <tt>secret</tt>, or <tt>random</tt>.
 +
*door_wall can be one of <tt>north</tt>, <tt>south</tt>, <tt>west</tt>, or <tt>east</tt>, a pipe-delimited list of those, or <tt>random</tt>, and tells on what wall of the room the door will be created.
 +
*door_pos is a positive integer value and tells how far from the top or left the door will be.
 +
 
 +
Example:
 +
ROOMDOOR: false, closed, north|south, random
  
 
===DOOR===
 
===DOOR===
 
  DOOR:door_state, {{sa|selection}}
 
  DOOR:door_state, {{sa|selection}}
 +
Puts a door on the map.
 +
 +
*door_state can be one of <tt>open</tt>, <tt>closed</tt>, <tt>locked</tt>, <tt>nodoor</tt>, <tt>broken</tt>, <tt>secret</tt>, or <tt>random</tt>.
  
 
===WALLWALK===
 
===WALLWALK===
Line 100: Line 142:
  
 
===DRAWBRIDGE===
 
===DRAWBRIDGE===
  DRAWBRIDGE:{{sa|coord or variable}}, direction, door_state
+
  DRAWBRIDGE:{{sa|coord or variable}}, dir, state
 +
 
 +
*<tt>dir</tt> is one of the following: <tt>north</tt>, <tt>east</tt>, <tt>south</tt> or <tt>west</tt>
 +
*<tt>state</tt> is one of the following: <tt>nodoor</tt>, <tt>locked</tt>, <tt>closed</tt>, <tt>open</tt> or <tt>random</tt>
 +
 
 +
Note that the drawbridge placement is different from door placement; the coordinate must be a place where the drawbridge would be when it's open, and from that place towards the direction there should be a wall, where the portcullis will be.
 +
 
 +
Example:
 +
DRAWBRIDGE:(25,18), north, closed
  
 
===ENGRAVING===
 
===ENGRAVING===
 
  ENGRAVING:{{sa|coord or variable}}, engraving_type, "string"
 
  ENGRAVING:{{sa|coord or variable}}, engraving_type, "string"
 
  ENGRAVING:{{sa|coord or variable}}, engraving_type, $stringvariable
 
  ENGRAVING:{{sa|coord or variable}}, engraving_type, $stringvariable
engraving_type can be one of dust, engrave, burn, mark, blood, or <tt>random</tt>
+
engraving_type can be one of <tt>dust</tt>, <tt>engrave</tt>, <tt>burn</tt>, <tt>mark</tt>, <tt>blood</tt>, or <tt>random</tt>.
  
 
===FOUNTAIN===
 
===FOUNTAIN===
Line 186: Line 236:
 
  WALLIFY
 
  WALLIFY
 
  WALLIFY:region_or_variable
 
  WALLIFY:region_or_variable
 +
Turns walls (in the whole map, or in the defined region) completely surrounded by other walls into solid stone <tt>' '</tt>.
  
 
===NOMAP===
 
===NOMAP===
 
  NOMAP
 
  NOMAP
 +
Instead of {{sa|GEOMETRY}} and {{sa|MAP}}, you use this if you think that {{sa|INIT_MAP}} creates a good enough random map and you don't want to use any fixed map-parts.
 +
 +
See also {{sa|MAP}}
  
 
===GEOMETRY===
 
===GEOMETRY===
Line 195: Line 249:
 
  GEOMETRY:horiz,vert
 
  GEOMETRY:horiz,vert
 
  GEOMETRY:{{sa|coord or variable}}
 
  GEOMETRY:{{sa|coord or variable}}
horiz is one of <tt>left</tt>, <tt>half-left</tt>, <tt>center</tt>, <tt>half-right</tt>, or <tt>right</tt>.
+
*horiz is one of <tt>left</tt>, <tt>half-left</tt>, <tt>center</tt>, <tt>half-right</tt>, or <tt>right</tt>.
vert is one of <tt>top</tt>, <tt>center</tt>, or <tt>bottom</tt>.
+
*vert is one of <tt>top</tt>, <tt>center</tt>, or <tt>bottom</tt>.
  
 
Both types take an optional boolean value. If it's true, the commands following the map are restricted into that map.
 
Both types take an optional boolean value. If it's true, the commands following the map are restricted into that map.
Line 282: Line 336:
 
       BREAK
 
       BREAK
 
  }  
 
  }  
 +
The SWITCH behaviour is modeled after the C switch-statement.
 +
The <tt>BREAK</tt> keyword is optional; leaving it out will make execution fall through to the next case.
  
 
===LOOP===
 
===LOOP===
 
  LOOP [ integer_or_variable ] { {{sa|Level statements}} }
 
  LOOP [ integer_or_variable ] { {{sa|Level statements}} }
 +
 +
Example:
 +
LOOP [ 10 ] { OBJECT:random,random }
  
 
===IF===
 
===IF===
 +
IF [ percentage ] { {{sa|Level statements}} }
 
  IF [ 50% ] { {{sa|Level statements}} } ELSE { {{sa|Level statements}} }
 
  IF [ 50% ] { {{sa|Level statements}} } ELSE { {{sa|Level statements}} }
 
  IF [ math_expression_or_variable compare_operator math_expression_or_variable ] { {{sa|Level statements}} }
 
  IF [ math_expression_or_variable compare_operator math_expression_or_variable ] { {{sa|Level statements}} }

Revision as of 10:20, 9 January 2013

This is a preliminary document of the Des-file format used by UnNetHack.

UnNethack, like Sporkhack started with the new level compiler patch, and added most of the changes from Spork.

A level consists of any number of Header statements, and one or more of Level definitions.

Header statements

FUNCTION

FUNCTION name() { Level statements }

Defines a function. The level statements defined inside the function body will be executed when the function is called. Function must be defined before it can be called. Call the function by using it's name, for example name()

INCLUDE

INCLUDE "filename.des"

Includes the contents of the file in the current file.


Level definitions

A level definition consists of LEVEL, followed by an optional FLAGS and any number of Level statements.

LEVEL

LEVEL:"name"

The level is saved as name.des file. The name can be up to 8 characters long.

FLAGS

FLAGS:noteleport,mazelevel

Defines special flags for the whole level. Parameters are a comma-separated list of flags:

  • noteleport: Player cannot teleport within the level.
  • sheol: Level is a Sheol-type level, with special rules.
  • hardfloor: The floor is too hard to dig.
  • nommap: magic mapping does not work.
  • arboreal: supposedly an outdoor map. Solid walls and secret corridors will be shown as trees, digging makes floor instead of corridor and randomly created corridors are made out of floor instead of corridor.
  • shortsighted: Monsters cannot see you from far away.
  • noflipx, noflipy and noflip prevent the level from being flipped horizontally, vertically and both.
  • mazelevel
  • premapped: The level map is automatically known by player (a la Sokoban).
  • shroud
  • stormy
  • graveyard
  • sky

Level statements

Level statements include the following commands, variable definitions, FUNCTION definitions, function calls, and Flow control commands.

MESSAGE

MESSAGE:"string"

The message string is shown when player first enters the level. Each message line gets separated with a --more-- -prompt in the game.

Example:

MESSAGE: "Well done, mortal!"
$foo = "Hello, World!"
MESSAGE: $foo

INIT_MAP

INIT_MAP:solidfill, ' '
INIT_MAP:mines, '.' , ' ', true, true, random, true
INIT_MAP:sheollev
INIT_MAP:mazegrid,'-'

Initializes the map with different algorithm.

ALTAR

ALTAR:coord or variable, alignment, altartype

Create an altar.

GRAVE

GRAVE:coord or variable, "Any epitaph message"
GRAVE:coord or variable, random
GRAVE:coord or variable

Creates a grave at given location, with a given epitaph, a random epitaph, or with no text.

MON_GENERATION

Change the monster generation chances for this level.

MON_GENERATION:75%, (9, 'a'), (1, "fire giant")

75% of randomly generated monsters are either ants (90% chance), or fire giants (10% chance).

SOUNDS

Random sounds on this level.

SOUNDS:200, (hear, "falling rocks."), (pline, "Kaboom!"), (verbal, "Mwahahah!"), (feel, "hot!")

1/200 chance each turn to get one of the sounds defined. In this case, "You hear falling rocks.", "Kaboom!", "Mwahahah!", or "You feel hot!"

BRANCH

BRANCH:(x1,y1,x2,y2), (x3,y3,x4,y4)
BRANCH:levregion(x1,y1,x2,y2), levregion(x3,y3,x4,y4)

CORRIDOR

CORRIDOR:(room_number, direction, door_position), (room_number, direction, door_position)
CORRIDOR:(room_number, direction, door_position), any_integer

SHUFFLE

SHUFFLE:any_array_variable

Shuffles the array elements.

Example:

$foo = MONSTER:{ 'd', 'T', 'e', 'L' }
SHUFFLE: $foo

NON_DIGGABLE

NON_DIGGABLE:region_or_variable

Sets the walls inside the region as non-diggable.

Example:

NON_DIGGABLE:(00,00,13,12)

NON_PASSWALL

NON_PASSWALL:region_or_variable

Players and monsters cannot phase through the walls inside the region.

Example:

NON_PASSWALL:(00,00,13,12)

ROOMDOOR

ROOMDOOR:secret, door_state, door_wall, door_pos

Creates a door with certain state on the previously defined ROOM or SUBROOM.

  • secret can be one of true, false, or random.
  • door_state can be one of open, closed, locked, nodoor, broken, secret, or random.
  • door_wall can be one of north, south, west, or east, a pipe-delimited list of those, or random, and tells on what wall of the room the door will be created.
  • door_pos is a positive integer value and tells how far from the top or left the door will be.

Example:

ROOMDOOR: false, closed, north|south, random

DOOR

DOOR:door_state, selection

Puts a door on the map.

  • door_state can be one of open, closed, locked, nodoor, broken, secret, or random.

WALLWALK

WALLWALK:coord or variable, map character or variable
WALLWALK:coord or variable, map character or variable, 50%
WALLWALK:coord or variable, map character or variable, map character or variable
WALLWALK:coord or variable, map character or variable, map character or variable, 50%

DRAWBRIDGE

DRAWBRIDGE:coord or variable, dir, state
  • dir is one of the following: north, east, south or west
  • state is one of the following: nodoor, locked, closed, open or random

Note that the drawbridge placement is different from door placement; the coordinate must be a place where the drawbridge would be when it's open, and from that place towards the direction there should be a wall, where the portcullis will be.

Example:

DRAWBRIDGE:(25,18), north, closed

ENGRAVING

ENGRAVING:coord or variable, engraving_type, "string"
ENGRAVING:coord or variable, engraving_type, $stringvariable

engraving_type can be one of dust, engrave, burn, mark, blood, or random.

FOUNTAIN

FOUNTAIN:selection

POOL

POOL:selection

SINK

SINK:selection

TERRAIN

TERRAIN:selection, map_character_or_variable

REPLACE_TERRAIN

REPLACE_TERRAIN:region_or_variable, map_character_or_variable, map_character_or_variable, percentage

SPILL

SPILL:coord or variable, terrain_type, direction, length

PORTAL

PORTAL:(x1,y1,x2,y2), (x3,y3,x4,y4), "string"
PORTAL:levregion(x1,y1,x2,y2), levregion(x3,y3,x4,y4), "string"

RANDOM_CORRIDORS

RANDOM_CORRIDORS
RANDOM_CORRIDORS:style

style is random, or one of the following values:

  • 1 = at least one corridor leaves from each room and goes to random room
  • 2 = circular path: room1 -> room2 -> room3 -> ... -> room1
  • 3 = all roads lead to rome. or to the first room.
  • any other value (or leaving style off) will generate normal style corridors.

REGION

REGION:region_or_variable, lightstate, roomtype [, filling [, bool]] [{ Level statements }]

ROOM

ROOM:"roomtype", [ chance, ] lightstate, position, align, size [, fill] { Level statements }
  • position can be either random or an approximate location in the form of (1,3) - this is not a coordinate, but an approximate position on the map - the number ranges are 1..5
  • align is either random or an approximate adjustment to the location in the form of (horiz, vert), where
    • horiz is one of left, half-left, center, half-right, or right.
    • vert is one of top, center, or bottom.
  • size is either random or an exact width and height in the form of (3,5).
  • fill is an optional boolean, and tells whether the room should get stocked with random stuff.

The contents (and SUBROOMs) of the room can be defined using the level statements.

SUBROOM

SUBROOM:"roomtype", [ chance, ] lightstate, position, size [, fill] { Level statements }
  • position is either random, or an exact position of the room inside the outer room in the form of (4,3).
  • size is either random or an exact width and height in the form of (3,5).
  • fill is an optional boolean, and tells whether the room should get stocked with random stuff.

The contents (and SUBROOMs) of the room can be defined using the level statements.

GOLD

GOLD:mathematical expression, coord or variable

LADDER

LADDER:coord or variable, direction

Creates a ladder. direction is one of up or down.

STAIR

STAIR:coord or variable, direction

Creates stairs. direction is one of up or down.

TELEPORT_REGION

TELEPORT_REGION:(x1,y1,x2,y2), (x3,y3,x4,y4) [, up_or_down ]
TELEPORT_REGION:levregion(x1,y1,x2,y2), levregion(x3,y3,x4,y4) [, up_or_down ]

TRAP

TRAP:"falling rock", coord or variable
TRAP:random, coord or variable

WALLIFY

WALLIFY
WALLIFY:region_or_variable

Turns walls (in the whole map, or in the defined region) completely surrounded by other walls into solid stone ' '.

NOMAP

NOMAP

Instead of GEOMETRY and MAP, you use this if you think that INIT_MAP creates a good enough random map and you don't want to use any fixed map-parts.

See also MAP

GEOMETRY

This must be immediately followed by a MAP definition. It tells the location of the MAP-part on the level. Two types of GEOMETRY, one takes an approximation of MAP alignment, the other takes an exact coordinate or variable.

GEOMETRY:horiz,vert
GEOMETRY:coord or variable
  • horiz is one of left, half-left, center, half-right, or right.
  • vert is one of top, center, or bottom.

Both types take an optional boolean value. If it's true, the commands following the map are restricted into that map.

GEOMETRY:center,center,true

MAP

MAP
...
...
...
ENDMAP

This must be immediately preceded by a GEOMETRY definition. You define a map-part by "drawing" with map characters between the MAP and ENDMAP. The map can be up to 21 lines high and each line can be up to 76 chars long. Each line must also be the same length. You can also use numbers inside the map, but those will be ignored; they're considered as line numbers.

See also NOMAP.

MAZEWALK

MAZEWALK:coord or variable, direction
MAZEWALK:coord or variable, direction, stocked
MAZEWALK:coord or variable, direction, stocked, '.'

stocked is a boolean value and tells whether the maze should get stocked with random loot and monsters.

MONSTER

MONSTER:'d', coord or variable
MONSTER:"hill giant", coord or variable
MONSTER:('i', "imp"), coord or variable
MONSTER:random, coord or variable
$foo = MONSTER:'d'
MONSTER:$foo, (5,5)
$arr = MONSTER:{ 'd', 'T', 'y' }
MONSTER:$arr[0], (5,5)

The monster definition can also take a number of optional parameters, separated by commas:

MONSTER:'d', (4,4), "Idefix", peaceful, asleep, law, m_feature "boulder", female, invisible, cancelled, revived, avenge, stunned, confused, fleeing: 40, blinded: 20, paralyzed: 10, seen_traps: all
  • "Idefix" is the name of the monster.
  • Instead of peaceful, could use hostile.
  • Instead of asleep, could use awake.
  • Instead of law, could use noalign, neutral, chaos, coaligned, noncoaligned, align[0], align[1], align[2] or align:random.
  • m_feature tells the monster to mimic a dungeon feature, a boulder in this case. could also use m_monster or m_object.
  • female, invisible, cancelled, revived, avenge, stunned and confused set monster status bits.
  • fleeing, blinded and paralyzed set the number of turns the monster will flee, is blinded or is paralyzed, respectively.
  • seen_traps tells which traps the monster has seen; parameter is either all or quoted strings of trap names separated by pipe characters (eg. "falling boulder", or "arrow"|"dart"|"bear")

OBJECT

OBJECT:"elven cloak", (5,5)
OBJECT:'?', (5,5)
OBJECT:('/', "wishing"), (5,5)
OBJECT:random, (5,5)
$foo = OBJECT:'/'
OBJECT:$foo, (5,5)
$arr = OBJECT:{ '/', '?', '!' }
OBJECT:$arr[2], (5,5)

The object definition can also take a number of optional parameters, separated by commas:

OBJECT:'?', (5,5), blessed, montype:('d', "little dog"), +4, NAME:"foobar", quantity: 20, buried, invisible, lit, greased, locked, trapped, eroded:2, erodeproof, recharged:3
  • blessed can be replaced with uncursed or cursed.
  • montype tells eg. what monster statue it is.
  • any integer value sets the plusses or minuses for eg. armor or weapon.
  • NAME gives the item a name. can also take a variable of string type as a parameter.
  • quantity set the number of items.
  • buried, trapped, invisible, greased set object states.
  • lit or unlit for lamps.
  • eroded sets the erosion. Don't use with erodeproof.
  • locked (or broken) set the lock state for lockable objects.
  • recharged sets the number of times eg. a wand has been recharged.


CONTAINER

CONTAINER:"large chest", (5,5) { Level statements }

Takes the same parameters as OBJECT, but allows defining the contents inside the curly braces. For the contents, use a subset of level statements: OBJECTs, CONTAINERs and flow control commands (LOOP, IF...ELSE and SWITCH); anything else causes undefined behaviour.

Flow control

The following commands affect the order in which commands are executed.

SWITCH

SWITCH [ integer_or_variable ] {
  CASE integer:
     Level statements
     BREAK
  DEFAULT:
     Level statements
     BREAK
} 

The SWITCH behaviour is modeled after the C switch-statement. The BREAK keyword is optional; leaving it out will make execution fall through to the next case.

LOOP

LOOP [ integer_or_variable ] { Level statements }

Example:

LOOP [ 10 ] { OBJECT:random,random }

IF

IF [ percentage ] { Level statements }
IF [ 50% ] { Level statements } ELSE { Level statements }
IF [ math_expression_or_variable compare_operator math_expression_or_variable ] { Level statements }

EXIT

EXIT

Immediately finishes the level script.


variable

Variable names start with a dollar sign, and can contain any alphanumeric characters. Variables must be defined before they can be used. Some variable definitions must have the variable type: TERRAIN, MONSTER, OBJECT and selection.

$foo = 123
$foo = "any string"
$foo = mathematical expression
$bar = $foo
$foo = TERRAIN:'T'
$foo = MONSTER:'d'
$foo = MONSTER:"little dog"
$foo = MONSTER:('d', "little dog")
$foo = MONSTER:random
$foo = OBJECT:'/'
$foo = OBJECT:"elven cloak"
$foo = OBJECT:('?', "identify")
$foo = (40, 12)
$foo = (5,5, 40,12)
$foo = selection:selection

Array variables:

$foo = { 1, 2, 3, 4, 5 }
$foo = { "string a", "bcdef", "and something" }
$foo = { (1,2), (40,12) }
$foo = { (5,5,40,12), (1,1,20,18), (40,10,50,12) }
$foo = TERRAIN: { 'T', 'L', '.' }
$foo = MONSTER: { 'n', "newt", ('d', "little dog") }
$foo = OBJECT: { '/', "elven cloak", ('?', "identify") }

To access one element of an array variable, use eg. $foo[0] to access variable $foo's first element.

coord or variable

This parameter can be either a coordinate, or a variable of the coordinate type. For example:

GRAVE: (10,5)
$foo = (4,10)
$bar = { (4,10), (3,12), (50,2) }
GRAVE: $foo
GRAVE: $bar[1]
GRAVE: rndcoord(selection)

A random coordinate selected from within the selection

region or variable

This parameter can be either a region, or a variable of the region type. For example:

NON_DIGGABLE:(5,5, 40,12)
$foo = (5,5, 40,12)
NON_DIGGABLE:$foo

mathematical expression

A mathematical expression can consist of plain integer values, D-notations, and the operands '+', '-', '*', '/', and '%'. For example: 1 + 2, or 3d6 * (2 + 3). Negative integer values should be enclosed inside parenthesis: (-1) * (-3)

selection

A selection is a collection of map coordinates. The selection keyword is only needed when defining a variable of selection type.

$foo = selection:coord or variable
$foo = selection:rect region or variable
$foo = selection:fillrect region or variable
$foo = selection:line coord or variable-coord or variable
$foo = selection:randline coord or variable-coord or variable,mathematical expression
$foo = selection:grow (selection)
$foo = selection:grow (list of directions, selection)
$foo = selection:filter (50%, selection))
$foo = selection:filter (selection, selection)
$foo = selection:floodfill coord or variable
$foo = selection:circle (coord or variable, mathematical expression)
$foo = selection:circle (coord or variable, mathematical expression, filled)
$foo = selection:circle (coord or variable, mathematical expression, unfilled)
$foo = selection:ellipse (coord or variable, mathematical expression, mathematical expression)
$foo = selection:ellipse (coord or variable, mathematical expression, mathematical expression, filled)
$foo = selection:ellipse (coord or variable, mathematical expression, mathematical expression, unfilled)
$bar = $foo

Selections can be added together with the '&' operator, for example rect(5,5, 50,18) & rect(10,2, 40,13):

$foo = selection:rect(5,5, 50,18) & rect(10,2, 40,13)

To select a random coordinate from a selection, use rndcoord(selection):

$bar = rndcoord(rect(5,5, 50,18) & rect(10,2, 40,13))