diff options
| author | Eltrac <hi@guhub.cn> | 2025-03-07 22:54:43 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-03-07 22:54:43 +0800 |
| commit | a47d91f0dbd92a0c182d9a60e390930b3356a077 (patch) | |
| tree | b21cff978127bba7bad7c4ec6c55e2f10799986b /objects/room.lua | |
| parent | 630365ae1308c6a8784c5f2b41db3c36107226f3 (diff) | |
fix: some rooms are not accessible due to door misplacement
Diffstat (limited to 'objects/room.lua')
| -rw-r--r-- | objects/room.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/objects/room.lua b/objects/room.lua index 5d113f9..1d2bfa2 100644 --- a/objects/room.lua +++ b/objects/room.lua @@ -147,13 +147,19 @@ function Room:connect(anotherRoom, way) -- determine directions -- if not specified, choose randomly - local directions + 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())]] + local dd1 = self:getDoorlessDirections() + local dd2 = anotherRoom:getDoorlessDirections() + + repeat + directions[1] = utils.any(dd1) + directions[2] = OppositeDirection[directions[1]] + until utils.contains(dd2, directions[2]) end if not directions then return false end |
