Modding:level API (0.9.9.7)
From DoomRL Wiki
Revision as of 19:58, 22 December 2012 by Yaflhdztioxo (Talk | contribs)
This page is pending. The below is a dump from earlier versions.
API
Level Interface | |
value | Level.property_get(string property) |
void | Level.property_set(property value, ) → string |
boolean | Level.flag_get(Level Flag flag) |
void | Level.flag_set(Level Flag flag, boolean value) |
value | Level.roll_weight(list list, integer sum) |
integer | Level.weight_list_sum(list list) |
void | Level.place_tile(table translation, string tile, integer x, integer y) |
void | Level.player(integer x, integer y) |
integer | Level.result(integer value) |
boolean | Level.eye_contact(Coord c1, Coord c2) |
boolean | Level.is_visible(Coord position) |
void | Level.nuke() |
void | Level.explosion(Coord position, integer radius, integer delay, integer damage_dice, integer damage_sides, Color color, Sound ID sound, DamageType damagetype, ExplosionFlag List flags, Cell ID content) |
Cell-specific functions | |
boolean | Level.light_flag_get(Coord position, LightFlag flag) |
void | Level.light_flag_set(Coord position, LightFlag flag, boolean value) |
integer | Level.hp_get(Coord position) |
void | Level.hp_set(Coord position, integer value) |
boolean | Level.is_corpse(Coord position) |
boolean | Level.scan(Area scan_area, Cell ID good) |
void | Level.fill(Cell ID cell, Area fill_area) |
void | Level.flood(Cell ID tile, Area flood_area) |
void | Level.scatter(Area scatter_area, Cell ID good, Cell ID fill, integer count) |
void | Level.scatter_put(Area scatter_area, table translation, string tile, Cell ID good, integer count) |
boolean | Level.push_cell(Coord c, Coord target, boolean quiet) |
Being-specific functions | |
Being | Level.get_being(integer index) |
Being | Level.get_being_by_uid(integer uid) |
Being | Level.drop_being(Being ID bid, Coord position) |
void | Level.drop_being_ext(table being, Coord position) |
Being | Level.summon(Being ID bid, integer count) |
Being | Level.area_summon(Area where, Being ID bid, integer count) |
void | Level.clear_being(Coord position) |
list, integer | Level.get_being_list() |
Being ID | Level.random_being() |
void | Level.flood_monster(Being ID bid, integer amount) |
void | Level.flood_monsters(integer amount) |
Being iterator | Level.beings() |
Being iterator | Level.beings_in_range(Coord position, integer range) |
Item-specific functions | |
Item | Level.get_item(integer index) |
Item | Level.get_item_by_uid(integer uid) |
Item | Level.drop_item(Item ID iid, Coord position) |
void | Level.drop_item_ext(table item, Coord position) |
Item | Level.drop(Item ID iid, integer count) |
Item | Level.area_drop(Area where, Item ID iid, integer count) |
void | Level.try_destroy_item(Coord c) |
list, integer | Level.get_item_list(integer max_level, integer unique_mult) |
Item ID | Level.roll_item_type(ItemType list itypes, integer max_level, integer unique_mod) |
Item ID | Level.roll_item(integer max_level, integer unique_mod) |
void | Level.flood_items(integer amount) |
Item iterator | Level.items() |
Item iterator | Level.items_in_range(Coord position, integer range) |
- Level.property_get(string property) → value
- Gets the value of the given level property. It is preferred to use the Lua dot indexing syntax instead.
- Level.property_set(property value, ) → string
- Sets the given level property to the given value. It is preferred to use the Lua dot indexing syntax instead.
- Level.flag_get(Level Flag flag) → boolean
- Level.flags[Level Flag flag] → boolean
- Determines the current state of the given level flag.
- Level.flag_set(Level Flag flag, boolean value)
- Level.flags[Level Flag flag] = boolean value
- Sets the given level flag to the given value.
- Level.roll_weight(list list, integer sum) → value
- Randomly chooses an item from the list according to the weight property of the list items. Sum must be the sum of the weights of all the list items.
- Level.weight_list_sum(list list) → integer
- Returns the sum of the weight properties of all the items in the list.
- Level.place_tile(table translation, string tile, integer x, integer y)
- Places the map tile given by translation and tile on the map at the position given by x and y. translation should be a table that maps single character strings to either cell ids, or to tables. These tables have their first array element be a cell id, but they may also contain a being andor item key that is mapped to a being or item id respectively. Level.drop_being_ext and Level.drop_item_ext syntax is allowed. tile should be a string of characters that are defined in translation. Line breaks correspond to line breaks on the map.
- Level.player(integer x, integer y)
- Sets the initial position of the player for a special or scripted level. This should be called in the Create hook; after that it has no meaningful effect.
- Level.result(integer value) → integer
- If value is given, updates the level's status and returns nil. If value is omitted, returns the current status.
- Level.eye_contact(Coord c1, Coord c2) → boolean
- Determines whether or not there is a line-of-sight path between c1 and c2. This calculation ignores light flags (such that two beings can have eye contact even if they aren't visible to each other).
- Level.is_visible(Coord position) → boolean
- Determines if the given position is visible to the player.
- Level.nuke()
- Triggers an immediate nuclear explosion as from a thermonuclear bomb.
- Level.explosion(Coord position, integer radius, integer delay, integer damage_dice, integer damage_sides, Color color, Sound ID sound, DamageType damagetype, ExplosionFlag List flags, Cell ID content)
- Creates an explosion centered at the given position with the given parameters. radius is the size of the explosion. delay is the delay in milliseconds between animation frames (typically this is around 40). damage_dice and damage_sides determine the damage roll for the explosion. For a no-damage explosion, both should be 0. The default damage type is fire. content determines the cell that is randomly created wherever the explosion does enough damage. By default, there are no flags and there is no content. Only some colors are supported, and these are automatically translated into 3 color combinations used by the explosion animation. The supported colors are LIGHTBLUE, BLUE, MAGENTA, GREEN, LIGHTRED, YELLOW, and the default RED.
- Level.light_flag_get(Coord position, LightFlag flag) → boolean
- Level.light[Coord position][LightFlag flag] → boolean
- Gets the value of the given light flag at the given position.
- Level.light_flag_set(Coord position, LightFlag flag, boolean value)
- Level.light[Coord position][LightFlag flag] = boolean value
- Level.light[LightFlag flag] = boolean value
- Sets the value of the given light flag at the given position. For the syntax without a position, the light flag will be set at every position on the map.
- Level.hp_get(Coord position) → integer
- Level.hp[Coord position] → integer
- Gets the current hp of the cell at the given position.
- Level.hp_set(Coord position, integer value)
- Level.hp[Coord position] = integer value
- Sets the current hp of the cell at the given position. Setting hp to 0 won't destroy a cell.
- Level.is_corpse(Coord position) → boolean
- Determines whether the given position has a corpse in it. This counts the cell with id "corpse" as a corpse even though it otherwise isn't a corpse as far as the engine is concerned.
- Level.fill(Cell ID cell, Area fill_area)
- Sets every cell in the given area to the area. fill_area is optional; it defaults to the full map.
- Level.flood(Cell ID tile, Area flood_area)
- Changes CELLSET_FLOORS and CF_LIQUID tiles in the area to tile. If tile has CF_HAZARD, then it will destroy items.
- Level.scatter(Area scatter_area, Cell ID good, Cell ID fill, integer count)
- Chooses count random tiles in scatter_area (possibly with duplicates) and sets any chosen cells that are good to fill.
- Level.scatter_put(Area scatter_area, table translation, string tile, Cell ID good, integer count)
- Chooses count random subareas with upper-left corner in scatter_area of the size appropriate of tile (using the first line length and number of lines to define a rectangular area). There may be duplicates or overlaps. For each subarea, if the area is already filled with good, then it is replaced with tile (according to translation). See Level.place_tile for the semantics of translation and tile.
- Level.push_cell(Coord c, Coord target, boolean quiet) → boolean
- Swaps the content of the cells located in c and target: this will only occur successfully if target is a part of CELLSET_FLOORS. If target has the CF_HAZARD flag, the cell on c activates its OnDestroy hook. quiet, when set to true, includes messages (mostly specific to barrels, the only object pushed in the base game).
- Level.get_being(integer index) → Being
- Returns the being at the given index in the sparse being array. A being's index won't change as long as it is in the array.
- Level.get_being_by_uid(integer uid) → Being
- Returns the being with the given uid, or nil if that being doesn't exist or has been removed from the map.
- Level.drop_being(Being ID bid, Coord position) → Being
- Drops a newly created being in the given position. bid can also be an actual being object, although this should not be used for beings that are already on the map. If the position is occupied, the being will be dropped nearby. The dropped being is returned. If the function fails, nil is returned.
- Level.drop_being_ext(table being, Coord position)
- As Level.drop_being, except additional values are accetable for being as Level.drop_item_ext.
- Level.summon(Being ID bid, integer count) → Being
- Creates new beings of the type given by bid and amount given by count and scatters them around the map. The last dropped being (if any) is returned. count is optional and defaults to 1.
- Level.area_summon(Area where, Being ID bid, integer count) → Being
- As Level.summon, but all the summoned beings are randomly placed in where rather than scattered across the whole map.
- Level.clear_being(Coord position)
- Level.clear_being(integer index)
- Removes an item from the map at the given position, or from the given index in the item array.
- Level.get_being_list() → list,integer
- Returns the list and sum (ready to be used with Level.roll_weight) for beings and beings groups according to Level.danger_level and DIFFICULTY. The result is cached.
- Level.random_being() → Being ID
- Returns a random being chosen according to weights from the current level's list. This will never choose a group. The returned id is always a string id.
- Level.flood_monster(Being ID bid, integer amount)
- Add the given monster type to the level in an amount specified by the total danger value amount (so it scales appropriately with Level.flood_monsters).
- Level.flood_monsters(integer amount)
- Adds monsters to the level using the normal algorithm for random levels. The amount is a total danger value such as a value returned by Generator.being_weight.
- Level.beings() → Being iterator
- Gives an iterator over all beings in the level.
- Level.beings_in_range(Coord position, integer range) → Being iterator
- Gives an iterator over all beings within range units of distance from position in the level.
- Level.get_item(integer index) → Item
- Returns the item at the given index in the sparse item array. An item's index won't change as long as it is in the array.
- Level.get_item_by_uid(integer uid) → Item
- Returns the item with the given uid, or nil if that item doesn't exist or has been removed from the map.
- Level.drop_item(Item ID iid, Coord position) → Item
- Drops a newly created item in the given position. iid can also be an actual item object, although this should not be used for items that are already on the map. If the position is occupied, the item will be dropped nearby. The dropped item is returned. If the function fails, nil is returned.
- Level.drop_item_ext(table item, Coord position)
- As Level.drop_item, except additional values are acceptable for item. If item is a table, the first list element is passed used to determine which item to drop. For other key-value pairs in the table, the property of the dropped item that corresponds to the key will be set to the value.
- Level.drop(Item ID iid, integer count) → Item
- Creates new items of the type given by iid and amount given by count and scatters them around the map. The last dropped item (if any) is returned. count is optional and defaults to 1.
- Level.area_drop(Area where, Item ID iid, integer count) → Item
- As Level.drop, but all dropped items are randomly placed in where rather than scattered across the whole map.
- Level.try_destroy_item(Coord c)
- Destroys an item at position, if there is one to be found.
- Level.get_item_list(integer max_level, integer unique_mult) → list,integer
- Returns the list and sum (ready to be used with Level.roll_weight) for items according to max_level, and unique_mult. max_level defaults to Level.danger_level, and is used to determine which items fall in the proper level range. Unique items' weights are multiplied by unique_mult (which defaults to 1). The result is cached.
- Level.roll_item_type(ItemType list itypes, integer max_level, integer unique_mod) → Item ID
- Returns a random item chosen from among the given item types according to weights from the list specified by max_level and unique_mod. The returned id is always a string id.
- Level.roll_item(integer max_level, integer unique_mod) → Item ID
- As Level.roll_item_type, but the item type of the result isn't restricted.
- Level.flood_items(integer amount)
- Adds items to the level according to the normal algorithm for random levels (not counting special features). The number of items is given by amount.
- Level.items() → Item iterator
- Gives an iterator over all items in the level.
- Level.items_in_range(Coord position, integer range) → Item iterator
- Gives an iterator over all items within range units of distance from position in the level.