From fb8a5d0fbff6fc480a6d507578826690b2585926 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 7 Mar 2025 21:01:24 +0800 Subject: refactor: clearer logic of determining door connection direction --- objects/room.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'objects/room.lua') diff --git a/objects/room.lua b/objects/room.lua index 3176e0c..aa77f8d 100644 --- a/objects/room.lua +++ b/objects/room.lua @@ -174,7 +174,14 @@ function Room:connect(anotherRoom, way) -- determine directions -- if not specified, choose randomly - local directions = Way[way or Ways[way or utils.any(self:getDoorlessDirections())]] + local directions + if type(way) == "string" then + directions = Way[way] + elseif type(way) == "number" then + directions = Way[Ways[way]] + else + directions = Way[Ways[utils.any(self:getDoorlessDirections())]] + end if not directions then return false end -- connect room with determined direction -- cgit v1.2.3