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
+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)