Difference between revisions of "Modding:level object (0.9.9.7)"
From DoomRL Wiki
Yaflhdztioxo (Talk | contribs) |
Yaflhdztioxo (Talk | contribs) |
||
(2 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | The ''level'' object in DoomRL pulls triple duty: it stores and publishes properties relevant to the current level, it provides access to the [[Modding:level API|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. | + | The ''level'' object in DoomRL pulls triple duty: it stores and publishes properties relevant to the current level, it provides access to the [[Modding:level API|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 == | ||
Line 7: | Line 7: | ||
|c2=padding:0px 2px; | |c2=padding:0px 2px; | ||
|c3=padding:0px 2px; | |c3=padding:0px 2px; | ||
− | |status |{{modarg|word}}|This is for use by level designers and is preserved after a level is exited. | + | |status |{{modarg|word}} |This is for use by level designers and is preserved after a level is exited. |
− | |name |{{modarg|string}}|This is the level name as displayed on the HUD. | + | |data |{{modarg|anything}}|This is for use by level designers. |
− | |name_number |{{modarg|word}}|This controls the "LevX" part of the level name. If zero, it won't be displayed. | + | |name |{{modarg|string}} |This is the level name as displayed on the HUD. |
− | |danger_level |{{modarg|word}}|Level generation parameter that usually corresponds to depth. | + | |name_number |{{modarg|word}} |This controls the "LevX" part of the level name. If zero, it won't be displayed. |
− | |style |{{modarg|byte}} | + | |danger_level |{{modarg|word}} |Level generation parameter that usually corresponds to depth. |
− | |<u>id</u> |{{modarg|string}}|The id of the current level | + | |style |{{modarg|byte}} |The style (tile set) used by the level generation functions. |
− | |<u>special_exit</u> |{{modarg|string}}|The id of the level that red stairs lead to | + | |<u>id</u> |{{modarg|string}} |The id of the current level |
+ | |<u>special_exit</u> |{{modarg|string}} |The id of the level that red stairs lead to | ||
|}} | |}} | ||
}} | }} | ||
− | == Properties == | + | |
+ | 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/[[Modding:level blueprint#level_onenteritem|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 == | ||
{{drltable|Array Properties|3|{{Table3Col | {{drltable|Array Properties|3|{{Table3Col | ||
|es=background: #333; | |es=background: #333; |
Latest revision as of 22:22, 23 December 2012
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