From 1338c4d9ac9e1f7ed64abd1154e584390eaede99 Mon Sep 17 00:00:00 2001 From: iTracerFacer <134304944+iTracerFacer@users.noreply.github.com> Date: Tue, 4 Nov 2025 09:58:11 -0600 Subject: [PATCH] =?UTF-8?q?In=20Moose=5FCTLD.lua=20within=20Build=20Here?= =?UTF-8?q?=20flow:=20If=20BuildRequiresGroundCrates=20is=20true=20and=20t?= =?UTF-8?q?he=20helo=20has=20loaded=20crates,=20the=20script=20now=20shows?= =?UTF-8?q?:=20=E2=80=9CInsufficient=20ground=20crates=20to=20build=20here?= =?UTF-8?q?.=20You=20have=20X=20loaded=20crate(s)=20onboard=20=E2=80=94=20?= =?UTF-8?q?drop=20them=20first=20(F10=20->=20Drop=20Loaded=20Crates).?= =?UTF-8?q?=E2=80=9D=20Otherwise=20it=20falls=20back=20to=20the=20generic:?= =?UTF-8?q?=20=E2=80=9CInsufficient=20crates=20to=20build=20any=20asset=20?= =?UTF-8?q?here.=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Moose_CTLD_Pure/Moose_CTLD.lua | 34 +++++++++++++------ .../init_mission_dual_coalition.lua | 3 +- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Moose_CTLD_Pure/Moose_CTLD.lua b/Moose_CTLD_Pure/Moose_CTLD.lua index 65873b1..f265b0e 100644 --- a/Moose_CTLD_Pure/Moose_CTLD.lua +++ b/Moose_CTLD_Pure/Moose_CTLD.lua @@ -36,6 +36,7 @@ CTLD.Config = { MessageDuration = 15, -- seconds for on-screen messages Debug = false, PickupZoneSmokeColor = trigger.smokeColor.Green, -- default smoke color when spawning crates at pickup zones + BuildRequiresGroundCrates = true, -- if true, all required crates must be on the ground (won't count/consume carried crates) -- Hover pickup configuration (Ciribob-style inspired) HoverPickup = { @@ -519,22 +520,26 @@ function CTLD:BuildAtGroup(group) -- Include loaded crates carried by this group local gname = group:GetName() local carried = CTLD._loadedCrates[gname] - if carried and carried.byKey then - for k,v in pairs(carried.byKey) do - counts[k] = (counts[k] or 0) + v + if self.Config.BuildRequiresGroundCrates ~= true then + if carried and carried.byKey then + for k,v in pairs(carried.byKey) do + counts[k] = (counts[k] or 0) + v + end end end -- Helper to consume crates of a given key/qty local function consumeCrates(key, qty) local removed = 0 - -- Consume from loaded crates first - if carried and carried.byKey and (carried.byKey[key] or 0) > 0 then - local take = math.min(qty, carried.byKey[key]) - carried.byKey[key] = carried.byKey[key] - take - if carried.byKey[key] <= 0 then carried.byKey[key] = nil end - carried.total = math.max(0, (carried.total or 0) - take) - removed = removed + take + -- Optionally consume from carried crates + if self.Config.BuildRequiresGroundCrates ~= true then + if carried and carried.byKey and (carried.byKey[key] or 0) > 0 then + local take = math.min(qty, carried.byKey[key]) + carried.byKey[key] = carried.byKey[key] - take + if carried.byKey[key] <= 0 then carried.byKey[key] = nil end + carried.total = math.max(0, (carried.total or 0) - take) + removed = removed + take + end end for _,c in ipairs(nearby) do if removed >= qty then break end @@ -603,6 +608,15 @@ function CTLD:BuildAtGroup(group) return end + -- Helpful hint if building requires ground crates and player is carrying crates + if self.Config.BuildRequiresGroundCrates == true then + local carried = CTLD._loadedCrates[gname] + if carried and (carried.total or 0) > 0 then + _msgGroup(group, string.format('Insufficient ground crates to build here. You have %d loaded crate(s) onboard — drop them first (F10 -> Drop Loaded Crates).', carried.total)) + return + end + end + _msgGroup(group, 'Insufficient crates to build any asset here') end diff --git a/Moose_CTLD_Pure/init_mission_dual_coalition.lua b/Moose_CTLD_Pure/init_mission_dual_coalition.lua index 825e605..cba5a76 100644 --- a/Moose_CTLD_Pure/init_mission_dual_coalition.lua +++ b/Moose_CTLD_Pure/init_mission_dual_coalition.lua @@ -25,9 +25,9 @@ ctldBlue = _MOOSE_CTLD:New({ --DropZones = { { name = 'DROP_BLUE_1' } }, -- FOBZones = { { name = 'FOB_BLUE_A' } }, }, + BuildRequiresGroundCrates = true, }) --- Create CTLD for RED ctldRed = _MOOSE_CTLD:New({ CoalitionSide = coalition.side.RED, PickupZoneSmokeColor = trigger.smokeColor.Red, @@ -41,6 +41,7 @@ ctldRed = _MOOSE_CTLD:New({ --DropZones = { { name = 'DROP_RED_1' } }, -- FOBZones = { { name = 'FOB_RED_A' } }, }, + BuildRequiresGroundCrates = true, }) -- If the external catalog was loaded (as _CTLD_EXTRACTED_CATALOG), both instances auto-merged it