Loading

Paste #p9ffxs9pv

  1. --[[
  2. This function checks if a tile has no entity on it and (optionally) if it is not
  3. in a room.
  4. !param x (integer) the queried tile's x coordinate.
  5. !param y (integer) the queried tile's y coordinate.
  6. !param not_in_room (boolean) If set, also check the tile is not in a room.
  7. !return (boolean) whether all checks hold.
  8. --]]
  9. function World:isTileEmpty(x, y, not_in_room)
  10.   for _, entity in ipairs(self.entities) do
  11.     if entity.tile_x == x and entity.tile_y == y then
  12.       return false
  13.     end
  14.   end
  15.   if not_in_room then
  16.     return self:getRoom(x, y) == nil
  17.   end
  18.   return true
  19. end

Comments