feat: dyrene først — køb foder som sidste udvej, fabrikker holdes tilbage til siloerne dækker dyrene (v1.62.105)
This commit is contained in:
@@ -954,6 +954,28 @@ function ADFieldWork.findRefillMarker(adEnv, vehicle, fillType, x, z, skipRoute)
|
||||
return best
|
||||
end
|
||||
|
||||
-- Kun købestationer der sælger varen (dyrefoder som sidste udvej, 8/10). -> waypoint-id | nil
|
||||
function ADFieldWork.findBuyMarker(adEnv, vehicle, fillType, x, z, skipRoute)
|
||||
local best, bestDistance = nil, math.huge
|
||||
pcall(function()
|
||||
for _, placeable in pairs(g_currentMission.placeableSystem.placeables) do
|
||||
local spec = placeable.spec_buyingStation
|
||||
local station = spec ~= nil and spec.buyingStation or nil
|
||||
if station ~= nil and ADFieldWork.buyingSupports(station, fillType) then
|
||||
local wayPointId = markerAtStation(adEnv, vehicle, station, placeable)
|
||||
local wayPoint = wayPointId ~= nil and wayPointId > 0 and adEnv.ADGraphManager:getWayPointById(wayPointId) or nil
|
||||
if wayPoint ~= nil then
|
||||
local distance = (wayPoint.x - x) ^ 2 + (wayPoint.z - z) ^ 2
|
||||
if distance < bestDistance and (skipRoute or ADUnloadWait.hasRouteTo(adEnv, vehicle, wayPointId)) then
|
||||
best, bestDistance = wayPointId, distance
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
return best
|
||||
end
|
||||
|
||||
-- Påfyldning undervejs (såmaskine/sprøjte/spreder): AutoDrive LOAD med hjælper = Courseplay. Når CP melder
|
||||
-- tom (onCpEmpty), kører AD til påfyldningen (2. markør), fylder op, kører tilbage til F-markøren (1. markør)
|
||||
-- og genstarter CP. Findes ingen påfyldning, stopper sættet når det er tomt ("tom for …", se finish).
|
||||
|
||||
Reference in New Issue
Block a user