feat(navne): egne bygningsnavne fra ADSmartPickup_names.xml bruges overalt (FS25 kan ikke omdøbe bygninger); marksilo: siloer i samme klynge som et gårdlager er gårdens (v1.39.0.0)

This commit is contained in:
2026-09-27 15:05:14 +02:00
parent 7e0a991ce6
commit 9a284c875e
9 changed files with 114 additions and 3 deletions
+12
View File
@@ -125,6 +125,18 @@ do
check("gårdens nabosilo (40 m fra gårdlager) er ikke marksilo", table.concat(names, ","), "fs")
ADFields.fieldSilos = function() return {fieldSilo, farm} end
-- in-game 27/9: gårdens Farma-klynge er 300 m lang — siloer over 100 m fra et valgt gårdlager blev marksiloer.
-- En silo i samme klynge (≤ 60 m til en nabo) som et gårdlager er gårdens.
local c1 = {id = "c1", name = "Klynge 1", kind = "silo", placeable = {rootNode = {x = 50, z = 0}, spec_silo = {storages = {storage({[WHEAT] = 60000}, 0)}}}}
local c2 = {id = "c2", name = "Klynge 2", kind = "silo", placeable = {rootNode = {x = 105, z = 0}, spec_silo = {storages = {storage({[WHEAT] = 60000}, 0)}}}}
ADBuildings.list = function() return {fieldSilo, farm, c1, c2} end
ADFields.fieldSilos = function() return {fieldSilo, farm, c1, c2} end
local clustered = {}
for _, silo in ipairs(S.collectBuildings(adEnv)) do table.insert(clustered, silo.id) end
check("gårdens klynge (105 m via nabo) er ikke marksilo", table.concat(clustered, ","), "fs")
ADBuildings.list = function() return {fieldSilo, farm} end
ADFields.fieldSilos = function() return {fieldSilo, farm} end
-- M5: rest under 100 l tæller ikke som last
residue = 50
local vehicles = S.collectVehicles(adEnv)
+20
View File
@@ -0,0 +1,20 @@
-- Kør: luajit tests/test_adNames.lua (fra repo-roden)
dofile("FS25_ADSmartPickup/adNames.lua")
local failures = 0
local function check(name, actual, expected)
if actual == expected then print("OK " .. name) else
failures = failures + 1
print(string.format("FAIL %s: forventede %s, fik %s", name, tostring(expected), tostring(actual)))
end
end
local byId = ADNames.fromRecords({{id = "placeableA", name = "Gårdsilo 10"}, {id = "", name = "x"}, {id = "placeableB", name = " "}, {id = "placeableC"}})
check("navn indlæst", byId.placeableA, "Gårdsilo 10")
check("tomt id springes over", byId[""], nil)
check("blankt navn springes over", byId.placeableB, nil)
check("manglende navn springes over", byId.placeableC, nil)
ADNames.byId = byId
check("opslag på bygning", ADNames.forPlaceable({uniqueId = "placeableA"}), "Gårdsilo 10")
check("bygning uden eget navn", ADNames.forPlaceable({uniqueId = "placeableZ"}), nil)
check("uden uniqueId", ADNames.forPlaceable({}), nil)
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
os.exit(failures == 0 and 0 or 1)