From 49cee6e05fa18b2fb8bbf93e1fc3b158dfe771ab Mon Sep 17 00:00:00 2001 From: Eltrac Date: Tue, 4 Mar 2025 10:53:17 +0800 Subject: chore: connect room with automatically chosen direction --- objects/room.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'objects/room.lua') 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] -- cgit v1.2.3