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