Modding:level object (0.9.9.7)

From DoomRL Wiki

(Redirected from Modding:level object)
Jump to: navigation, search

The level object in DoomRL pulls triple duty: it stores and publishes properties relevant to the current level, it provides access to the level API which includes procedures from Lua, DoomRL, and valkyrie, and through clever use of metatables it exposes the light, cell type, and HP arrays stored in the valkyrie LuaMapNode object. Here we focus on its representation as an object.

Properties

Properties
status word This is for use by level designers and is preserved after a level is exited.
data anything This is for use by level designers.
name string This is the level name as displayed on the HUD.
name_number word This controls the "LevX" part of the level name. If zero, it won't be displayed.
danger_level word Level generation parameter that usually corresponds to depth.
style byte The style (tile set) used by the level generation functions.
id string The id of the current level
special_exit string The id of the level that red stairs lead to

level.data and level.status are used to store information during (in the case of data) and after (in the case of status) level execution. Although one can work around the need for either it is considered good practice to use these two fields. level.status is limited; it can only store a single word value and it is intended for storing the current state of a level--just entered, reached the halfway mark, finished, etc. It is preserved so you may use this information to influence future levels. level.data is meant to track the current level as it exists now, should a word value be insufficient. Careful use of level.data and chaining/OnEnter hooks can also modify level behaviour in special modes (such as challenge modes) while keeping the level itself ignorant of the concept of a challenge.

Array Properties

Array Properties
flags[Level Flag] boolean Get or set level flags
light[coord][Light Flag] boolean Get or set cell light flags*
map[coord] cell Get or set cells on a map by cell id
hp[coord] byte Get or set cell HP values
  • As a special extension you can pass an area to level.light when setting flags and the procedure will automatically iterate through every coord
Personal tools