Module mapgen
Functions
Functions
- generate_map (branchID, depth, force)
-
Create and populate a map
Parameters:
- branchID Text. The branch ID the map is part of
- depth Number. At what depth of said branch the map occurs on
- force Text. The ID of a mapType to force this map to be. Optional
Returns:
-
Map. The fresh new map
- generate_creature (min_level, max_level, list, tags, allowAll)
-
Initializes and creates a new creature at the given level. The creature itself must then actually be added to a map using Map:add_creature()
Parameters:
- min_level The lower level limit of the desired creature
- max_level The upper level limit of the desired creature
- list Table. A specific list of creatures to choose from. Optional
- tags Table. A list of tags to pass to the creature
- allowAll Boolean. If True, creatures with the specialOnly flag can still be chosen (but bosses or creatures with the neverSpawn flag set still cannot). Optional
Returns:
-
Creature. The new creature
- generate_item (min_level, max_level, list, tags, allowAll, enchantment_chance, artifact_chance)
-
Initializes and creates a new item at the given level. The item itself must then actually be added to the map using Map:add_item()
Parameters:
- min_level The lower level limit of the desired item
- max_level The upper level limit of the desired item
- list Table. A list of possible items to pull from
- tags Table. A list of tags, potentially to pass to the item, or to use as preference for enchantments
- allowAll Boolean. If True, items with the specialOnly flag can still be chosen (but items with the neverSpawn flag set still cannot). Optional
- enchantment_chance Number. The chance of the item spawning with an enchantment
- artifact_chance Number. The chance of the item spawning as an artifact
Returns:
-
Item. The new item
- generate_items_from_item_group (groupID, amount, passedTags)
-
Generate an item from an item group
Parameters:
- groupID String. The item group list
- amount Number. The number of items to generate
- passedTags Table. A table of tags to pass to the new items
Returns:
-
Table. A table of generated items
- make_artifact (item, tags)
-
Turns an item into a random artifact
Parameters:
- item Item. The item to turn into an artifact
- tags Table. A list of tags, used to prioritize enchantments which match said tags (optional)
- generate_branch (branchID, args)
-
Creates an instance of a branch, to be attached to a given playthrough
Parameters:
- branchID Text. The ID of the branch
- args Anything. Arguments to pass to the branch
Returns:
-
Table. The information for the new branch
- floodFill (map, lookFor, startX, startY, noRandom)
-
Perform a floodfill operation, getting all walls or floor that touch. Only works for walls and floor, not features.
Parameters:
- map Map. The map to look at
- lookFor String. "." or "#" for floors or walls, or the ID of a feature. Defaults to "."
- startX Number. The X-coordinate to start at. Optional, will pick a randon tile if blank
- startY Number. The Y-coordinate to start at. Optional, will pick a random tile if blank
- noRandom Boolean. If true, don't hop to a random tile if the initial tile doesn't match
Returns:
- Table. A table covering the whole map, in the format Table[x][y] = true or false, for whether the given tile matches lookFor
- Number. The number of tiles found
- floodTile (map, x, y, floodFill, lookFor, numTiles, check)
-
Looks at the tiles next to a given tile, to see if they match. Used by the floodFill() function, probably shouldn't be used by itself.
Parameters:
- map Map. The map to look at
- x Number. The X-coordinate to look at
- y Number. The Y-coordinate to look at
- floodFill Table. The table of floodFill values.
- lookFor String. "." or "#" for floors or walls, or the ID of a feature. Defaults to "."
- numTiles Number. The number of tiles currently matching the floodfill criteria
- check Table. A table full of values to be checked.
Returns:
- Table. A table covering the whole map, in the format Table[x][y] = true or false, for whether the given tile matches lookFor
- Number. The number of tiles found
- Table. A table full of values that still need to be checked
- addRiver (map, tile, noBridges, bridgeData, minDist)
-
Add a river to a map.
Parameters:
- map Map. The map to add the river to
- tile Feature. The feature to use to fill the river
- noBridges Boolean. If set to True, don't make bridges over the river. Otherwise, make bridges. Optional
- bridgeData Anything. Arguments to pass to the bridge's new() function. Optional
- minDist Number. The minimum distance that must be between bridges. Optional, defaults to 5.
Returns:
-
Table. A table of the tiles along the river's shore.
- buildBridge (map, fromX, fromY, toX, toY, data)
-
Add a bridge
Parameters:
- map Map. The map to add edges to.
- fromX Number. The x-coordinate to start at
- fromY Number. The y-coordinate to start at
- toX Number. The x-coordinate to end at
- toY Number. The y-coordinate to end at
- data Anything. The data to pass to the bridge's new() function
- makeEdges (map, width, height, onlyFeature)
-
Add jagged edges to the borders of the map, to make it more visually interesting than just flat walls.
Parameters:
- map Map. The map to add edges to.
- width Number. The width of the map.
- height Number. The height of the map.
- onlyFeature Text. If this is left blank, the new walls will be created no matter what. If it's the ID of a feature, the walls will only be created if the tile has that feature on it.
- addGenericStairs (build, width, height)
-
Randomly add stairs to the map, generally on opposite sides.
Parameters:
- build Map. The map to add the stairs to.
- width Number. The width of the map
- height Number. The height of the map
- get_stair_location (map)
-
Get coordinates for a
Parameters:
- map Map. The map to look at to build stairs
- addTombstones (map)
-
Add tombstones to the map of previous player characters who have died here.
Parameters:
- map Map. The map to add the tombstones to.
- make_blob (map, startX, startY, feature, decay, includeWalls)
-
Make a procedurally-generated blob on the map
Parameters:
- map Map. The map to make the blob on
- startX Number. The starting X coordinate
- startY Number. The starting Y coordinate
- feature Text. The ID of the feature to make the blob out of
- decay Number. The % by which to decrease the chance that after a tile is made part of the blob, the next tiles will also be made part of the blob. Optional, defaults to 10
- includeWalls Boolean. Whether or not walls will be absorbed by the blob. Optional, if blank, the blob will form around walls
Returns:
-
Table. A table of tile coordinates that are part of the blob
- contourBomb (map, tiles, iterations)
-
"Contour-bombs" open tiles, basically drawing open circles around tiles to make a more organic-looking space.
Parameters:
- map Map. The map we're operating on.
- tiles Table. A table of the tiles to look at. Optional, defaults to all tiles in the map
- iterations The number of times to run the bombing. Optional, defaults to the count of the tiles multiplied by a number between 2 and 5.
- get_content_list_from_tags (content_type, tags, args, forbiddenTags, requiredTags, mapTags, searchSet)
-
Gets a list of all types of content
Parameters:
- content_type String. The type of content to look for. Creature, feature, item, spell, store, faction, roomDecorator, roomShape, recipe
- tags Table. Content that has ANY of these tags will be included.
- args Table. Other potential arguments. Can include:
- forbiddenTags Table. Content with ANY these tags will be excluded
- requiredTags Table. Content that doesn't have ALL of these tags will be excluded
- mapTags Table. The tags from the map. Not used to search for content, but used for the item's own requiredMapTags and forbiddenMapTags
- searchSet Table. A list of IDs to search through for the given content_type. If blank, search through all of the possibilities in the game
- can_place_room (minX, minY, maxX, maxY, map)
-
Determines whether you can place a room in a location
Parameters:
- minX Number. The minimum X value of the room.
- minY Number. The minimum Y value of the room.
- maxX Number. The maximum X value of the room.
- maxY Number. The maximum Y value of the room.
- map Map. The map to create the room on.
- get_largest_room_from_anchor_point (startX, startY, direction, map, max_width, max_height, min_width, min_height, centered)
-
Determines the largest free room area starting from a given point
Parameters:
- startX Number. The X coordinate to anchor off of
- startY Number. The Y coordinate to anchor off of
- direction String. The direction to look in
- map Map. The map to create the room on
- max_width Number. The maximum width of the room
- max_height Number. The maximum height of the room
- min_width Number. The minimum width of the room
- min_height Number. The minimum height of the room
- centered Boolean. If true, the room must be centered on the anchor point
Returns:
-
Table or false. {minX=minX,minY=minY,maxX=maxX,maxY=maxY}
- generate_encounter (threat, creature_list, min_level, max_level, tags, max_creatures)
-
Creates an encounter at a given threat level
Parameters:
- threat Number.
- creature_list Table. A list of possible creatures.
- min_level The lower level limit of the desired creature
- max_level The upper level limit of the desired creature
- tags Table. A list of tags to pass to the creature
- max_creatures Number. The maximum number of creatures
Returns:
-
Table. A table of creatures to place.