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

From NetHackWiki
Jump to navigation Jump to search
(moar info.)
m (selection)
Line 71: Line 71:
 
  $foo = (40, 12)
 
  $foo = (40, 12)
 
  $foo = (5,5, 40,12)
 
  $foo = (5,5, 40,12)
 +
$foo = selection:{{sa|selection}}
  
 
Array variables:
 
Array variables:
Line 86: Line 87:
 
This parameter can be either a coordinate, or a variable of the coordinate type. For example:  
 
This parameter can be either a coordinate, or a variable of the coordinate type. For example:  
 
  GRAVE: (10,5)
 
  GRAVE: (10,5)
Hard-coded coordinate.
 
 
 
  $foo = (4,10)
 
  $foo = (4,10)
 +
$bar = { (4,10), (3,12), (50,2) }
 
  GRAVE: $foo
 
  GRAVE: $foo
 
+
  GRAVE: $bar[1]
$foo = { (4,10), (3,12), (50,2) }
 
  GRAVE: $foo[0]
 
  
 
  GRAVE: rndcoord({{sa|selection}})
 
  GRAVE: rndcoord({{sa|selection}})
 
A random coordinate selected from within the {{sa|selection}}
 
A random coordinate selected from within the {{sa|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==
 
==mathematical expression==
Line 102: Line 105:
 
A mathematical expression can consist of plain integer values, [[D-notation]]s, and the operands '+', '-', '*', '/', and '%'. For example: <tt>1 + 2</tt>, or <tt>3d6 * (2 + 3)</tt>.
 
A mathematical expression can consist of plain integer values, [[D-notation]]s, and the operands '+', '-', '*', '/', and '%'. For example: <tt>1 + 2</tt>, or <tt>3d6 * (2 + 3)</tt>.
 
Negative integer values should be enclosed inside parenthesis: <tt>(-1) * (-3)</tt>
 
Negative integer values should be enclosed inside parenthesis: <tt>(-1) * (-3)</tt>
 +
 +
==selection==
 +
A selection is a collection of map coordinates. The <tt>selection</tt> keyword is only needed when defining a variable of selection type.
 +
$foo = selection:{{sa|coord or variable}}
 +
$foo = selection:rect {{sa|region or variable}}
 +
$foo = selection:fillrect {{sa|region or variable}}
 +
$foo = selection:line {{sa|coord or variable}}-{{sa|coord or variable}}
 +
$foo = selection:randline {{sa|coord or variable}}-{{sa|coord or variable}},{{sa|mathematical expression}}
 +
$foo = selection:grow ({{sa|selection}})
 +
$foo = selection:grow ({{sa|list of directions}}, {{sa|selection}})
 +
$foo = selection:filter (50%, {{sa|selection}}))
 +
$foo = selection:filter ({{sa|selection}}, {{sa|selection}})
 +
$foo = selection:floodfill {{sa|coord or variable}}
 +
$foo = selection:circle ({{sa|coord or variable}}, {{sa|mathematical expression}})
 +
$foo = selection:circle ({{sa|coord or variable}}, {{sa|mathematical expression}}, filled)
 +
$foo = selection:circle ({{sa|coord or variable}}, {{sa|mathematical expression}}, unfilled)
 +
$foo = selection:ellipse ({{sa|coord or variable}}, {{sa|mathematical expression}}, {{sa|mathematical expression}})
 +
$foo = selection:ellipse ({{sa|coord or variable}}, {{sa|mathematical expression}}, {{sa|mathematical expression}}, filled)
 +
$foo = selection:ellipse ({{sa|coord or variable}}, {{sa|mathematical expression}}, {{sa|mathematical expression}}, unfilled)
 +
$bar = $foo
 +
 +
Selections can be added together with the '&' operator, for example <tt>rect(5,5, 50,18) & rect(10,2, 40,13)</tt>:
 +
$foo = selection:rect(5,5, 50,18) & rect(10,2, 40,13)
 +
 +
To select a random coordinate from a selection, use <tt>rndcoord({{sa|selection}})</tt>:
 +
$bar = rndcoord(rect(5,5, 50,18) & rect(10,2, 40,13))

Revision as of 18:58, 7 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

Level definition consists of LEVEL, optional FLAGS and any number of Level statements.

LEVEL

LEVEL:"name"

FLAGS

FLAGS:noteleport,mazelevel

Defines special flags for the whole level. Parameters are a comma-separated list of flags: noteleport, sheol, hardfloor, nommap, arboreal, shortsighted, noflipx, noflipy, noflip, mazelevel, premapped, shroud, stormy, graveyard, and sky.

Level statements

MESSAGE

MESSAGE:"any string goes here"

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


variable

Variable names start with a dollar sign, and can contain any alphanumeric characters. Variables must be defined before they can be used.

$foo = 123
$foo = "any string"
$foo = mathematical expression
$foo = $bar
$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))