Class Room
Methods
room:init (width, height, shape, decorator) | Initiate a room. |
room:build (shape) | Creates the basic structure of the room and places it on the map |
room:clear (noWalls, alsoItems) | Clear a room's decorator and remove all features |
room:build_walls (featureID) | Places walls in all the tiles in the room's walls table, in case the room was built somewhere without walls featureID String. |
room:can_decorate (decID) | Determine if a given decorator can be used to decorate this room |
room:decorate (decID, notPrimary, args) | Decorate a room |
room:populate_creatures (creatTotal, forceGeneric) | Randomly add creatures to the map |
room:populate_items (itemTotal, forceGeneric) | Randomly add items to the room |
room:get_possible_doors (exclude_rooms, exclude_hallways) | Gets a list of possible walls that could be turned into doors (ie there's open space on both sides) |
room:get_creature_list (Table.) | Gets a list of creatures that can spawn in the room. |
room:get_target_threat () | Returns the threat value that should populate in the room |
room:get_current_threat () | Returns the current threat value in the room |
room:get_current_value (printVals) | Returns the current value of all items the room |
room:get_content_tags (tagType) | Get a map's content tags |
room:has_content_tag (tag, tagType) | Checks if a map has a given content tag |
room:has_tag (tag) | Checks if a map has a descriptive tag. |
room:get_all_safe_to_block (openType) | Gets all the "safe to block" tiles in a room. |
room:get_largest_internal_rectangle () | Gets the largest available rectangle in the room while |
room:get_neighbors (force_refresh.) | Gets a list of all rooms that border a room |
room:get_distances (force_refresh.) | Gets a list of distances to all rooms |
room:connect (info) | Connect a room to other rooms. |
room:connect_to_room (partner, info) | Build a hallway from one room to another room |
room:callbacks (callback_type, Anything.) | Checks the callbacks of the room |
Methods
- room:init (width, height, shape, decorator)
-
Initiate a room. You shouldn't use this function, the game uses it at loadtime to instantiate the conditions.
Parameters:
- width Number. The width of the room.
- height Number. The height of the room.
- shape String, Table, or False. The name of the room shape, a table of possible shapes or False. Optional, if blank will just select a random one. If False, will not build the room at all yet, just create a blank room entry
- decorator String or Table. The name of the room decorator, or a table of possible decorators. Optional. If provided, the room will go ahead and decorate itself using it, if blank, it will just be an empty room
Returns:
-
Room. The room itself.
- room:build (shape)
-
Creates the basic structure of the room and places it on the map
Parameters:
- shape
- room:clear (noWalls, alsoItems)
-
Clear a room's decorator and remove all features
Parameters:
- noWalls Boolean. If true, don't call build_walls
- alsoItems Boolean. If true, delete items as well, otherwise preserve them
- room:build_walls (featureID)
-
Places walls in all the tiles in the room's walls table, in case the room was built somewhere without walls
featureID String. The ID of the feature to use for the wall
Parameters:
- featureID
- room:can_decorate (decID)
-
Determine if a given decorator can be used to decorate this room
Parameters:
- decID String. The ID of the given decorator
Returns:
-
Boolean. Whether or not this decorator can be used on this room
- room:decorate (decID, notPrimary, args)
-
Decorate a room
Parameters:
- decID String or table. Either the ID of a specific room decorator, or a table of room decorator IDs. Optional
- notPrimary Boolean. If true, don't assign this decorator's ID to the room's decorator ID (ie this is PURELY for decoration, will not be used for creature/item generation)
- args Anything. Arguments to pass to the decorator
- room:populate_creatures (creatTotal, forceGeneric)
-
Randomly add creatures to the map
Parameters:
- creatTotal Number. The number of creatures to add. Optional, if blank will generate enough to meet the necessary density
- forceGeneric Boolean. Whether to ignore any special populate_creatures() code in the room decorator's code. Optional
- room:populate_items (itemTotal, forceGeneric)
-
Randomly add items to the room
Parameters:
- itemTotal Number. The number of items to add. Optional, if blank will generate enough to meet the necessary density
- forceGeneric Boolean. Whether to ignore any special populate_items() code in the room decorator's code. Optional
- room:get_possible_doors (exclude_rooms, exclude_hallways)
-
Gets a list of possible walls that could be turned into doors (ie there's open space on both sides)
Parameters:
- exclude_rooms
- exclude_hallways
Returns:
-
Table. A table of possible doors, in the format {n={{x=x,y=y},{x=x,y=y}},s={},e={},w={}}
- room:get_creature_list (Table.)
-
Gets a list of creatures that can spawn in the room.
Parameters:
- Table. A table listing the creatures
- room:get_target_threat ()
-
Returns the threat value that should populate in the room
Returns:
-
Number. The threat value that should be placed in the room
- room:get_current_threat ()
-
Returns the current threat value in the room
Returns:
-
Number. The threat value of all content in the room
- room:get_current_value (printVals)
-
Returns the current value of all items the room
Parameters:
- printVals
Returns:
-
Number. The value of all items in the room
- room:get_content_tags (tagType)
-
Get a map's content tags
Parameters:
- tagType String. The type of tag
- room:has_content_tag (tag, tagType)
-
Checks if a map has a given content tag
Parameters:
- tag String. The tag to check for
- tagType String. The type of tag
Returns:
-
Boolean. Whether or not it has the tag.
- room:has_tag (tag)
-
Checks if a map has a descriptive tag.
Parameters:
- tag String. The tag to check for
Returns:
-
Boolean. Whether or not it has the tag.
- room:get_all_safe_to_block (openType)
-
Gets all the "safe to block" tiles in a room. Takes a list of tiles and runs map:is_safe_to_block on them.
Parameters:
- openType Text. Determines what counts as "safe." "wall": next to wall only, "noWalls": not next to wall, "wallsCorners": open walls and corners only, "corners": corners only
Returns:
-
Table. A table of tiles deemed safe to block.
- room:get_largest_internal_rectangle ()
- Gets the largest available rectangle in the room while
- room:get_neighbors (force_refresh.)
-
Gets a list of all rooms that border a room
Parameters:
- force_refresh. If true, calculate neighbors again
Returns:
-
Table. A table of rooms bordering this room
- room:get_distances (force_refresh.)
-
Gets a list of distances to all rooms
Parameters:
- force_refresh. If true, calculate neighbors again
Returns:
-
Table. A table of rooms bordering this room
- room:connect (info)
-
Connect a room to other rooms. First, checks any neighboring rooms, and creates doors between them. If it doesn't manage that, then create hallways
Parameters:
- info Table. A table of info
- room:connect_to_room (partner, info)
-
Build a hallway from one room to another room
Parameters:
- partner Room. The room to connect it to
- info Table. Table of info
Returns:
-
Boolean. Whether the connection was successful
- room:callbacks (callback_type, Anything.)
-
Checks the callbacks of the room
Parameters:
- callback_type String. The callback type to check.
- Anything. Any info you want to pass to the callback. Each callback type is probably looking for something specific (optional)
Returns:
- Boolean. If any of the callbacks returned true or false.
- Table. Any other information that the callbacks might return.