Module ROT.Map.Room

Room object.

Used by ROT.Map.Uniform and ROT.Map.Digger to create maps

Functions

init (x1, y1, x2, y2[, doorX[, doorY]]) Constructor.
createRandomAt (x, y, dx, dy, options, rng) Create Random with position.
createRandomCenter (cx, cy, options, rng) Create Random with center position.
createRandom (availWidth, availHeight, options, rng) Create random with no position.
addDoor (x, y) Place a door.
getDoors (callback) Get all doors.
clearDoors () Reset the room's _doors table.
addDoors (isWallCallback) Add all doors based on available walls.
debug () Write various information about this room to the console.
isValid (isWallCallback, canBeDugCallback) Use two callbacks to confirm room validity.
create (digCallback) Create.
getCenter () Get center cell of room
getLeft () Get Left most floor space.
getRight () Get right-most floor space.
getTop () Get top most floor space.
getBottom () Get bottom-most floor space.


Functions

init (x1, y1, x2, y2[, doorX[, doorY]])
Constructor. creates a new room object with the assigned values

Parameters:

  • x1 int Left wall
  • y1 int Upper wall
  • x2 int Right wall
  • y2 int Bottom wall
  • doorX int x-position of door (optional)
  • doorY int y-position of door (optional)
createRandomAt (x, y, dx, dy, options, rng)
Create Random with position.

Parameters:

  • x int x-position of room
  • y int y-position of room
  • dx int x-direction in which to build room 1==right -1==left
  • dy int y-direction in which to build room 1==down -1==up
  • options Options
    • roomWidth table minimum/maximum width for room {min,max}
    • roomHeight table minimum/maximum height for room {min,max}
  • rng userData A user defined object with a .random(self, min, max) method (optional)
createRandomCenter (cx, cy, options, rng)
Create Random with center position.

Parameters:

  • cx int x-position of room's center
  • cy int y-position of room's center
  • options Options
    • roomWidth table minimum/maximum width for room {min,max}
    • roomHeight table minimum/maximum height for room {min,max}
  • rng userData A user defined object with a .random(min, max) method (optional)
createRandom (availWidth, availHeight, options, rng)
Create random with no position.

Parameters:

  • availWidth int Typically the width of the map.
  • availHeight int Typically the height of the map
  • options Options
    • roomWidth table minimum/maximum width for room {min,max}
    • roomHeight table minimum/maximum height for room {min,max}
  • rng userData A user defined object with a .random(min, max) method (optional)
addDoor (x, y)
Place a door. adds an element to this rooms _doors table

Parameters:

  • x int the x-position of the door
  • y int the y-position of the door
getDoors (callback)
Get all doors. Runs the provided callback on all doors for this room

Parameters:

  • callback function A function with two parameters (x, y) representing the position of the door.
clearDoors ()
Reset the room's _doors table.

Returns:

    ROT.Map.Room self
addDoors (isWallCallback)
Add all doors based on available walls.

Parameters:

  • isWallCallback function

Returns:

    ROT.Map.Room self
debug ()
Write various information about this room to the console.
isValid (isWallCallback, canBeDugCallback)
Use two callbacks to confirm room validity.

Parameters:

  • isWallCallback function A function with two parameters (x, y) that will return true if x, y represents a wall space in a map.
  • canBeDugCallback function A function with two parameters (x, y) that will return true if x, y represents a map cell that can be made into floorspace.

Returns:

    boolean true if room is valid.
create (digCallback)
Create. Function runs a callback to dig the room into a map

Parameters:

  • digCallback function The function responsible for digging the room into a map.
getCenter ()
Get center cell of room

Returns:

    table {x-position, y-position}
getLeft ()
Get Left most floor space.

Returns:

    int left-most floor
getRight ()
Get right-most floor space.

Returns:

    int right-most floor
getTop ()
Get top most floor space.

Returns:

    int top-most floor
getBottom ()
Get bottom-most floor space.

Returns:

    int bottom-most floor
generated by LDoc 1.4.6 Last updated 2017-07-19 18:43:03