feat: bistadernes pallespawner som udkørselskilde for honning (1.62.362)
This commit is contained in:
@@ -42,3 +42,43 @@ function ADUtil.savePath(fileName)
|
||||
if path == nil then return nil end
|
||||
return (path:gsub(ADRunsStorage.FILE_NAME .. "$", fileName))
|
||||
end
|
||||
|
||||
-- Diagnose én gang pr. placeable: bistader-spawner uden honning-vare (HONEY ukendt) -> ikke en kilde.
|
||||
local loggedBeehive = setmetatable({}, {__mode = "k"})
|
||||
function ADUtil.logBeehiveOnce(placeable)
|
||||
if placeable == nil or loggedBeehive[placeable] then return end
|
||||
loggedBeehive[placeable] = true
|
||||
if Logging ~= nil and Logging.info ~= nil then
|
||||
local ok, name = pcall(function() return placeable.getName ~= nil and placeable:getName() or nil end)
|
||||
Logging.info("ADSmartPickup: bistader '%s' har en pallespawner, men varen HONEY kunne ikke slås op — springes over som kilde",
|
||||
tostring(ok and name or "?"))
|
||||
end
|
||||
end
|
||||
|
||||
-- Bistadernes pallespawner (spillets PlaceableBeehivePalletSpawner; også FS25_moreHoneyPalletSpawnerOptions): honning
|
||||
-- fra gårdens bistader kommer som paller ved spawneren -> spawner, fillType (HONEY) | nil. Spillet sætter spec.fillType
|
||||
-- i onLoad; mangler den, slås HONEY op. (in-game 19/10: 29 bistader, men spawneren stod ikke i Fra-listen)
|
||||
function ADUtil.beehivePalletSpawner(placeable)
|
||||
local spec = placeable ~= nil and placeable.spec_beehivePalletSpawner or nil
|
||||
local spawner = spec ~= nil and spec.palletSpawner or nil
|
||||
if spawner == nil then return nil end
|
||||
local fillType = spec.fillType
|
||||
if fillType == nil and g_fillTypeManager ~= nil and g_fillTypeManager.getFillTypeIndexByName ~= nil then
|
||||
local ok, index = pcall(g_fillTypeManager.getFillTypeIndexByName, g_fillTypeManager, "HONEY")
|
||||
fillType = ok and index or nil
|
||||
end
|
||||
if fillType == nil then
|
||||
ADUtil.logBeehiveOnce(placeable)
|
||||
return nil
|
||||
end
|
||||
return spawner, fillType
|
||||
end
|
||||
|
||||
-- En pallespawners pladser for varen, som spillet selv vælger (PalletSpawner:getOrSpawnPallet): varens egne pladser
|
||||
-- (spawnPlace#fillTypes -> fillTypeToSpawnPlaces), ellers de fælles. Uden vare: kun de fælles (som før — fabrikker).
|
||||
function ADUtil.spawnPlaces(spawner, fillType)
|
||||
if spawner == nil then return {} end
|
||||
local byFillType = spawner.fillTypeToSpawnPlaces
|
||||
if fillType ~= nil and byFillType ~= nil and byFillType[fillType] ~= nil then return byFillType[fillType] end
|
||||
return spawner.spawnPlaces or {}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user