Modding:generator API

From DoomRL Wiki

Revision as of 20:38, 20 April 2013 by Shark20061 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page is currently under construction.

The generator holds all of the ever-present functions used to create the random maps in DoomRL. It also contains a variety of helper functions, many of them useful if not vital to the creation of intricate and meticulous game design.

Contents

API

Please note that the type "integer" indicates an numeric value without a decimal part. It does not indicate the range of acceptable values.

The argument type "CellID" may be the numeric or string ID of a cell.

The argument type "CellSet" may be the numeric ID, string ID, or a list of numeric and/or string IDs.

The argument type "Flags" expects a list of flag constants of the indicated type.

Valkyrie Functions

These functions are provided via the Valkyrie library, and are low level functions for level manipulation and querying.

Generator Interface - Valkyrie Functions
Basic Cell Handling Functions
integer generator.get_cell(Coord loc)
string generator.get_cell_id(Coord loc)
integer generator.fast_get_cell(integer x, integer y)
void generator.set_cell(Coord loc, CellID what)
void generator.fast_set_cell(integer x, integer y, integer what)
Map Checking Functions
integer generator.around(Coord where, CellSet what)
integer generator.cross_around(Coord where, CellSet what)
boolean generator.is_empty(Coord where, Flags reqs)
boolean generator.is_empty_area(Area where, Flags reqs)
Map Searching Functions
Coord generator.find_coord(CellSet what)

Basic Cell Handling Functions

generator.get_cell(Coord loc)
Gets the Numeric ID (NID) of the cell at a given map position.
loc: The coordinates of the cell to get.
Returns: The NID of the cell.

generator.get_cell_id(Coord loc)
Gets the ID of the cell at a given map position.
loc: The coordinates of the cell to get.
Returns: The string ID of the cell.

generator.fast_get_cell(integer x, integer y)
Gets the Numeric ID (NID) of the cell at a given map position.
x: The X position of the cell to get.
y: The Y position of the cell to get.
Returns: The NID of the cell.

generator.set_cell(Coord loc, CellID what)
Assigns a new cell to a map position.
loc: The coordinates of the position to set.
what: The ID of the cell to assign to the position.

generator.fast_set_cell(integer x, integer y, integer what)
Assigns a now cell to a map position.
x: The X position of the cell to set.
y: The Y position of the cell to set.
what: The NID (string IDs not allowed) of the cell to assign to the position.

Map Checking Functions

generator.around(Coord where, CellSet what)
Checks the positions adjacent to a location (including diagonally adjacent) and returns the number of cells that match one of the indicated cell IDs.
where: The coordinate to check around. The coordinate sent in this way is not checked, only adjacent cells are.
what: The cell(s) to check for.
Returns: The number of cells (from 0 to 8) that matched one of the what cell IDs.

generator.cross_around(Coord where, CellSet what)
Checks the positions adjacent to a location (but not diagonally adjacent) and returns the number of cells that match one of the indicated cell IDs.
where: The coordinates to check around. The coordinate sent in this way is not checked, only adjacent cells are.
what: The cell(s) to check for.
Returns: The number of cells (from 0 to 4) that matched one of the what cell IDs.

generator.is_empty(Coord where, Flags reqs)
Checks to see if the indicated cell is "empty", defining "empty" based on a list of criteria.
where: The position to check.
reqs: A list of EmptyFlags (named numeric constants that start with EF_) indicating which types of objects or properties the position cannot have. For example, EF_NOBEINGS only returns true if the map position does not contain a being. See Modding:Constants#Empty_Flags for more information.
Returns: True if the cell satisfies all of the conditions indicated in reqs, False otherwise.

generator.is_empty_area(Area where, Flags reqs)
Checks to see if the indicated area is "empty", defining "empty" based on a list of criteria.
where: The area to check.
reqs: A list of EmptyFlags (named numeric constants that start with EF_) indicating which types of objects or properties the area cannot have. For example, EF_NOBEINGS only returns true if the area does not contain a being. See Modding:Constants#Empty_Flags for more information.
Returns: True if every cell in the area satisfies all of the conditions indicated in reqs, False otherwise.

Map Searching Functions

generator.find_coord(CellSet what)
Searches the map for the first coordinate containing one of the indicated cell IDs.
what: The cell(s) to search for.
Returns: The coordinates of the first position that contains one of the what cell IDs. The map is checked row by row starting from the top, going from left to right across each row.

Personal tools