Class engine.generator.map.RoomsLoader
Generator interface that can use rooms
Methods
engine.generator.map.RoomsLoader:makePod (x, y, radius, room_id, data, floor, wall)
Easy way to make an irregular shaped room
engine.generator.map.RoomsLoader:roomParse (def)
Generates a basic (ascii) room definition (for use by function room generators)
engine.generator.map.RoomsLoader:roomFrom (id, x, is_lit, room)
Updates the map with data from a (ascii) room definition (for use by function room generators)
engine.generator.map.RoomsLoader:roomGen (room, id, lev, old_lev)
Generates (resolves) a room
engine.generator.map.RoomsLoader:roomPlace (room, id, x)
Use room data to update the map
engine.generator.map.RoomsLoader:roomAlloc (room, id, lev, old_lev, add_check)
Generate a room and place it (randomly) on the map
engine.generator.map.RoomsLoader:randDir (sx, sy)
Random tunnel dir (no diagonals)
engine.generator.map.RoomsLoader:tunnelDir (x1, y1, x2, y2)
Find the direction in which to tunnel (no diagonals)
engine.generator.map.RoomsLoader:markTunnel (x, y, xdir, ydir, id)
Marks a tunnel as a tunnel and the space behind it
engine.generator.map.RoomsLoader:canDoor (x, y)
Can we create a door (will it lead anywhere)
engine.generator.map.RoomsLoader:tunnel (x1, x2, id, virtual)
Tunnel between two points
Methods
- engine.generator.map.RoomsLoader:makePod (x, y, radius, room_id, data, floor, wall)
-
Easy way to make an irregular shaped room
Parameters:
- x
- y
- radius
- room_id
- data
- floor
- wall
- engine.generator.map.RoomsLoader:roomParse (def)
-
Generates a basic (ascii) room definition (for use by function room generators)
Parameters:
- def
- engine.generator.map.RoomsLoader:roomFrom (id, x, is_lit, room)
-
Updates the map with data from a (ascii) room definition (for use by function room generators)
Parameters:
- id the room id to reference
- x , y the position the room is being placed
- is_lit boolean to lite the room tiles
- room room definition (ascii format)
- engine.generator.map.RoomsLoader:roomGen (room, id, lev, old_lev)
-
Generates (resolves) a room
Parameters:
- room a room definition (if it's a function it will be called as room(self, id, lev, old_lev)
- id index of room for this generator
- lev level (number) to generate
- old_lev previous level (number) within the zone
Returns:
-
the room table or false
- engine.generator.map.RoomsLoader:roomPlace (room, id, x)
-
Use room data to update the map
Parameters:
- room a room definition
- id room index (count of rooms placed including this one)
- x , y coordinates (upper left) to place the room
Returns:
-
placement data: {id=id, x=placed x, y=placed y, cx=connection x, cy=connection y, room=room}
calls room.generator(x, y, is_lit) if present to update the map, otherwise copies the room map to the current map (unresolved grids will be replaced with '.' or 'floor' if possible)
calls room.onplace(room, zone, level, map, data), if it's defined, after update
- engine.generator.map.RoomsLoader:roomAlloc (room, id, lev, old_lev, add_check)
-
Generate a room and place it (randomly) on the map
Parameters:
- room a room definition
- id room index (count of rooms placed including this one)
- lev level (number) to generate
- old_lev previous level (number) within the zone
- add_check optional function(room, x, y) to call (return true) to allow the room to be generated
Returns:
-
the results of roomPlace
calls room.prefer_location(self.map), if defined, to obtain the first location to try to place the room (successive tries will be clustered around this location)
- engine.generator.map.RoomsLoader:randDir (sx, sy)
-
Random tunnel dir (no diagonals)
Parameters:
- sx
- sy
- engine.generator.map.RoomsLoader:tunnelDir (x1, y1, x2, y2)
-
Find the direction in which to tunnel (no diagonals)
Parameters:
- x1
- y1
- x2
- y2 HEX TODO ?
- engine.generator.map.RoomsLoader:markTunnel (x, y, xdir, ydir, id)
-
Marks a tunnel as a tunnel and the space behind it
Parameters:
- x
- y
- xdir
- ydir
- id Disable the many prints of tunnelling
- engine.generator.map.RoomsLoader:canDoor (x, y)
-
Can we create a door (will it lead anywhere)
Parameters:
- x
- y
- engine.generator.map.RoomsLoader:tunnel (x1, x2, id, virtual)
-
Tunnel between two points
Parameters:
- x1 , y1 starting coordinates
- x2 , y2 ending coordinates
- id tunnel id
- virtual
set true to mark the tunnel without changing terrain
tunnels according to the rules (based on the room_map):
goes around .special unless .can_open is true goes through .room unless .can_open == false tries to go around previous tunnels
places self:resolve('='), self:resolve('.') or self:resolve('floor')) on the tunnel path (never changes terrain if .room or .special are set)