feat: v1.12.1.0 — prisregel via sæsonkurven, reserve til gårdens eget forbrug, paller til palleskur, fanen Lagre (idéer fra Distribution Redux)

This commit is contained in:
2026-09-23 10:34:41 +02:00
parent 43483bda76
commit 2d6e6dd7bf
16 changed files with 595 additions and 43 deletions
@@ -0,0 +1,55 @@
-- Smart Pickup — fanen Lagre
-- Alt gården har liggende, pr. bygning: fabrikker (outputs først), stalde, palleskure, siloer.
-- Kun bygninger med indhold vises; teksterne opdateres hvert sekund uden genopbygning.
-- Funktionerne lægges på SmartPickupFrame (indlæses efter SmartPickupFrame.lua).
-- "Sugar mill (fabrik): Sukker 150.0k/180.0k ▸ · Roer 356.8k/360.0k" (▸ = output)
function SmartPickupFrame:describeInventory(entry)
local parts = {}
for _, item in ipairs(entry.entries) do
local amount
if item.count ~= nil then
amount = string.format(self.i18n:getText("spu_storage_pallets"), item.count)
else
amount = string.format("%s/%s", SmartPickupFrame.formatCompact(item.level or 0), SmartPickupFrame.formatCompact(item.capacity or 0))
end
table.insert(parts, string.format("%s %s%s", tostring(item.title), amount, item.isOutput and " ▸" or ""))
end
local kindText = self.i18n:getText("spu_source_kind_" .. tostring(entry.kind))
return string.format("%s (%s): %s", tostring(entry.name), kindText, table.concat(parts, " · "))
end
function SmartPickupFrame:getInventory(adEnv)
if ADSources == nil or ADSources.getFarmInventory == nil then
return {}
end
return ADSources.getFarmInventory(adEnv, g_currentMission:getFarmId())
end
function SmartPickupFrame:fillStorageRows(adEnv)
self.storageRows = {}
self:addTextRow(self.i18n:getText("spu_section_storage"))
local inventory = self:getInventory(adEnv)
for _, entry in ipairs(inventory) do
table.insert(self.storageRows, {placeable = entry.placeable, title = self:addTextRow(self:describeInventory(entry))})
end
if #inventory == 0 then
self:addTextRow(self.i18n:getText("spu_storage_empty"))
end
end
function SmartPickupFrame:refreshStorageRows(adEnv)
if self.currentTab ~= SmartPickupFrame.TAB_STORAGE or #(self.storageRows or {}) == 0 then
return
end
local byPlaceable = {}
for _, entry in ipairs(self:getInventory(adEnv)) do
byPlaceable[entry.placeable] = entry
end
for _, row in ipairs(self.storageRows) do
local entry = byPlaceable[row.placeable]
if entry ~= nil then
row.title:setText(self:describeInventory(entry))
end
end
end