feat: Alt automatisk laver planen om ved ændret behov (>10 %, hvert 5. min); pålæsnings-diagnose i traktorens retning — 1.62.292
Brugerspørgsmål 17/10: flere dyr -> genberegnes forbruget? Nu: tickNeeds
sammenligner behov i ha pr. vare mod sidste plan; >10 % eller nyt/forsvundet
behov -> applyAll(enableIds={}, replan) — spillerens Fra-marker og egne mål
røres ikke. Diagnose: triggerens midte (bounding-sfære) set fra tankens
exactFillRootNode i traktorens retning (+X = venstre i Giants); adGates
genindsat efter uheld i patch (review).
This commit is contained in:
@@ -49,37 +49,42 @@ local function inBox(trigger, trailer)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Ren: påfyldningspunktets plads i triggerens eget rum (x til siden, y op/ned, z frem/tilbage) og triggerens radius ->
|
||||
-- læsbar tekst (in-game 17/10: Supercis 800 "0,4 m før" triggeren langs vejen, men ikke i boksen — til siden? i højden?)
|
||||
-- Ren: hvor triggerens midte ligger set fra vognens påfyldningspunkt i TRAKTORENS retning (x til siden, y op/ned,
|
||||
-- z frem/tilbage) -> læsbar tekst, der siger hvilken vej sporet/markøren skal rykkes (in-game 17/10: Supercis 800 ved
|
||||
-- 'Slurry Tank' stod 0,4 m fra triggeren langs vejen, men 1,5 m til siden — ikke i boksen)
|
||||
function ADLoadDiag.describeOffset(x, y, z, radius)
|
||||
if x == nil or y == nil or z == nil then return nil end
|
||||
local side = math.abs(x) < 0.05 and "midt for" or string.format("%.1f m til %s", math.abs(x), x < 0 and "venstre" or "højre")
|
||||
local up = math.abs(y) < 0.05 and "i højde med" or string.format("%.1f m %s", math.abs(y), y < 0 and "under" or "over")
|
||||
local along = math.abs(z) < 0.05 and "" or string.format(", %.1f m %s", math.abs(z), z < 0 and "bag" or "foran")
|
||||
return string.format("påfyldningspunkt %s, %s triggerens midte%s%s", side, up, along,
|
||||
local parts = {}
|
||||
-- Giants: Y op, Z frem, højrehåndet -> +X peger til VENSTRE for traktoren (venstre hjul har positiv x i køretøjs-XML)
|
||||
if math.abs(x) >= 0.05 then table.insert(parts, string.format("%.1f m til %s", math.abs(x), x > 0 and "venstre" or "højre")) end
|
||||
if math.abs(z) >= 0.05 then table.insert(parts, string.format("%.1f m %s", math.abs(z), z < 0 and "bagud" or "frem")) end
|
||||
if math.abs(y) >= 0.05 then table.insert(parts, string.format("%.1f m %s", math.abs(y), y < 0 and "lavere" or "højere")) end
|
||||
local where = #parts > 0 and table.concat(parts, ", ") or "lige dér"
|
||||
return string.format("triggerens midte ligger %s i forhold til tankens påfyldningspunkt%s", where,
|
||||
radius ~= nil and string.format(" (triggerens radius %.1f m)", radius) or "")
|
||||
end
|
||||
|
||||
-- Påfyldningspunktet (exactFillRootNode for den første fyldenhed der tager varen) set fra triggerens node.
|
||||
local function fillOffset(trigger, trailer, fillType)
|
||||
-- Triggerens midte (bounding-sfærens centrum, ellers nodens nulpunkt) set fra den første fyldenheds exactFillRootNode,
|
||||
-- i traktorens retning.
|
||||
local function fillOffset(trigger, trailer, fillType, vehicle)
|
||||
local node = trigger.triggerNode
|
||||
if node == nil or trailer.getFillUnits == nil then return nil end
|
||||
if node == nil or trailer.getFillUnits == nil or vehicle == nil or vehicle.rootNode == nil then return nil end
|
||||
for i = 1, #(trailer:getFillUnits() or {}) do
|
||||
if trailer.getFillUnitSupportsFillType == nil or trailer:getFillUnitSupportsFillType(i, fillType) then
|
||||
local fillNode = trailer.getFillUnitExactFillRootNode ~= nil and trailer:getFillUnitExactFillRootNode(i) or nil
|
||||
if fillNode ~= nil then
|
||||
local wx, wy, wz = getWorldTranslation(fillNode)
|
||||
local x, y, z = worldToLocal(node, wx, wy, wz)
|
||||
local radius = nil
|
||||
-- formens midte (nodens nulpunkt sidder tit i et hjørne — review 17/10): mål fra midten af boksen
|
||||
local fx, fy, fz = getWorldTranslation(fillNode)
|
||||
local cx, cy, cz, radius = 0, 0, 0, nil
|
||||
if getShapeBoundingSphere ~= nil then
|
||||
local okR, cx, cy, cz, r = pcall(getShapeBoundingSphere, node)
|
||||
local okR, sx, sy, sz, r = pcall(getShapeBoundingSphere, node)
|
||||
if okR and type(r) == "number" then
|
||||
radius = r
|
||||
if type(cx) == "number" and type(cy) == "number" and type(cz) == "number" then x, y, z = x - cx, y - cy, z - cz end
|
||||
if type(sx) == "number" and type(sy) == "number" and type(sz) == "number" then cx, cy, cz = sx, sy, sz end
|
||||
end
|
||||
end
|
||||
return ADLoadDiag.describeOffset(x, y, z, radius)
|
||||
local tx, ty, tz = localToWorld(node, cx, cy, cz)
|
||||
local x, _, z = worldDirectionToLocal(vehicle.rootNode, tx - fx, 0, tz - fz)
|
||||
return ADLoadDiag.describeOffset(x, ty - fy, z, radius)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -170,7 +175,7 @@ local function describeTrailer(adEnv, trailer, fillType, vehicle)
|
||||
end
|
||||
if nearestOk == nil then table.insert(parts, "INGEN AD-læssetrigger med varen") end
|
||||
if nearestOk ~= nil and not inBox(nearestOk.trigger, trailer) then
|
||||
local okO, offset = pcall(fillOffset, nearestOk.trigger, trailer, fillType)
|
||||
local okO, offset = pcall(fillOffset, nearestOk.trigger, trailer, fillType, vehicle)
|
||||
if okO and offset ~= nil then table.insert(parts, offset) end
|
||||
end
|
||||
if nearestOk ~= nil and vehicle ~= nil and trailer.getFillUnits ~= nil then
|
||||
|
||||
Reference in New Issue
Block a user