diff options
| author | Eltrac <hi@guhub.cn> | 2025-03-04 10:53:17 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-03-04 10:53:17 +0800 |
| commit | 49cee6e05fa18b2fb8bbf93e1fc3b158dfe771ab (patch) | |
| tree | a578af7cfaa45904b42792dc7323a4fa6501ca62 /objects/room.lua | |
| parent | d3e5889fa9d93f612a2fd5817d4849e96221121a (diff) | |
chore: connect room with automatically chosen direction
Diffstat (limited to 'objects/room.lua')
| -rw-r--r-- | objects/room.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/objects/room.lua b/objects/room.lua index 12ea800..81d30ae 100644 --- a/objects/room.lua +++ b/objects/room.lua @@ -148,12 +148,17 @@ function Room:getDoorlessDirections() end function Room:connect(anotherRoom, way) - local door1, door2 - if type(way) == "number" then + -- if number (Direction enums) way = Ways[way] + elseif not way then + -- if no way set, randomly choose a doorless direction + local doorless = self:getDoorlessDirections() + if #doorless == 0 then return false end + way = Ways[utils.any(doorless)] end + -- connect room with determined direction local door1, door2 if Way[way] then local dir1, dir2 = Way[way][1], Way[way][2] |
