Difference between revisions of "Modding:level object (0.9.9.7)"

From DoomRL Wiki

Jump to: navigation, search
(Created page with "This page is pending. The below is a dump from earlier versions. === Flags === {{drltable|Level Flags|2|{{Table2Col |es=background: #333; |c1=font-family:monospace; text-a...")
 
 
(5 intermediate revisions by one user not shown)
Line 1: Line 1:
This page is pending.  The below is a dump from earlier versions.
+
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 ==
=== Flags ===
+
{{drltable|Properties |3|{{Table3Col
{{drltable|Level Flags|2|{{Table2Col
+
 
   |es=background: #333;
 
   |es=background: #333;
 
   |c1=font-family:monospace; text-align:right; vertical-align:top; padding:0px 2px;
 
   |c1=font-family:monospace; text-align:right; vertical-align:top; padding:0px 2px;
 
   |c2=padding:0px 2px;
 
   |c2=padding:0px 2px;
   |LF_NOHOMING|Causes homing phase devices to act like normal phase devices.
+
   |c3=padding:0px 2px;
   |LF_UNIQUEITEM|Used by the level generation code to keep track of whether a unique item has dropped on the current level (in order to prevent multiple uniques from dropping on one level). This flag also causes a level feeling to occur indicating that a unique item is present.
+
   |status              |{{modarg|word}}    |This is for use by level designers and is preserved after a level is exited.
   |LF_BONUS|This flag is automatically set for so-called special levels like [[Halls of Carnage]]. (It is not set for those special levels like [[Hellgate]] that replace normal levels, only by those reached from red stairs.)
+
   |data                |{{modarg|anything}}|This is for use by level designers.
   |LF_RESPAWN|Causes monsters to randomly respawn as when playing the game on Nightmare!
+
   |name                |{{modarg|string}}  |This is the level name as displayed on the HUD.
   |LF_NORESPAWN|Prevents the Nightmare! respawn feature.
+
   |name_number        |{{modarg|word}}    |This controls the "LevX" part of the level name. If zero, it won't be displayed.
   |LF_NUKED|This flag is automatically set when the level is nuked.
+
   |danger_level        |{{modarg|word}}    |Level generation parameter that usually corresponds to depth.
   |LF_NONUKE|Causes the thermonuclear bomb to have no effect when it is used. It is not respected by other nuke effects.
+
   |style              |{{modarg|byte}}    |The style (tile set) used by the level generation functions.
   |LF_ITEMSVISIBLE|Allows the player to see all items on the level (as with a [[Computer Map]]).
+
   |<u>id</u>          |{{modarg|string}}  |The id of the current level
   |LF_BEINGSVISIBLE|Allows the player to see all beings on the level (as with a [[Tracking Map]]).
+
   |<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.
These are properties of the global Level variable. They are changed by the engine as the player moves from level to level. For some of the read-only properties, rawset can be used to create a lua property that shadows the pascal property, tricking APIs that are implemented in lua. This is particularly useful for tricking the generator API into using a custom style.
+
 
{|class="wikitable" style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
+
== Array Properties ==
! colspan="3" style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Level'''
+
{{drltable|Array Properties|3|{{Table3Col
{{Table3Col
+
 
   |es=background: #333;
 
   |es=background: #333;
   |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
+
   |c1=font-family:monospace; text-align:right; vertical-align:top; padding:0px 2px;
   |c2=vertical-align:top; padding:0px 2px;
+
   |c2=padding:0px 2px;
 
   |c3=padding:0px 2px;
 
   |c3=padding:0px 2px;
   |Word|status|This is for use by level designers. It is preferred to access it through Level.result.
+
   |flags[{{modarg|Level Flag}}]|{{modarg|boolean}}|Get or set level flags
  |string|name|This is the level name as displayed on the HUD.
+
   |light[{{modarg|coord}}][{{modarg|Light Flag}}]|{{modarg|boolean}}|Get or set cell light flags*
   |Byte|name_number|This controls the "LevX" part of the level name. If zero, it won't be displayed.
+
   |map[{{modarg|coord}}]|{{modarg|cell}}|Get or set cells on a map by cell id
  |Byte|danger_level|Level generation parameter that corresponds to depth.
+
   |hp[{{modarg|coord}}]|{{modarg|byte}}|Get or set cell HP values
   |Byte|style|The style (tile set) used by the level generation functions. This property is read-only.
+
   |}}
   |string|special_exit|The sid of the level that red stairs lead to on the current level number. This property is read-only.
+
}}
  |string|special_name|The sid of the current level prototype or the empty string for random levels. This property is read-only.
+
 
   |DWord|item_array_size|Length of the sparse array that stores all the items on the level. This property is read-only.
+
* As a special extension you can pass an area to level.light when setting flags and the procedure will automatically iterate through every coord
  |DWord|being_array_size|Length of the sparse array that stores all the beings on the level. This property is read-only.
+
}}
+
|}
+

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
Personal tools