summaryrefslogtreecommitdiff
path: root/objects/room.lua
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-03-07 21:01:24 +0800
committerEltrac <hi@guhub.cn>2025-03-07 21:01:24 +0800
commitfb8a5d0fbff6fc480a6d507578826690b2585926 (patch)
tree11f0a8aa97a3a1d404fdf8e689509b99e2b0f3e3 /objects/room.lua
parent1693be759251b7b294d4c54379e1f513ef012a92 (diff)
refactor: clearer logic of determining door connection direction
Diffstat (limited to 'objects/room.lua')
-rw-r--r--objects/room.lua9
1 files changed, 8 insertions, 1 deletions
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