From f97a26c02068aac19ce55d6d33583d6ee17f5b4a Mon Sep 17 00:00:00 2001 From: Lily Carpenter Date: Mon, 11 Sep 2023 22:37:13 -0500 Subject: [PATCH] Bugfix: Use coherent method to determine if no stranded units --- warn-stranded.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/warn-stranded.lua b/warn-stranded.lua index 5e331def13..c6bb782a45 100644 --- a/warn-stranded.lua +++ b/warn-stranded.lua @@ -185,7 +185,7 @@ local function compareGroups(group_one, group_two) end local function getStrandedUnits() - local grouped = { n = 0 } + local groupCount = 0 local citizens = dfhack.units.getCitizens() -- Don't use ignored units to determine if there are any stranded units @@ -202,12 +202,14 @@ local function getStrandedUnits() table.insert(ensure_key(ignoredGroup, walkGroup), unit) else table.insert(ensure_key(grouped, walkGroup), unit) - grouped['n'] = grouped['n'] + 1 + if #grouped[walkGroup] == 1 then + groupCount = groupCount + 1 + end end end -- No one is stranded, so stop here - if grouped['n'] <= 1 then + if groupCount <= 1 then return false, {} end