diff --git a/FS19_AutoDrive/gui/debugSettingsPage.xml b/FS19_AutoDrive/gui/debugSettingsPage.xml
index 7ef5814e..963a5dd9 100644
--- a/FS19_AutoDrive/gui/debugSettingsPage.xml
+++ b/FS19_AutoDrive/gui/debugSettingsPage.xml
@@ -89,6 +89,14 @@
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/gui/guiProfiles.xml b/FS19_AutoDrive/gui/guiProfiles.xml
index 7aa76fba..8a079b1c 100644
--- a/FS19_AutoDrive/gui/guiProfiles.xml
+++ b/FS19_AutoDrive/gui/guiProfiles.xml
@@ -276,4 +276,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/gui/tipOfTheDayGUI.xml b/FS19_AutoDrive/gui/tipOfTheDayGUI.xml
new file mode 100644
index 00000000..96f045d5
--- /dev/null
+++ b/FS19_AutoDrive/gui/tipOfTheDayGUI.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FS19_AutoDrive/gui/userSettingsPage.xml b/FS19_AutoDrive/gui/userSettingsPage.xml
index 03fb807f..ea80c9c2 100644
--- a/FS19_AutoDrive/gui/userSettingsPage.xml
+++ b/FS19_AutoDrive/gui/userSettingsPage.xml
@@ -97,14 +97,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/gui/vehicleSettingsPage.xml b/FS19_AutoDrive/gui/vehicleSettingsPage.xml
index a1c39888..184e7e87 100644
--- a/FS19_AutoDrive/gui/vehicleSettingsPage.xml
+++ b/FS19_AutoDrive/gui/vehicleSettingsPage.xml
@@ -90,22 +90,22 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -146,6 +146,14 @@
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/modDesc.xml b/FS19_AutoDrive/modDesc.xml
index 5c620a29..3ecf1a8b 100644
--- a/FS19_AutoDrive/modDesc.xml
+++ b/FS19_AutoDrive/modDesc.xml
@@ -130,7 +130,7 @@ Traduit avec www.DeepL.com/Translator (version gratuite)
- 1.1.1.0
+ 1.1.1.1
icon.dds
@@ -170,6 +170,7 @@ Traduit avec www.DeepL.com/Translator (version gratuite)
+
diff --git a/FS19_AutoDrive/register.lua b/FS19_AutoDrive/register.lua
index 9a0eca43..82fee900 100644
--- a/FS19_AutoDrive/register.lua
+++ b/FS19_AutoDrive/register.lua
@@ -129,6 +129,8 @@ source(Utils.getFilename("scripts/Gui/SettingsPage.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Gui/DebugSettingsPage.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Gui/ExperimentalFeaturesSettingsPage.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Gui/Settings.lua", g_currentModDirectory))
+source(Utils.getFilename("scripts/Gui/TipOfTheDayGUI.lua", g_currentModDirectory))
+source(Utils.getFilename("scripts/TipOfTheDayHandler.lua", g_currentModDirectory))
AutoDriveRegister = {}
AutoDriveRegister.version = g_modManager:getModByName(g_currentModName).version
diff --git a/FS19_AutoDrive/scripts/AutoDrive.lua b/FS19_AutoDrive/scripts/AutoDrive.lua
index cf10f92e..8c2b2aae 100644
--- a/FS19_AutoDrive/scripts/AutoDrive.lua
+++ b/FS19_AutoDrive/scripts/AutoDrive.lua
@@ -1,10 +1,11 @@
AutoDrive = {}
-AutoDrive.version = "1.1.1.0"
+AutoDrive.version = "1.1.1.1-RC3"
AutoDrive.directory = g_currentModDirectory
g_autoDriveUIFilename = AutoDrive.directory .. "textures/GUI_Icons.dds"
g_autoDriveDebugUIFilename = AutoDrive.directory .. "textures/gui_debug_Icons.dds"
+g_autoDriveTipOfTheDayUIFilename = AutoDrive.directory .. "textures/tipOfTheDay_icons.dds"
AutoDrive.experimentalFeatures = {}
AutoDrive.experimentalFeatures.redLinePosition = false
@@ -45,6 +46,7 @@ AutoDrive.DC_NETWORKINFO = 64
AutoDrive.DC_EXTERNALINTERFACEINFO = 128
AutoDrive.DC_RENDERINFO = 256
AutoDrive.DC_ROADNETWORKINFO = 512
+AutoDrive.DC_BGA_MODE = 1024
AutoDrive.DC_ALL = 65535
AutoDrive.currentDebugChannelMask = AutoDrive.DC_NONE
@@ -94,8 +96,8 @@ AutoDrive.actions = {
{"AD_open_notification_history", false, 0},
{"AD_continue", false, 3},
{"ADParkVehicle", false, 0},
- {"AD_devAction", false, 0}
- -- {"COURSEPLAY_MOUSEACTION_SECONDARY", true, 1}
+ {"AD_devAction", false, 0},
+ {"AD_open_tipOfTheDay", false, 0}
}
function AutoDrive:onAllModsLoaded()
@@ -184,6 +186,7 @@ g_logManager:info("[AD] Start register later loaded mods end")
ADMultipleTargetsManager:load()
AutoDrive.initTelemetry()
+ AutoDrive.initTipOfTheDay()
end
function AutoDrive:init()
@@ -247,6 +250,7 @@ function AutoDrive:keyEvent(unicode, sym, modifier, isDown)
AutoDrive.leftLSHIFTmodifierKeyPressed = bitAND(modifier, Input.MOD_LSHIFT) > 0
AutoDrive.isCAPSKeyActive = bitAND(modifier, Input.MOD_CAPS) > 0
AutoDrive.rightCTRLmodifierKeyPressed = bitAND(modifier, Input.MOD_RCTRL) > 0
+ AutoDrive.rightSHIFTmodifierKeyPressed = bitAND(modifier, Input.MOD_RSHIFT) > 0
if AutoDrive.isInExtendedEditorMode() then
if (AutoDrive.rightCTRLmodifierKeyPressed and AutoDrive.toggleSphrere == true) then
@@ -317,6 +321,7 @@ function AutoDrive:update(dt)
ADRoutesManager:update(dt)
AutoDrive.handleTelemetry(dt)
+ AutoDrive.handleTipOfTheDay(dt)
end
function AutoDrive:draw()
diff --git a/FS19_AutoDrive/scripts/Events/Graph/RecordWayPointEvent.lua b/FS19_AutoDrive/scripts/Events/Graph/RecordWayPointEvent.lua
index 93e44c80..2c10fda5 100644
--- a/FS19_AutoDrive/scripts/Events/Graph/RecordWayPointEvent.lua
+++ b/FS19_AutoDrive/scripts/Events/Graph/RecordWayPointEvent.lua
@@ -9,7 +9,7 @@ function AutoDriveRecordWayPointEvent:emptyNew()
return o
end
-function AutoDriveRecordWayPointEvent:new(x, y, z, connectPrevious, dual, isReverse, previousId)
+function AutoDriveRecordWayPointEvent:new(x, y, z, connectPrevious, dual, isReverse, isSubPrio, previousId)
local o = AutoDriveRecordWayPointEvent:emptyNew()
o.x = x
o.y = y
@@ -18,6 +18,7 @@ function AutoDriveRecordWayPointEvent:new(x, y, z, connectPrevious, dual, isReve
o.dual = dual or false
o.isReverse = isReverse
o.previousId = previousId
+ o.isSubPrio = isSubPrio
return o
end
@@ -29,6 +30,7 @@ function AutoDriveRecordWayPointEvent:writeStream(streamId, connection)
streamWriteBool(streamId, self.dual)
streamWriteBool(streamId, self.isReverse)
streamWriteFloat32(streamId, self.previousId)
+ streamWriteBool(streamId, self.isSubPrio)
end
function AutoDriveRecordWayPointEvent:readStream(streamId, connection)
@@ -39,19 +41,20 @@ function AutoDriveRecordWayPointEvent:readStream(streamId, connection)
self.dual = streamReadBool(streamId)
self.isReverse = streamReadBool(streamId)
self.previousId = streamReadFloat32(streamId)
+ self.isSubPrio = streamReadBool(streamId)
self:run(connection)
end
function AutoDriveRecordWayPointEvent:run(connection)
if connection:getIsServer() then
-- If the event is coming from the server, clients have to record the way point
- ADGraphManager:recordWayPoint(self.x, self.y, self.z, self.connectPrevious, self.dual, self.isReverse, self.previousId, false)
+ ADGraphManager:recordWayPoint(self.x, self.y, self.z, self.connectPrevious, self.dual, self.isReverse, self.previousId, self.isSubPrio, false)
end
end
-function AutoDriveRecordWayPointEvent.sendEvent(x, y, z, connectPrevious, dual, isReverse, previousId)
+function AutoDriveRecordWayPointEvent.sendEvent(x, y, z, connectPrevious, dual, isReverse, previousId, isSubPrio)
if g_server ~= nil then
-- Server have to broadcast to all clients
- g_server:broadcastEvent(AutoDriveRecordWayPointEvent:new(x, y, z, connectPrevious, dual, isReverse, previousId))
+ g_server:broadcastEvent(AutoDriveRecordWayPointEvent:new(x, y, z, connectPrevious, dual, isReverse, previousId, isSubPrio))
end
end
diff --git a/FS19_AutoDrive/scripts/ExternalInterface.lua b/FS19_AutoDrive/scripts/ExternalInterface.lua
index 23f7e94a..17cae7dd 100644
--- a/FS19_AutoDrive/scripts/ExternalInterface.lua
+++ b/FS19_AutoDrive/scripts/ExternalInterface.lua
@@ -195,6 +195,7 @@ function AutoDrive:notifyDestinationListeners()
for object, callBackFunction in pairs(AutoDrive.destinationListeners) do
callBackFunction(object, true)
end
+ AutoDrive.triggerStaticOutput()
end
function AutoDrive:combineIsCallingDriver(combine) --only for CoursePlay
diff --git a/FS19_AutoDrive/scripts/Gui.lua b/FS19_AutoDrive/scripts/Gui.lua
index 37a79c82..f00de2e2 100644
--- a/FS19_AutoDrive/scripts/Gui.lua
+++ b/FS19_AutoDrive/scripts/Gui.lua
@@ -9,6 +9,7 @@ function AutoDrive:loadGUI()
AutoDrive.gui.ADEnterDestinationFilterGui = ADEnterDestinationFilterGui:new()
AutoDrive.gui.ADRoutesManagerGui = ADRoutesManagerGui:new()
AutoDrive.gui.ADNotificationsHistoryGui = ADNotificationsHistoryGui:new()
+ AutoDrive.gui.ADTipOfTheDayGUI = ADTipOfTheDayGUI:new()
g_gui:loadGui(AutoDrive.directory .. "gui/enterDriverNameGUI.xml", "ADEnterDriverNameGui", AutoDrive.gui.ADEnterDriverNameGui)
g_gui:loadGui(AutoDrive.directory .. "gui/enterTargetNameGUI.xml", "ADEnterTargetNameGui", AutoDrive.gui.ADEnterTargetNameGui)
@@ -16,6 +17,7 @@ function AutoDrive:loadGUI()
g_gui:loadGui(AutoDrive.directory .. "gui/enterDestinationFilterGUI.xml", "ADEnterDestinationFilterGui", AutoDrive.gui.ADEnterDestinationFilterGui)
g_gui:loadGui(AutoDrive.directory .. "gui/routesManagerGUI.xml", "ADRoutesManagerGui", AutoDrive.gui.ADRoutesManagerGui)
g_gui:loadGui(AutoDrive.directory .. "gui/notificationsHistoryGUI.xml", "ADNotificationsHistoryGui", AutoDrive.gui.ADNotificationsHistoryGui)
+ g_gui:loadGui(AutoDrive.directory .. "gui/tipOfTheDayGUI.xml", "ADTipOfTheDayGui", AutoDrive.gui.ADTipOfTheDayGUI)
AutoDrive.gui.ADSettingsPage = ADSettingsPage:new()
AutoDrive.gui.ADUserSettingsPage = ADSettingsPage:new()
@@ -44,6 +46,8 @@ function AutoDrive.GuiOverlay_loadOverlay(superFunc, ...)
overlay.filename = g_autoDriveDebugUIFilename
elseif overlay.filename == "g_autoDriveUIFilename" then
overlay.filename = g_autoDriveUIFilename
+ elseif overlay.filename == "g_autoDriveTipOfTheDayUIFilename" then
+ overlay.filename = g_autoDriveTipOfTheDayUIFilename
end
return overlay
@@ -92,3 +96,9 @@ function AutoDrive.onOpenNotificationsHistory()
g_gui:showGui("ADNotificationsHistoryGui")
end
end
+
+function AutoDrive.onOpenTipOfTheDay()
+ if not AutoDrive.gui.ADTipOfTheDayGUI.isOpen then
+ g_gui:showGui("ADTipOfTheDayGui")
+ end
+end
diff --git a/FS19_AutoDrive/scripts/Gui/EnterGroupNameGUI.lua b/FS19_AutoDrive/scripts/Gui/EnterGroupNameGUI.lua
index ce526c92..5ac0bbf0 100644
--- a/FS19_AutoDrive/scripts/Gui/EnterGroupNameGUI.lua
+++ b/FS19_AutoDrive/scripts/Gui/EnterGroupNameGUI.lua
@@ -27,10 +27,12 @@ end
function ADEnterGroupNameGui:onClickOk()
ADEnterGroupNameGui:superClass().onClickOk(self)
- if self.textInputElement.text ~= ADGraphManager.debugGroupName then
+
+ if self.textInputElement.text ~= ADGraphManager.debugGroupName then
-- do not allow user to create debug group
ADGraphManager:addGroup(self.textInputElement.text)
end
+
self:onClickBack()
end
diff --git a/FS19_AutoDrive/scripts/Gui/TipOfTheDayGUI.lua b/FS19_AutoDrive/scripts/Gui/TipOfTheDayGUI.lua
new file mode 100644
index 00000000..c3074879
--- /dev/null
+++ b/FS19_AutoDrive/scripts/Gui/TipOfTheDayGUI.lua
@@ -0,0 +1,77 @@
+ADTipOfTheDayGUI = {}
+ADTipOfTheDayGUI.CONTROLS = {"tipOfTheDayTemplate"}
+
+local ADTipOfTheDayGUI_mt = Class(ADTipOfTheDayGUI, ScreenElement)
+
+function ADTipOfTheDayGUI:new(target)
+ local o = ScreenElement:new(target, ADTipOfTheDayGUI_mt)
+ o.returnScreenName = ""
+ --o.history = {}
+ o:registerControls(ADTipOfTheDayGUI.CONTROLS)
+ return o
+end
+
+function ADTipOfTheDayGUI:onCreate()
+ --self.tipOfTheDayTemplate:unlinkElement()
+ --self.tipOfTheDayTemplate:setVisible(false)
+end
+
+function ADTipOfTheDayGUI:onOpen()
+ self:refreshItems()
+ ADTipOfTheDayGUI:superClass().onOpen(self)
+ g_depthOfFieldManager:setBlurState(false)
+
+ if self.activeCheckbox ~= nil then
+ self.activeCheckbox:setIsChecked(AutoDrive.getSetting("showTipOfTheDay"))
+ end
+end
+
+function ADTipOfTheDayGUI:refreshItems()
+ AutoDrive.showNextTipOfTheDay()
+ self.tipOfTheDayContent = AutoDrive.tipOfTheDay.currentTipOfTheDay
+
+ self.tipOfTheDayTemplate.elements[1]:setText(g_i18n:getText(self.tipOfTheDayContent.titletext))
+ self.tipOfTheDayTemplate.elements[2]:setImageUVs(nil, unpack(getNormalizedUVs(self.tipOfTheDayContent.imageUV)))
+ self.tipOfTheDayTemplate.elements[3]:setText(g_i18n:getText(self.tipOfTheDayContent.text))
+
+ self.imageWidth, self.imageHeight = getNormalizedScreenValues(self.tipOfTheDayContent.imageSize[1], self.tipOfTheDayContent.imageSize[2])
+ self.tipOfTheDayTemplate.elements[2]:setSize(self.imageWidth, self.imageHeight)
+
+end
+
+function ADTipOfTheDayGUI:onListSelectionChanged(rowIndex)
+end
+
+function ADTipOfTheDayGUI:onDoubleClick(rowIndex)
+end
+
+function ADTipOfTheDayGUI:onClickBack()
+ ADTipOfTheDayGUI:superClass().onClickBack(self)
+end
+
+function ADTipOfTheDayGUI:onClickCancel()
+ ADTipOfTheDayGUI:superClass().onClickCancel(self)
+end
+
+function ADTipOfTheDayGUI:onClickActivate()
+ --ADTipOfTheDayGUI:superClass().onClickActivate(self)
+ --AutoDrive.showNextTipOfTheDay()
+ self:refreshItems()
+end
+
+function ADTipOfTheDayGUI:onEnterPressed(_, isClick)
+end
+
+function ADTipOfTheDayGUI:onEscPressed()
+ self:onClickBack()
+end
+
+function ADTipOfTheDayGUI:onCreateCheckbox(element)
+ self.activeCheckbox = element.elements[1]
+end
+
+function ADTipOfTheDayGUI:onClickToggle(element)
+ AutoDrive.toggleTipOfTheDay()
+
+ self.activeCheckbox:setIsChecked(AutoDrive.getSetting("showTipOfTheDay"))
+end
diff --git a/FS19_AutoDrive/scripts/Hud.lua b/FS19_AutoDrive/scripts/Hud.lua
index 4fff5407..a73a6341 100644
--- a/FS19_AutoDrive/scripts/Hud.lua
+++ b/FS19_AutoDrive/scripts/Hud.lua
@@ -138,18 +138,6 @@ function AutoDriveHud:createHudAt(hudX, hudY)
self.Speed = "50"
self.Target = "Not Ready"
self.showHud = false
- self.stateHud = 0
- self.statesHud = 0
-
- if AutoDrive.getSetting("combineCPADHudMouse") > 1.0 and g_courseplay ~= nil then
- if AutoDrive.getSetting("combineCPADHudMouse") == 2.0 then
- self.statesHud = 1
- elseif AutoDrive.getSetting("combineCPADHudMouse") == 3.0 then
- self.statesHud = 2
- end
- end
- -- TODO: deactivated until PR #1862 solved with issue #1886
- self.statesHud = 0
if ADGraphManager:getMapMarkerById(1) ~= nil then
self.Target = ADGraphManager:getMapMarkerById(1).name
@@ -169,7 +157,7 @@ function AutoDriveHud:createHudAt(hudX, hudY)
local posX = self.posX + self.width - (closeWidth * 1.1)
local posY = self.rowHeader
-- close crossing
- table.insert(self.hudElements, ADHudButton:new(posX, posY, closeWidth, closeHeight, "input_toggleHud", nil, "", 1, true))
+ table.insert(self.hudElements, ADHudButton:new(posX, posY, closeWidth, closeHeight, "input_toggleHud", nil, nil, nil, "", 1, true))
-- axel - is this used?
table.insert(self.hudElements, ADHudIcon:new(self.posX, self.row4, self.iconWidth, self.iconHeight, AutoDrive.directory .. "textures/destination.dds", 1, "destinationOverlay"))
@@ -196,18 +184,22 @@ function AutoDriveHud:createHudAt(hudX, hudY)
)
-------- BASE ROW BUTTONS --------------
- self:AddButton("input_start_stop", nil, "input_ADEnDisable", 1, true)
- self:AddButton("input_silomode", "input_previousMode", "input_ADSilomode", 1, true)
- self:AddButton("input_continue", nil, "input_AD_continue", 1, true)
- self:AddButton("input_parkVehicle", "input_setParkDestination", "input_ADParkVehicle", 1, true)
- self:AddButton("input_incLoopCounter", "input_decLoopCounter", "input_ADIncLoopCounter", 1, true)
+ self:AddButton("input_start_stop", nil, nil, nil, "input_ADEnDisable", 1, true)
+ self:AddButton("input_silomode", "input_previousMode", nil, nil, "input_ADSilomode", 1, true)
+ self:AddButton("input_continue", nil, nil, nil, "input_AD_continue", 1, true)
+ self:AddButton("input_parkVehicle", "input_setParkDestination", nil, nil, "input_ADParkVehicle", 1, true)
+ if vehicle == nil or vehicle.ad.stateModule:getMode() ~= AutoDrive.MODE_BGA then
+ self:AddButton("input_incLoopCounter", "input_decLoopCounter", nil, nil, "input_ADIncLoopCounter", 1, true)
+ else
+ self:AddButton("input_bunkerUnloadType", nil, nil, nil, "input_ADbunkerUnloadType", 1, true)
+ end
local speedX = self.posX + (self.cols - 1 + self.buttonCollOffset) * self.borderX + (self.cols - 2 + self.buttonCollOffset) * self.buttonWidth
local speedY = self.posY + (1) * self.borderY + (0) * self.buttonHeight
table.insert(self.hudElements, ADHudSpeedmeter:new(speedX, speedY, self.buttonWidth, self.buttonHeight, false))
self.buttonCounter = self.buttonCounter + 1
- self:AddButton("input_debug", "input_displayMapPoints", "input_ADActivateDebug", 1, true)
+ self:AddButton("input_debug", "input_displayMapPoints", nil, nil, "input_ADActivateDebug", 1, true)
--------------------------------------------------
---------- SECOND ROW BUTTONS ---------------------
@@ -222,10 +214,10 @@ function AutoDriveHud:createHudAt(hudX, hudY)
self:AddEditModeButtons()
if g_courseplay ~= nil then
self.buttonCounter = self.buttonCounter - 1
- self:AddButton("input_startCp", "input_toggleCP_AIVE", "hud_startCp", 1, true)
+ self:AddButton("input_startCp", "input_toggleCP_AIVE", nil, nil, "hud_startCp", 1, true)
elseif (vehicle ~= nil and vehicle.acParameters ~= nil) then
self.buttonCounter = self.buttonCounter - 1
- self:AddButton("input_startCp", "input_toggleCP_AIVE", "hud_startCp", 3, true)
+ self:AddButton("input_startCp", "input_toggleCP_AIVE", nil, nil, "hud_startCp", 3, true)
end
end
@@ -234,16 +226,16 @@ function AutoDriveHud:createHudAt(hudX, hudY)
table.insert(self.hudElements, ADHudSpeedmeter:new(speedX, speedY, self.buttonWidth, self.buttonHeight, true))
self.buttonCounter = self.buttonCounter + 1
- self:AddButton("input_openGUI", nil, "input_ADOpenGUI", 1, true)
+ self:AddButton("input_openGUI", nil, nil, nil, "input_ADOpenGUI", 1, true)
else
self:AddEditModeButtons()
if AutoDrive.getSetting("addSettingsToHUD") then
self.buttonCounter = self.buttonCounter - 5
if g_courseplay ~= nil then
- self:AddButton("input_startCp", "input_toggleCP_AIVE", "hud_startCp", 1, true)
+ self:AddButton("input_startCp", "input_toggleCP_AIVE", nil, nil, "hud_startCp", 1, true)
elseif (vehicle ~= nil and vehicle.acParameters ~= nil) then
- self:AddButton("input_startCp", "input_toggleCP_AIVE", "hud_startCp", 3, true)
+ self:AddButton("input_startCp", "input_toggleCP_AIVE", nil, nil, "hud_startCp", 3, true)
else
self:AddSettingsButton("enableTrafficDetection", "gui_ad_enableTrafficDetection", 1, true)
end
@@ -255,10 +247,10 @@ function AutoDriveHud:createHudAt(hudX, hudY)
else
if g_courseplay ~= nil then
self.buttonCounter = self.buttonCounter - 1
- self:AddButton("input_startCp", "input_toggleCP_AIVE", "hud_startCp", 1, true)
+ self:AddButton("input_startCp", "input_toggleCP_AIVE", nil, nil, "hud_startCp", 1, true)
elseif (vehicle ~= nil and vehicle.acParameters ~= nil) then
self.buttonCounter = self.buttonCounter - 1
- self:AddButton("input_startCp", "input_toggleCP_AIVE", "hud_startCp", 3, true)
+ self:AddButton("input_startCp", "input_toggleCP_AIVE", nil, nil, "hud_startCp", 3, true)
end
end
@@ -267,7 +259,7 @@ function AutoDriveHud:createHudAt(hudX, hudY)
table.insert(self.hudElements, ADHudSpeedmeter:new(speedX, speedY, self.buttonWidth, self.buttonHeight, true))
self.buttonCounter = self.buttonCounter + 1
- self:AddButton("input_openGUI", nil, "input_ADOpenGUI", 1, true)
+ self:AddButton("input_openGUI", nil, nil, nil, "input_ADOpenGUI", 1, true)
end
--------------------------------------------------
@@ -276,9 +268,9 @@ function AutoDriveHud:createHudAt(hudX, hudY)
self:AddEditModeButtons()
if g_courseplay ~= nil then
- self:AddButton("input_startCp", "input_toggleCP_AIVE", "hud_startCp", 1, true)
+ self:AddButton("input_startCp", "input_toggleCP_AIVE", nil, nil, "hud_startCp", 1, true)
elseif (vehicle ~= nil and vehicle.acParameters ~= nil) then
- self:AddButton("input_startCp", "input_toggleCP_AIVE", "hud_startCp", 3, true)
+ self:AddButton("input_startCp", "input_toggleCP_AIVE", nil, nil, "hud_startCp", 3, true)
end
end
@@ -287,17 +279,17 @@ function AutoDriveHud:createHudAt(hudX, hudY)
end
function AutoDriveHud:AddEditModeButtons()
- self:AddButton("input_record", "input_record_dual", "input_ADRecord", 1, false)
- self:AddButton("input_routesManager", nil, "input_AD_routes_manager", 1, false)
- self:AddButton("input_createMapMarker", nil, "input_ADDebugCreateMapMarker", 1, false)
- self:AddButton("input_removeWaypoint", "input_removeMapMarker", "input_ADDebugDeleteWayPoint", 1, false)
- self:AddButton("input_editMapMarker", nil, "input_ADRenameMapMarker", 1, false)
+ self:AddButton("input_record", "input_record_dual", "input_record_subPrio", "input_record_subPrioDual", "input_ADRecord", 1, false)
+ self:AddButton("input_routesManager", nil, nil, nil, "input_AD_routes_manager", 1, false)
+ self:AddButton("input_createMapMarker", nil, nil, nil, "input_ADDebugCreateMapMarker", 1, false)
+ self:AddButton("input_removeWaypoint", "input_removeMapMarker", nil, nil, "input_ADDebugDeleteWayPoint", 1, false)
+ self:AddButton("input_editMapMarker", nil, nil, nil, "input_ADRenameMapMarker", 1, false)
if AutoDrive.getSetting("wideHUD") and AutoDrive.getSetting("addSettingsToHUD") then
- self:AddButton("input_removeMapMarker", nil, "input_ADDebugDeleteDestination", 1, false)
+ self:AddButton("input_removeMapMarker", nil, nil, nil, "input_ADDebugDeleteDestination", 1, false)
end
end
-function AutoDriveHud:AddButton(primaryAction, secondaryAction, toolTip, state, visible)
+function AutoDriveHud:AddButton(primaryAction, secondaryAction, tertiaryAction, quatenaryAction, toolTip, state, visible)
self.buttonCounter = self.buttonCounter + 1
self.colCurrent = self.buttonCounter % self.cols
if self.colCurrent == 0 then
@@ -309,7 +301,7 @@ function AutoDriveHud:AddButton(primaryAction, secondaryAction, toolTip, state,
local posX = self.posX + self.colCurrent * self.borderX + (self.colCurrent - 1) * self.buttonWidth
local posY = self.posY + (self.rowCurrent) * self.borderY + (self.rowCurrent - 1) * self.buttonHeight
--toolTip = string.sub(g_i18n:getText(toolTip), 4, string.len(g_i18n:getText(toolTip)))
- table.insert(self.hudElements, ADHudButton:new(posX, posY, self.buttonWidth, self.buttonHeight, primaryAction, secondaryAction, toolTip, state, visible))
+ table.insert(self.hudElements, ADHudButton:new(posX, posY, self.buttonWidth, self.buttonHeight, primaryAction, secondaryAction, tertiaryAction, quatenaryAction, toolTip, state, visible))
end
function AutoDriveHud:AddSettingsButton(setting, toolTip, state, visible)
@@ -369,47 +361,13 @@ function AutoDriveHud:update(dt)
end
function AutoDriveHud:toggleHud(vehicle)
- if self.statesHud > 0 then
- if self.stateHud == 0 then
- -- show both
- self.showHud = true
- vehicle.ad.showingHud = true
- g_courseplay.courseplay:openCloseHud(vehicle, true)
- if self.statesHud == 2 then
- self.stateHud = 1
- else
- self.stateHud = 3
- end
- elseif self.stateHud == 1 then
- -- show AD hud
- self.showHud = true
- vehicle.ad.showingHud = true
- g_courseplay.courseplay:openCloseHud(vehicle, false)
- g_inputBinding:setShowMouseCursor(true)
- self.stateHud = 2
- elseif self.stateHud == 2 then
- -- show CP hud
- self.showHud = false
- vehicle.ad.showingHud = false
- g_courseplay.courseplay:openCloseHud(vehicle, true)
- self.stateHud = 3
- elseif self.stateHud == 3 then
- -- close both
- self.showHud = false
- vehicle.ad.showingHud = false
- g_inputBinding:setShowMouseCursor(false)
- g_courseplay.courseplay:openCloseHud(vehicle, false)
- self.stateHud = 0
- end
+ if self.showHud == false then
+ self.showHud = true
+ vehicle.ad.showingHud = true
else
- if self.showHud == false then
- self.showHud = true
- vehicle.ad.showingHud = true
- else
- self.showHud = false
- vehicle.ad.showingHud = false
- g_inputBinding:setShowMouseCursor(false)
- end
+ self.showHud = false
+ vehicle.ad.showingHud = false
+ g_inputBinding:setShowMouseCursor(false)
end
AutoDrive.showingHud = self.showHud
@@ -445,6 +403,7 @@ function AutoDriveHud:mouseEvent(vehicle, posX, posY, isDown, isUp, button)
end
vehicle.ad.hoveredNodeId = nil
+ local adjustedPaths = false
if (not mouseEventHandled) and AutoDrive.isInExtendedEditorMode() then
if not AutoDrive.leftCTRLmodifierKeyPressed and vehicle.ad.newcreated ~= nil and vehicle.ad.selectedNodeId == vehicle.ad.newcreated then
-- if LCTRL is not pressed - no auto-connect to previous created new point, disable selected point
@@ -466,19 +425,39 @@ function AutoDriveHud:mouseEvent(vehicle, posX, posY, isDown, isUp, button)
end
if vehicle.ad.hoveredNodeId ~= nil then
-- waypoint at mouse position
- if button == 1 and isUp and not AutoDrive.leftALTmodifierKeyPressed and not AutoDrive.leftCTRLmodifierKeyPressed then
+ if button == 1 and isUp and not AutoDrive.leftCTRLmodifierKeyPressed then
-- left mouse button to select point / connect to already selected point
if vehicle.ad.selectedNodeId ~= nil then
if vehicle.ad.selectedNodeId ~= vehicle.ad.hoveredNodeId then
-- connect selected point with hovered point
- ADGraphManager:toggleConnectionBetween(ADGraphManager:getWayPointById(vehicle.ad.selectedNodeId), ADGraphManager:getWayPointById(vehicle.ad.hoveredNodeId), AutoDrive.leftLSHIFTmodifierKeyPressed)
+ --ADGraphManager:toggleConnectionBetween(ADGraphManager:getWayPointById(vehicle.ad.selectedNodeId), ADGraphManager:getWayPointById(vehicle.ad.hoveredNodeId), AutoDrive.leftLSHIFTmodifierKeyPressed)
+ -- lalt -> dual
+ -- lshift -> subPrio
+ -- rshift -> reverse
+
+ ADGraphManager:toggleConnectionBetween(ADGraphManager:getWayPointById(vehicle.ad.selectedNodeId), ADGraphManager:getWayPointById(vehicle.ad.hoveredNodeId), AutoDrive.rightSHIFTmodifierKeyPressed and not AutoDrive.leftALTmodifierKeyPressed)
+ if AutoDrive.leftALTmodifierKeyPressed then
+ ADGraphManager:toggleConnectionBetween(ADGraphManager:getWayPointById(vehicle.ad.hoveredNodeId), ADGraphManager:getWayPointById(vehicle.ad.selectedNodeId), AutoDrive.rightSHIFTmodifierKeyPressed and not AutoDrive.leftALTmodifierKeyPressed)
+ end
+
+ if AutoDrive.leftLSHIFTmodifierKeyPressed then
+ --local isSubPrioMarker = ADGraphManager:getIsPointSubPrioMarker(vehicle.ad.selectedNodeId)
+ --if not isSubPrioMarker then
+ -- ADGraphManager:toggleWayPointAsSubPrio(vehicle.ad.selectedNodeId)
+ --end
+ ADGraphManager:toggleWayPointAsSubPrio(vehicle.ad.hoveredNodeId)
+ end
end
+
-- unselect point
vehicle.ad.selectedNodeId = nil
+ adjustedPaths = true
else
-- select point
-- no selectedNodeId: hoveredNodeId is now selectedNodeId
- vehicle.ad.selectedNodeId = vehicle.ad.hoveredNodeId
+ if not AutoDrive.leftALTmodifierKeyPressed then
+ vehicle.ad.selectedNodeId = vehicle.ad.hoveredNodeId
+ end
end
end
@@ -504,9 +483,13 @@ function AutoDriveHud:mouseEvent(vehicle, posX, posY, isDown, isUp, button)
vehicle.ad.selectedNodeId = vehicle.ad.newcreated
end
+ if button == 1 and isUp and AutoDrive.leftLSHIFTmodifierKeyPressed and AutoDrive.leftCTRLmodifierKeyPressed and vehicle.ad.hoveredNodeId ~= nil then
+ ADGraphManager:toggleWayPointAsSubPrio(vehicle.ad.hoveredNodeId)
+ end
+
--If no node is hovered / moved - create new node
if vehicle.ad.nodeToMoveId == nil and vehicle.ad.hoveredNodeId == nil then
- if button == 1 and isUp and not AutoDrive.leftALTmodifierKeyPressed and AutoDrive.leftCTRLmodifierKeyPressed then
+ if button == 1 and isUp and AutoDrive.leftCTRLmodifierKeyPressed then
--For rough depth assertion, we use the closest nodes location as this is roughly in the screen's center
local closest = vehicle:getClosestWayPoint()
closest = ADGraphManager:getWayPointById(closest)
@@ -551,7 +534,19 @@ function AutoDriveHud:mouseEvent(vehicle, posX, posY, isDown, isUp, button)
local createdId = ADGraphManager:getWayPointsCount()
if vehicle.ad.newcreated ~= nil and vehicle.ad.selectedNodeId == vehicle.ad.newcreated then
-- connect only if previous created point is selected and newcreated ~= nil
- ADGraphManager:toggleConnectionBetween(ADGraphManager:getWayPointById(vehicle.ad.selectedNodeId), ADGraphManager:getWayPointById(createdId), AutoDrive.leftLSHIFTmodifierKeyPressed)
+
+ -- lalt -> dual
+ -- lshift -> subPrio
+ -- rshift -> reverse
+
+ ADGraphManager:toggleConnectionBetween(ADGraphManager:getWayPointById(vehicle.ad.selectedNodeId), ADGraphManager:getWayPointById(createdId), AutoDrive.rightSHIFTmodifierKeyPressed and not AutoDrive.leftALTmodifierKeyPressed)
+ if AutoDrive.leftALTmodifierKeyPressed then
+ ADGraphManager:toggleConnectionBetween(ADGraphManager:getWayPointById(createdId), ADGraphManager:getWayPointById(vehicle.ad.selectedNodeId), AutoDrive.rightSHIFTmodifierKeyPressed and not AutoDrive.leftALTmodifierKeyPressed)
+ end
+
+ if AutoDrive.leftLSHIFTmodifierKeyPressed then
+ ADGraphManager:toggleWayPointAsSubPrio(vehicle.ad.selectedNodeId)
+ end
end
vehicle.ad.newcreated = createdId
vehicle.ad.selectedNodeId = vehicle.ad.newcreated
@@ -560,7 +555,7 @@ function AutoDriveHud:mouseEvent(vehicle, posX, posY, isDown, isUp, button)
end
end
- if vehicle.ad.hoveredNodeId ~= nil and vehicle.ad.nodeToMoveId == nil then
+ if vehicle.ad.hoveredNodeId ~= nil and vehicle.ad.nodeToMoveId == nil and vehicle.ad.selectedNodeId == nil and not adjustedPaths then
if button == 1 and isUp and AutoDrive.leftALTmodifierKeyPressed and not AutoDrive.leftCTRLmodifierKeyPressed then
-- Left alt for deleting the currently hovered node
ADGraphManager:removeWayPoint(vehicle.ad.hoveredNodeId)
diff --git a/FS19_AutoDrive/scripts/Hud/HudButton.lua b/FS19_AutoDrive/scripts/Hud/HudButton.lua
index 8ce5b521..3e8dcda8 100644
--- a/FS19_AutoDrive/scripts/Hud/HudButton.lua
+++ b/FS19_AutoDrive/scripts/Hud/HudButton.lua
@@ -1,10 +1,12 @@
ADHudButton = ADInheritsFrom(ADGenericHudElement)
-function ADHudButton:new(posX, posY, width, height, primaryAction, secondaryAction, toolTip, state, visible)
+function ADHudButton:new(posX, posY, width, height, primaryAction, secondaryAction, tertiaryAction, quatenaryAction, toolTip, state, visible)
local o = ADHudButton:create()
o:init(posX, posY, width, height)
o.primaryAction = primaryAction
o.secondaryAction = secondaryAction
+ o.tertiaryAction = tertiaryAction
+ o.quatenaryAction = quatenaryAction
o.toolTip = toolTip
o.state = state
o.isVisible = visible
@@ -65,6 +67,12 @@ function ADHudButton:getNewState(vehicle)
if vehicle.ad.stateModule:isInDualCreationMode() then
newState = 3
end
+ if vehicle.ad.stateModule:isInSubPrioCreationMode() then
+ newState = 4
+ end
+ if vehicle.ad.stateModule:isInSubPrioDualCreationMode() then
+ newState = 5
+ end
else
newState = 1
end
@@ -163,6 +171,14 @@ function ADHudButton:getNewState(vehicle)
end
end
self.isVisible = (not AutoDrive.isEditorModeEnabled()) or (AutoDrive.getSetting("wideHUD") and AutoDrive.getSetting("addSettingsToHUD"))
+ end
+
+ if self.primaryAction == "input_bunkerUnloadType" then
+ if vehicle.ad.stateModule:getBunkerUnloadTypeIsTrigger() then
+ newState = 1
+ else
+ newState = 2
+ end
end
return newState
@@ -191,12 +207,18 @@ function ADHudButton:act(vehicle, posX, posY, isDown, isUp, button)
end
end
- if button == 1 and isUp then
+ if button == 1 and isUp and not AutoDrive.leftLSHIFTmodifierKeyPressed then
ADInputManager:onInputCall(vehicle, self.primaryAction)
return true
- elseif (button == 3 or button == 2) and isUp then
+ elseif (button == 3 or button == 2) and isUp and not AutoDrive.leftLSHIFTmodifierKeyPressed then
ADInputManager:onInputCall(vehicle, self.secondaryAction)
return true
+ elseif button == 1 and isUp and AutoDrive.leftLSHIFTmodifierKeyPressed then
+ ADInputManager:onInputCall(vehicle, self.tertiaryAction)
+ return true
+ elseif (button == 3 or button == 2) and isUp and AutoDrive.leftLSHIFTmodifierKeyPressed then
+ ADInputManager:onInputCall(vehicle, self.quatenaryAction)
+ return true
end
end
diff --git a/FS19_AutoDrive/scripts/Manager/GraphManager.lua b/FS19_AutoDrive/scripts/Manager/GraphManager.lua
index 80d00463..34db3d7c 100644
--- a/FS19_AutoDrive/scripts/Manager/GraphManager.lua
+++ b/FS19_AutoDrive/scripts/Manager/GraphManager.lua
@@ -1,6 +1,8 @@
ADGraphManager = {}
ADGraphManager.debugGroupName = "AD_Debug"
+ADGraphManager.SUB_PRIO_FACTOR = 20
+ADGraphManager.MIN_START_DISTANCE = 8
function ADGraphManager:load()
self.wayPoints = {}
@@ -125,22 +127,38 @@ end
function ADGraphManager:getPathTo(vehicle, waypointId)
local wp = {}
+
+ local x, _, z = getWorldTranslation(vehicle.components[1].node)
+ local wp_target = self.wayPoints[waypointId]
+
+ if wp_target ~= nil then
+ local distanceToTarget = MathUtil.vector2Length(x - wp_target.x, z - wp_target.z)
+ if distanceToTarget < ADGraphManager.MIN_START_DISTANCE then
+ table.insert(wp, wp_target)
+ return wp
+ end
+ end
+
local closestWaypoint = self:findMatchingWayPointForVehicle(vehicle)
if closestWaypoint ~= nil then
- wp = self:pathFromTo(closestWaypoint, waypointId)
+ local outCandidates = self:getBestOutPoints(vehicle, closestWaypoint)
+ wp = self:pathFromTo(closestWaypoint, waypointId, outCandidates)
end
return wp
end
-function ADGraphManager:pathFromTo(startWaypointId, targetWaypointId)
+function ADGraphManager:pathFromTo(startWaypointId, targetWaypointId, preferredNeighbors)
local wp = {}
if startWaypointId ~= nil and self.wayPoints[startWaypointId] ~= nil and targetWaypointId ~= nil and self.wayPoints[targetWaypointId] ~= nil then
if startWaypointId == targetWaypointId then
table.insert(wp, self.wayPoints[targetWaypointId])
else
- -- wp = ADPathCalculator:GetPath(startWaypointId, targetWaypointId)
- wp = AutoDrive:dijkstraLiveShortestPath(startWaypointId, targetWaypointId)
+ if preferredNeighbors == nil then
+ preferredNeighbors = {}
+ end
+ wp = ADPathCalculator:GetPath(startWaypointId, targetWaypointId, preferredNeighbors)
+ --wp = AutoDrive:dijkstraLiveShortestPath(startWaypointId, targetWaypointId)
end
end
return wp
@@ -154,8 +172,8 @@ function ADGraphManager:pathFromToMarker(startWaypointId, markerId)
table.insert(wp, 1, self.wayPoints[targetId])
return wp
else
- -- wp = ADPathCalculator:GetPath(startWaypointId, targetId)
- wp = AutoDrive:dijkstraLiveShortestPath(startWaypointId, targetId)
+ wp = ADPathCalculator:GetPath(startWaypointId, targetId, {})
+ --wp = AutoDrive:dijkstraLiveShortestPath(startWaypointId, targetId)
end
end
return wp
@@ -186,8 +204,8 @@ function ADGraphManager:FastShortestPath(start, markerName, markerId)
return wp
end
- -- wp = ADPathCalculator:GetPath(start_id, target_id)
- wp = AutoDrive:dijkstraLiveShortestPath(start_id, target_id)
+ wp = ADPathCalculator:GetPath(start_id, target_id, {})
+ --wp = AutoDrive:dijkstraLiveShortestPath(start_id, target_id)
return wp
end
@@ -535,6 +553,8 @@ function ADGraphManager:createWayPoint(x, y, z, sendEvent)
local newWp = self:createNode(newId, x, y, z, {}, {})
self:setWayPoint(newWp)
self:markChanges()
+
+ return newWp
end
end
@@ -560,7 +580,7 @@ function ADGraphManager:moveWayPoint(wayPonitId, x, y, z, sendEvent)
end
end
-function ADGraphManager:recordWayPoint(x, y, z, connectPrevious, dual, isReverse, previousId, sendEvent)
+function ADGraphManager:recordWayPoint(x, y, z, connectPrevious, dual, isReverse, previousId, isSubPrio, sendEvent)
previousId = previousId or 0
local previous
if connectPrevious then
@@ -572,7 +592,7 @@ function ADGraphManager:recordWayPoint(x, y, z, connectPrevious, dual, isReverse
if g_server ~= nil then
if sendEvent ~= false then
-- Propagating waypoint recording to clients
- AutoDriveRecordWayPointEvent.sendEvent(x, y, z, connectPrevious, dual, isReverse, previousId)
+ AutoDriveRecordWayPointEvent.sendEvent(x, y, z, connectPrevious, dual, isReverse, previousId, isSubPrio)
end
else
if sendEvent ~= false then
@@ -589,6 +609,11 @@ function ADGraphManager:recordWayPoint(x, y, z, connectPrevious, dual, isReverse
self:toggleConnectionBetween(newWp, previous, isReverse, false)
end
end
+
+ if isSubPrio then
+ self:toggleWayPointAsSubPrio(newId)
+ end
+
self:markChanges()
return newWp
end
@@ -626,6 +651,10 @@ function ADGraphManager:getDistanceBetweenNodes(start, target)
end
end
+ if self:getIsPointSubPrio(self.wayPoints[target].id) then
+ distance = distance * ADGraphManager.SUB_PRIO_FACTOR
+ end
+
return distance
end
@@ -982,7 +1011,6 @@ function ADGraphManager:createDebugMarkers(updateMap)
end
end
-
function ADGraphManager:checkForWrongReverseStart(wp_ref, wp_current, wp_ahead)
local reverseStart = false
@@ -1002,3 +1030,75 @@ function ADGraphManager:checkForWrongReverseStart(wp_ref, wp_current, wp_ahead)
return reverseStart
end
+
+function ADGraphManager:toggleWayPointAsSubPrio(wayPointId)
+ local wayPoint = self:getWayPointById(wayPointId)
+ if wayPoint ~= nil then
+ -- check if debug node for subPrio exists
+ local subPrioNode = self:getSubPrioMarkerNode()
+
+ self:toggleConnectionBetween(wayPoint, subPrioNode, false)
+ end
+end
+
+function ADGraphManager:getSubPrioMarkerNode()
+ if self.subPrioMarkerNode == nil then
+ for _, wp in pairs(self.wayPoints) do
+ if self:getIsPointSubPrioMarker(wp.id) then
+ self.subPrioMarkerNode = wp
+ break
+ end
+ end
+ end
+
+ if self.subPrioMarkerNode == nil then
+ self.subPrioMarkerNode = self:createWayPoint(-1, -1, -1)
+ end
+
+ return self.subPrioMarkerNode
+end
+
+function ADGraphManager:getIsPointSubPrio(wayPointId)
+ local wayPoint = self:getWayPointById(wayPointId)
+
+ for _, neighborId in pairs(wayPoint.out) do
+ local neighbor = ADGraphManager:getWayPointById(neighborId)
+ if neighbor ~= nil then
+ if neighbor.id == self:getSubPrioMarkerNode().id then
+ return true
+ end
+ end
+ end
+
+ return false
+end
+
+function ADGraphManager:getIsPointSubPrioMarker(wayPointId)
+ local wayPoint = self:getWayPointById(wayPointId)
+
+ if wayPoint.x >= -1.01 and wayPoint.x <= -0.99 and wayPoint.z >= -1.01 and wayPoint.z <= -0.99 then
+ return true
+ end
+
+ return false
+end
+
+function ADGraphManager:getBestOutPoints(vehicle, nodeId)
+ local neighbors = {}
+
+ local x, y, z = getWorldTranslation(vehicle.components[1].node)
+ local toCheck = self.wayPoints[nodeId]
+ local baseDistance = MathUtil.vector2Length(toCheck.x - x, toCheck.z - z)
+
+ if toCheck.out ~= nil then
+ for _, outId in pairs(toCheck.out) do
+ local out = self.wayPoints[outId]
+ local _, _, offsetZ = worldToLocal(vehicle.components[1].node, out.x, y, out.z)
+ if out ~= nil and baseDistance < MathUtil.vector2Length(out.x - x, out.z - z) and offsetZ > 0 then
+ table.insert(neighbors, out.id)
+ end
+ end
+ end
+
+ return neighbors
+end
diff --git a/FS19_AutoDrive/scripts/Manager/HarvestManager.lua b/FS19_AutoDrive/scripts/Manager/HarvestManager.lua
index b930170d..11d17922 100644
--- a/FS19_AutoDrive/scripts/Manager/HarvestManager.lua
+++ b/FS19_AutoDrive/scripts/Manager/HarvestManager.lua
@@ -120,7 +120,7 @@ function ADHarvestManager:update(dt)
for _, harvester in pairs(self.harvesters) do
if harvester ~= nil and g_currentMission.nodeToObject[harvester.components[1].node] ~= nil and entityExists(harvester.components[1].node) then
- if self.assignmentDelayTimer:done() then
+ --if self.assignmentDelayTimer:done() then
if not self:alreadyAssignedUnloader(harvester) then
if ADHarvestManager.doesHarvesterNeedUnloading(harvester) or ((not AutoDrive.combineIsTurning(harvester)) and ADHarvestManager.isHarvesterActive(harvester)) then
self:assignUnloaderToHarvester(harvester)
@@ -141,7 +141,7 @@ function ADHarvestManager:update(dt)
end
end
end
- end
+ --end
if (harvester.ad ~= nil and harvester.ad.noMovementTimer ~= nil and harvester.lastSpeedReal ~= nil) then
harvester.ad.noMovementTimer:timer((harvester.lastSpeedReal <= 0.0004), 3000, dt)
diff --git a/FS19_AutoDrive/scripts/Manager/InputManager.lua b/FS19_AutoDrive/scripts/Manager/InputManager.lua
index 83626be8..c9624a83 100644
--- a/FS19_AutoDrive/scripts/Manager/InputManager.lua
+++ b/FS19_AutoDrive/scripts/Manager/InputManager.lua
@@ -4,6 +4,8 @@ ADInputManager.actionsToInputs = {
ADSilomode = "input_silomode",
ADRecord = "input_record",
ADRecord_Dual = "input_record_dual",
+ ADRecord_SubPrio = "input_record_subPrio",
+ ADRecord_SubPrioDual = "input_record_subPrioDual",
ADEnDisable = "input_start_stop",
ADSelectTarget = "input_nextTarget",
ADSelectPreviousTarget = "input_previousTarget",
@@ -23,7 +25,6 @@ ADInputManager.actionsToInputs = {
AD_FieldSpeed_down = "input_decreaseFieldSpeed",
ADToggleHud = "input_toggleHud",
ADToggleMouse = "input_toggleMouse",
- COURSEPLAY_MOUSEACTION_SECONDARY = "input_toggleMouse",
ADDebugDeleteWayPoint = "input_removeWaypoint",
AD_routes_manager = "input_routesManager",
ADSelectNextFillType = "input_nextFillType",
@@ -36,9 +37,11 @@ ADInputManager.actionsToInputs = {
AD_open_notification_history = "input_openNotificationHistory",
AD_continue = "input_continue",
ADParkVehicle = "input_parkVehicle",
- AD_devAction = "input_devAction"
+ AD_devAction = "input_devAction",
+ AD_open_tipOfTheDay = "input_openTipOfTheDay"
}
+
--[[
tool selection not proper on dedi servers as known!
That's why the following event is only taken on clients and send as event in the network
@@ -71,7 +74,10 @@ ADInputManager.inputsToIds = {
input_nextTarget = 23,
input_previousTarget = 24,
input_startCp = 25,
- input_toggleCP_AIVE = 26
+ input_toggleCP_AIVE = 26,
+ input_record_subPrio = 27,
+ input_record_subPrioDual = 28,
+ input_bunkerUnloadType = 29
}
ADInputManager.idsToInputs = {}
@@ -116,6 +122,10 @@ function ADInputManager:input_openNotificationHistory(vehicle)
AutoDrive.onOpenNotificationsHistory()
end
+function ADInputManager:input_openTipOfTheDay(vehicle)
+ AutoDrive.onOpenTipOfTheDay()
+end
+
function ADInputManager:input_editMapMarker(vehicle)
if AutoDrive.isEditorModeEnabled() then
-- This can be triggered both from 'Edit Target' keyboard shortcut and right click on 'Create Target' hud button
@@ -233,6 +243,25 @@ function ADInputManager:input_start_stop(vehicle)
vehicle:stopAutoDrive()
else
vehicle.ad.stateModule:getCurrentMode():start()
+
+ if AutoDrive.rightSHIFTmodifierKeyPressed then
+ for _, otherVehicle in pairs(g_currentMission.vehicles) do
+ if otherVehicle ~= nil and otherVehicle ~= vehicle and otherVehicle.ad ~= nil and otherVehicle.ad.stateModule ~= nil then
+ --Doesn't work yet, if vehicle hasn't been entered before apparently. So we need to check what to call before, to setup all required variables.
+
+ if otherVehicle.ad.stateModule.activeBeforeSave then
+ g_currentMission:requestToEnterVehicle(otherVehicle)
+ otherVehicle.ad.stateModule:getCurrentMode():start()
+ end
+ if otherVehicle.ad.stateModule.AIVEActiveBeforeSave and otherVehicle.acParameters ~= nil then
+ g_currentMission:requestToEnterVehicle(otherVehicle)
+ otherVehicle.acParameters.enabled = true
+ otherVehicle:startAIVehicle(nil, false, g_currentMission.player.farmId)
+ end
+ end
+ end
+ g_currentMission:requestToEnterVehicle(vehicle)
+ end
end
end
@@ -257,7 +286,7 @@ function ADInputManager:input_previousMode(vehicle)
end
function ADInputManager:input_record(vehicle)
- if not vehicle.ad.stateModule:isInCreationMode() and not vehicle.ad.stateModule:isInDualCreationMode() then
+ if not vehicle.ad.stateModule:isInCreationMode() and not vehicle.ad.stateModule:isInDualCreationMode() and not vehicle.ad.stateModule:isInSubPrioCreationMode() and not vehicle.ad.stateModule:isInSubPrioDualCreationMode() then
vehicle.ad.stateModule:startNormalCreationMode()
else
vehicle.ad.stateModule:disableCreationMode()
@@ -265,13 +294,29 @@ function ADInputManager:input_record(vehicle)
end
function ADInputManager:input_record_dual(vehicle)
- if not vehicle.ad.stateModule:isInCreationMode() and not vehicle.ad.stateModule:isInDualCreationMode() then
+ if not vehicle.ad.stateModule:isInCreationMode() and not vehicle.ad.stateModule:isInDualCreationMode() and not vehicle.ad.stateModule:isInSubPrioCreationMode() and not vehicle.ad.stateModule:isInSubPrioDualCreationMode() then
vehicle.ad.stateModule:startDualCreationMode()
else
vehicle.ad.stateModule:disableCreationMode()
end
end
+function ADInputManager:input_record_subPrio(vehicle)
+ if not vehicle.ad.stateModule:isInCreationMode() and not vehicle.ad.stateModule:isInDualCreationMode() and not vehicle.ad.stateModule:isInSubPrioCreationMode() and not vehicle.ad.stateModule:isInSubPrioDualCreationMode() then
+ vehicle.ad.stateModule:startSubPrioCreationMode()
+ else
+ vehicle.ad.stateModule:disableCreationMode()
+ end
+end
+
+function ADInputManager:input_record_subPrioDual(vehicle)
+ if not vehicle.ad.stateModule:isInCreationMode() and not vehicle.ad.stateModule:isInDualCreationMode() and not vehicle.ad.stateModule:isInSubPrioCreationMode() and not vehicle.ad.stateModule:isInSubPrioDualCreationMode() then
+ vehicle.ad.stateModule:startSubPrioDualCreationMode()
+ else
+ vehicle.ad.stateModule:disableCreationMode()
+ end
+end
+
function ADInputManager:input_debug(vehicle)
AutoDrive.cycleEditMode()
end
@@ -408,3 +453,7 @@ function ADInputManager:input_devAction(vehicle)
AutoDrive.devAction(vehicle)
end
end
+
+function ADInputManager:input_bunkerUnloadType(vehicle)
+ vehicle.ad.stateModule:nextBunkerUnloadType()
+end
diff --git a/FS19_AutoDrive/scripts/Manager/TriggerManager.lua b/FS19_AutoDrive/scripts/Manager/TriggerManager.lua
index 8fda55cd..4ddbeeb5 100644
--- a/FS19_AutoDrive/scripts/Manager/TriggerManager.lua
+++ b/FS19_AutoDrive/scripts/Manager/TriggerManager.lua
@@ -184,6 +184,10 @@ function ADTriggerManager.loadAllTriggers()
table.insert(ADTriggerManager.siloTriggers, object)
end
end
+
+ if object.exactFillRootNode ~= nil then
+ table.insert(ADTriggerManager.tipTriggers, object)
+ end
end
end
@@ -214,6 +218,7 @@ function ADTriggerManager.loadAllTriggers()
end
end
end
+
for _, trigger in pairs(ADTriggerManager.siloTriggers) do
if trigger.stoppedTimer == nil then
trigger.stoppedTimer = AutoDriveTON:new()
@@ -345,13 +350,11 @@ end
function ADTriggerManager.getTriggerPos(trigger)
local x, y, z = 0, 0, 0
- if trigger.triggerNode ~= nil and g_currentMission.nodeToObject[trigger.triggerNode] ~= nil and entityExists(trigger.triggerNode) then
+ if trigger.triggerNode ~= nil and g_currentMission.nodeToObject[trigger.triggerNode] ~= nil and entityExists(trigger.triggerNode) then
x, y, z = getWorldTranslation(trigger.triggerNode)
- --g_logManager:devInfo("Got triggerpos: " .. x .. "/" .. y .. "/" .. z);
end
if trigger.exactFillRootNode ~= nil and g_currentMission.nodeToObject[trigger.exactFillRootNode] ~= nil and entityExists(trigger.exactFillRootNode) then
x, y, z = getWorldTranslation(trigger.exactFillRootNode)
- --g_logManager:devInfo("Got triggerpos: " .. x .. "/" .. y .. "/" .. z);
end
return x, y, z
end
@@ -378,3 +381,24 @@ end
function ADTriggerManager:onPlaceableBuy()
ADTriggerManager.searchedForTriggers = false
end
+
+function ADTriggerManager.triggerSupportsFillType(trigger, fillType)
+ if fillType > 0 then
+ if trigger ~= nil and trigger.getIsFillTypeSupported then
+ return trigger:getIsFillTypeSupported(fillType)
+ end
+ end
+ return false
+end
+
+function ADTriggerManager.getAllTriggersForFillType(fillType)
+ local triggers = {}
+
+ for _, trigger in pairs(ADTriggerManager.getUnloadTriggers()) do
+ if ADTriggerManager.triggerSupportsFillType(trigger, fillType) then
+ table.insert(triggers, trigger)
+ end
+ end
+
+ return triggers
+end
diff --git a/FS19_AutoDrive/scripts/Modes/CombineUnloaderMode.lua b/FS19_AutoDrive/scripts/Modes/CombineUnloaderMode.lua
index d978e2c2..7b13127c 100644
--- a/FS19_AutoDrive/scripts/Modes/CombineUnloaderMode.lua
+++ b/FS19_AutoDrive/scripts/Modes/CombineUnloaderMode.lua
@@ -609,9 +609,13 @@ function CombineUnloaderMode:getRearChaseOffsetZ()
if AutoDrive.isSugarcaneHarvester(self.combine) then
rearChaseOffset = -self.combine.sizeLength / 2 - AutoDrive.getTractorTrainLength(self.vehicle, true, false) * math.sqrt(2)
else
- --there is no need to be close to the rear of the harvester here. We can make it hard on the pathfinder since we have no strong desire to chase there anyway for normal harvesters
- --Especially when they are CP driven, we have to be prepared for that massive reverse maneuver when the combine is filled and wants to avoid the crop.
- rearChaseOffset = -45
+ if self.combine.lastSpeedReal > 0.002 and self.combine.ad.sensors.frontSensorFruit:pollInfo() then
+ rearChaseOffset = -10
+ else
+ --there is no need to be close to the rear of the harvester here. We can make it hard on the pathfinder since we have no strong desire to chase there anyway for normal harvesters
+ --Especially when they are CP driven, we have to be prepared for that massive reverse maneuver when the combine is filled and wants to avoid the crop.
+ rearChaseOffset = -45
+ end
end
end
diff --git a/FS19_AutoDrive/scripts/Modules/CollisionDetectionModule.lua b/FS19_AutoDrive/scripts/Modules/CollisionDetectionModule.lua
index 5f03f774..a02b8cc9 100644
--- a/FS19_AutoDrive/scripts/Modules/CollisionDetectionModule.lua
+++ b/FS19_AutoDrive/scripts/Modules/CollisionDetectionModule.lua
@@ -79,7 +79,8 @@ function ADCollisionDetectionModule:detectAdTrafficOnRoute()
self.trafficVehicle = nil
if #dualRoutePoints > 0 then
for _, other in pairs(g_currentMission.vehicles) do
- if other ~= self.vehicle and other.ad ~= nil and other.ad.stateModule ~= nil and other.ad.stateModule:isActive() and other.ad.drivePathModule:isOnRoadNetwork() then local onSameRoute = false
+ if other ~= self.vehicle and other.ad ~= nil and other.ad.stateModule ~= nil and other.ad.stateModule:isActive() and other.ad.drivePathModule:isOnRoadNetwork() then
+ local onSameRoute = false
local sameDirection = false
local window = 4
local i = -window
diff --git a/FS19_AutoDrive/scripts/Modules/DrivePathModule.lua b/FS19_AutoDrive/scripts/Modules/DrivePathModule.lua
index 383e414a..a9b5b2ad 100644
--- a/FS19_AutoDrive/scripts/Modules/DrivePathModule.lua
+++ b/FS19_AutoDrive/scripts/Modules/DrivePathModule.lua
@@ -16,6 +16,7 @@ function ADDrivePathModule:new(vehicle)
o.minDistanceTimer = AutoDriveTON:new()
o.waitTimer = AutoDriveTON:new()
o.blinkTimer = AutoDriveTON:new()
+ o.brakeHysteresisActive = false
ADDrivePathModule.reset(o)
return o
end
@@ -207,15 +208,30 @@ function ADDrivePathModule:followWaypoints(dt)
self.distanceToLookAhead = 8
if self.wayPoints[self:getCurrentWayPointIndex() - 1] ~= nil and self:getNextWayPoint() ~= nil then
local highestAngle = self:getHighestApproachingAngle()
- self.speedLimit = math.min(self.speedLimit, self:getMaxSpeedForAngle(highestAngle))
+
+ if self:isOnRoadNetwork() then
+ self.speedLimit = math.min(self.speedLimit, self:getMaxSpeedForAngle(highestAngle))
+ else
+ -- Let's increase the cornering speed for paths generated with the pathfinder module. There are many 45° angles in there that slow the process down otherwise.
+ self.speedLimit = math.min(self.speedLimit, math.max(12, self:getMaxSpeedForAngle(highestAngle) * 2))
+ end
end
self.distanceToTarget = self:getDistanceToLastWaypoint(40)
if self.distanceToTarget < self.distanceToLookAhead then
- self.speedLimit = math.clamp(8, self.speedLimit, 2 + self.distanceToTarget)
+ local currentTask = self.vehicle.ad.taskModule:getActiveTask()
+ local isCatchingCombine = currentTask.taskType ~= nil and self.vehicle.ad.taskModule:getActiveTask().taskType == "CatchCombinePipeTask"
+ if not isCatchingCombine then
+ self.speedLimit = math.clamp(8, self.speedLimit, 2 + self.distanceToTarget)
+ end
end
- self.speedLimit = math.min(self.speedLimit, self:getSpeedLimitBySteeringAngle())
+ if self:isOnRoadNetwork() then
+ self.speedLimit = math.min(self.speedLimit, self:getSpeedLimitBySteeringAngle())
+ else
+ -- Let's increase the cornering speed for paths generated with the pathfinder module. There are many 45° angles in there that slow the process down otherwise.
+ self.speedLimit = math.min(self.speedLimit, self:getSpeedLimitBySteeringAngle() * 1.5)
+ end
local maxSpeedDiff = ADDrivePathModule.MAX_SPEED_DEVIATION
if self.vehicle.ad.trailerModule:isUnloadingToBunkerSilo() then
@@ -252,11 +268,17 @@ function ADDrivePathModule:followWaypoints(dt)
self.vehicle.ad.specialDrivingModule:update(dt)
else
self.vehicle.ad.specialDrivingModule:releaseVehicle()
+ local speedDiff = (self.vehicle.lastSpeedReal * 3600) - self.speedLimit
-- Allow active braking if vehicle is not 'following' targetSpeed precise enough
- if (self.vehicle.lastSpeedReal * 3600) > (self.speedLimit + maxSpeedDiff) then
- self.acceleration = -0.6
+ if speedDiff <= 0.25 then
+ self.brakeHysteresisActive = false
end
-
+ if (speedDiff > maxSpeedDiff) or self.brakeHysteresisActive then
+ self.brakeHysteresisActive = true
+
+ self.acceleration = -math.min(0.6, speedDiff * 0.05)
+ end
+
--print("Speed: " .. (self.vehicle.lastSpeedReal * 3600) .. "/" .. self.speedLimit .. " acc: " .. self.acceleration .. " maxSpeedDiff: " .. maxSpeedDiff)
--print("LAD: " .. self.distanceToLookAhead .. " maxAngle: " .. self.maxAngle .. " maxAngleSpeed: " .. self.maxAngleSpeed)
--ADDrawingManager:addLineTask(x, y, z, self.targetX, y, self.targetZ, 1, 0, 0)
@@ -286,7 +308,7 @@ end
-- To differentiate between waypoints on the road and ones created from pathfinder
function ADDrivePathModule:isOnRoadNetwork()
- return (self.wayPoints ~= nil and self:getNextWayPoint() ~= nil and not self:getNextWayPoint().isPathFinderPoint)
+ return (self.wayPoints ~= nil and self:getCurrentWayPoint() ~= nil and not self:getCurrentWayPoint().isPathFinderPoint)
end
function ADDrivePathModule:getWayPoints()
@@ -431,27 +453,8 @@ function ADDrivePathModule:getMaxSpeedForAngle(angle)
local maxSpeed = math.huge
if angle < 5 then
- --[[
- elseif angle < 5 then
- maxSpeed = 38
- elseif angle < 8 then
- maxSpeed = 27
- elseif angle < 12 then
- maxSpeed = 20
- elseif angle < 20 then
- maxSpeed = 17
- elseif angle < 25 then
- maxSpeed = 16
- elseif angle < 100 then
- maxSpeed = 13
- --]]
maxSpeed = math.huge
elseif angle < 50 then
- --elseif angle < 100 then
- --maxSpeed = 8
- -- < 5 max
- -- > 5 = 60
- -- < 30 = 12
maxSpeed = 12 + 48 * (1 - math.clamp(0, (angle - 5), 25) / (30 - 5))
elseif angle >= 50 then
maxSpeed = 3
diff --git a/FS19_AutoDrive/scripts/Modules/PathFinderModule.lua b/FS19_AutoDrive/scripts/Modules/PathFinderModule.lua
index 33c9987c..b0e480cb 100644
--- a/FS19_AutoDrive/scripts/Modules/PathFinderModule.lua
+++ b/FS19_AutoDrive/scripts/Modules/PathFinderModule.lua
@@ -313,7 +313,7 @@ function PathFinderModule:startPathPlanningTo(targetPoint, targetVector)
local angleRad = math.atan2(targetVector.z, targetVector.x)
angleRad = AutoDrive.normalizeAngle(angleRad)
- self.minTurnRadius = AutoDrive.getDriverRadius(self.vehicle)
+ self.minTurnRadius = AutoDrive.getDriverRadius(self.vehicle) * 2 / 3
self.vectorX = {x = math.cos(angleRad) * self.minTurnRadius, z = math.sin(angleRad) * self.minTurnRadius}
self.vectorZ = {x = - math.sin(angleRad) * self.minTurnRadius, z = math.cos(angleRad) * self.minTurnRadius}
@@ -769,12 +769,12 @@ function PathFinderModule:testNextCells(cell)
self.grid[gridKey].incoming = cell
self.grid[gridKey].steps = cell.steps + 1
end
- elseif self.grid[gridKey].direction ~= location.direction then
- duplicatePointDirection = self.grid[gridKey].direction -- remember the grid direction
- if self.grid[gridKey].steps > (cell.steps + 1) then --found shortcut
- self.grid[gridKey].incoming = cell
- self.grid[gridKey].steps = cell.steps + 1
- end
+ --elseif self.grid[gridKey].direction ~= location.direction then
+ --duplicatePointDirection = self.grid[gridKey].direction -- remember the grid direction
+ --if self.grid[gridKey].steps > (cell.steps + 1) then --found shortcut -> not true!!! The outgoing angles would be all wrong here. This caused issues with undrivable paths being generated!
+ --self.grid[gridKey].incoming = cell
+ --self.grid[gridKey].steps = cell.steps + 1
+ --end
end
end
end
@@ -793,6 +793,7 @@ function PathFinderModule:testNextCells(cell)
end
if duplicatePointDirection >= 0 then
-- if different direction, it is not necessary to check the cell details again, just add a new entry in grid with known required restrictions
+ -- Todo : Not true!! If we come from a different direction we ususally have a differently sized collision box to check. There is a difference between a 0° angle when coming from the last cell and a +/- 45° angle.
gridKey = string.format("%d|%d|%d", location.x, location.z, duplicatePointDirection)
location.isRestricted = self.grid[gridKey].isRestricted
location.hasCollision = self.grid[gridKey].hasCollision
@@ -835,6 +836,7 @@ function PathFinderModule:checkGridCell(cell)
local worldPos = self:gridLocationToWorldLocation(cell)
--Try going through the checks in a way that fast checks happen before slower ones which might then be skipped
+ cell.isOnField = AutoDrive.checkIsOnField(worldPos.x, 0, worldPos.z)
if self.restrictToField and (self.fallBackMode1 and not self.fallBackMode2) then
-- limit cells to field border only possible if started on field
cell.bordercells = cell.incoming.bordercells + 1 -- by default we assume the new cell is not on field, so increase the counter
@@ -1472,9 +1474,13 @@ function PathFinderModule:getShapeDefByDirectionType(cell)
end
local increaseCellFactor = 1.15
+ if cell.isOnField ~= nil and cell.isOnField == true then
+ increaseCellFactor = 0.8
+ end
shapeDefinition.widthX = shapeDefinition.widthX * increaseCellFactor
shapeDefinition.widthZ = shapeDefinition.widthZ * increaseCellFactor
+
local corners = self:getCornersFromShapeDefinition(shapeDefinition)
if corners ~= nil then
for _, corner in pairs(corners) do
@@ -1544,8 +1550,11 @@ function PathFinderModule:createWayPoints()
self:smoothResultingPPPath_Refined()
if self.smoothStep == 2 then
- for i = 1, #self.wayPoints, 1 do
- self.wayPoints[i].isPathFinderPoint = true
+ -- When going to network, dont turn actual road network nodes into pathFinderPoints
+ if self.goingToNetwork then
+ for i = 1, #self.wayPoints, 1 do
+ self.wayPoints[i].isPathFinderPoint = true
+ end
end
if self.appendWayPoints ~= nil then
@@ -1553,13 +1562,19 @@ function PathFinderModule:createWayPoints()
self.wayPoints[#self.wayPoints + 1] = self.appendWayPoints[i]
end
self.smoothStep = 3
- PathFinderModule.debugVehicleMsg(self.vehicle,
- string.format("[AD] PFM %s createWayPoints appendWayPoints %s",
- tostring(self.vehicle:getName()),
- tostring(#self.appendWayPoints)
- )
- )
+ --PathFinderModule.debugVehicleMsg(self.vehicle,
+ --string.format("[AD] PFM %s createWayPoints appendWayPoints %s",
+ --tostring(self.vehicle:getName()),
+ --tostring(#self.appendWayPoints)
+ --)
+ --)
+ end
+ -- See comment above
+ if not self.goingToNetwork then
+ for i = 1, #self.wayPoints, 1 do
+ self.wayPoints[i].isPathFinderPoint = true
+ end
end
end
end
@@ -1594,12 +1609,12 @@ function PathFinderModule:smoothResultingPPPath()
end
self.wayPoints = filteredWPs
- PathFinderModule.debugVehicleMsg(self.vehicle,
- string.format("[AD] PFM %s smoothResultingPPPath self.wayPoints %s",
- tostring(self.vehicle:getName()),
- tostring(#self.wayPoints)
- )
- )
+ --PathFinderModule.debugVehicleMsg(self.vehicle,
+ --string.format("[AD] PFM %s smoothResultingPPPath self.wayPoints %s",
+ --tostring(self.vehicle:getName()),
+ --tostring(#self.wayPoints)
+ --)
+ --)
end
@@ -1623,6 +1638,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
if self.smoothStep == 1 then
local stepsThisFrame = 0
while self.smoothIndex < #self.wayPoints - unfilteredEndPointCount and stepsThisFrame < ADScheduler:getStepsPerFrame() do
+ --[[
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
string.format("[AD] PFM %s smoothResultingPPPath_Refined self.smoothIndex %d ",
@@ -1631,6 +1647,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
)
end
+ --]]
stepsThisFrame = stepsThisFrame + 1
local node = self.wayPoints[self.smoothIndex]
@@ -1653,9 +1670,10 @@ function PathFinderModule:smoothResultingPPPath_Refined()
local y = worldPos.y
local foundCollision = false
- local stepsOfLookAheadThisFrame = 0
+ --local stepsOfLookAheadThisFrame = 0
- while (foundCollision == false or self.totalEagerSteps < 30) and ((self.smoothIndex + self.totalEagerSteps) < (#self.wayPoints - unfilteredEndPointCount)) and stepsOfLookAheadThisFrame < ADScheduler:getStepsPerFrame() do
+ while (foundCollision == false or self.totalEagerSteps < 30) and ((self.smoothIndex + self.totalEagerSteps) < (#self.wayPoints - unfilteredEndPointCount)) and stepsThisFrame <= math.max(1, (ADScheduler:getStepsPerFrame() * 0.4)) do
+ --[[
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
string.format("[AD] PFM %s smoothResultingPPPath_Refined self.smoothIndex %d self.totalEagerSteps %d",
@@ -1665,8 +1683,9 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
)
end
+ --]]
local hasCollision = false
- stepsOfLookAheadThisFrame = stepsOfLookAheadThisFrame + 1
+ stepsThisFrame = stepsThisFrame + 1
local nodeAhead = self.wayPoints[self.smoothIndex + self.totalEagerSteps + 1]
local nodeTwoAhead = self.wayPoints[self.smoothIndex + self.totalEagerSteps + 2]
@@ -1674,6 +1693,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
angle = math.abs(angle)
if angle > 60 then
hasCollision = true
+ --[[
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
string.format("[AD] PFM %s smoothResultingPPPath_Refined hasCollision %d",
@@ -1682,12 +1702,14 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
)
end
+ --]]
end
if previousNode ~= nil then
angle = AutoDrive.angleBetween({x = node.x - previousNode.x, z = node.z - previousNode.z}, {x = nodeTwoAhead.x - node.x, z = nodeTwoAhead.z - node.z})
angle = math.abs(angle)
if angle > 60 then
hasCollision = true
+ --[[
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
string.format("[AD] PFM %s smoothResultingPPPath_Refined hasCollision %d",
@@ -1696,11 +1718,13 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
)
end
+ --]]
end
angle = AutoDrive.angleBetween({x = node.x - previousNode.x, z = node.z - previousNode.z}, {x = nodeAhead.x - node.x, z = nodeAhead.z - node.z})
angle = math.abs(angle)
if angle > 60 then
hasCollision = true
+ --[[
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
string.format("[AD] PFM %s smoothResultingPPPath_Refined hasCollision %d",
@@ -1709,12 +1733,14 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
)
end
+ --]]
end
end
if not hasCollision then
hasCollision = hasCollision or self:checkSlopeAngle(worldPos.x, worldPos.z, nodeAhead.x, nodeAhead.z)
if hasCollision then
+ --[[
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
string.format("[AD] PFM %s smoothResultingPPPath_Refined hasCollision %d",
@@ -1723,6 +1749,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
)
end
+ --]]
end
end
@@ -1750,6 +1777,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
if not hasCollision then
local shapes = overlapBox(worldPos.x + vectorX / 2, y + 3, worldPos.z + vectorZ / 2, 0, angleRad, 0, length / 2 + 2.5, 2.65, sideLength + 1.5, "collisionTestCallbackIgnore", nil, self.mask, true, true, true)
hasCollision = hasCollision or (shapes > 0)
+ --[[
if hasCollision then
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
@@ -1760,6 +1788,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
end
end
+ --]]
end
if (self.smoothIndex > 1) then
@@ -1769,6 +1798,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
if (angleBetween * 1.25) > AITurnStrategy.SLOPE_DETECTION_THRESHOLD then
hasCollision = true
+ --[[
if hasCollision then
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
@@ -1779,6 +1809,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
end
end
+ --]]
end
end
@@ -1806,6 +1837,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
end
hasCollision = hasCollision or (fruitValue > 50)
if hasCollision then
+ --[[
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
string.format("[AD] PFM %s smoothResultingPPPath_Refined hasCollision %d",
@@ -1814,6 +1846,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
)
end
+ --]]
break
end
end
@@ -1828,6 +1861,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
fruitValue, _, _, _ = FSDensityMapUtil.getFruitArea(self.fruitToCheck, cornerX, cornerZ, corner2X, corner2Z, corner4X, corner4Z, true, true)
end
hasCollision = hasCollision or (fruitValue > 50)
+ --[[
if hasCollision then
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
@@ -1838,6 +1872,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
end
end
+ --]]
end
end
end
@@ -1845,6 +1880,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
if not hasCollision then
local cellBox = AutoDrive.boundingBoxFromCorners(cornerX, cornerZ, corner2X, corner2Z, corner3X, corner3Z, corner4X, corner4Z)
hasCollision = hasCollision or AutoDrive.checkForVehiclePathInBox(cellBox, self.minTurnRadius, self.vehicle)
+ --[[
if hasCollision then
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
@@ -1855,6 +1891,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
end
end
+ --]]
end
foundCollision = hasCollision
@@ -1866,6 +1903,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
end
self.totalEagerSteps = self.totalEagerSteps + 1
+ --[[
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
PathFinderModule.debugVehicleMsg(self.vehicle,
string.format("[AD] PFM %s smoothResultingPPPath_Refined self.smoothIndex %d self.totalEagerSteps %d self.filteredIndex %d foundCollision %s",
@@ -1877,6 +1915,7 @@ function PathFinderModule:smoothResultingPPPath_Refined()
)
)
end
+ --]]
end
if self.totalEagerSteps >= 30 or ((self.smoothIndex + self.totalEagerSteps) >= (#self.wayPoints - unfilteredEndPointCount)) then
@@ -1902,12 +1941,14 @@ function PathFinderModule:smoothResultingPPPath_Refined()
self.wayPoints = self.filteredWPs
self.smoothDone = true
+ --[[
PathFinderModule.debugVehicleMsg(self.vehicle,
string.format("[AD] PFM %s smoothResultingPPPath_Refined self.wayPoints %s",
tostring(self.vehicle:getName()),
tostring(#self.wayPoints)
)
)
+ --]]
end
end
diff --git a/FS19_AutoDrive/scripts/Modules/RecordingModule.lua b/FS19_AutoDrive/scripts/Modules/RecordingModule.lua
index 4e35ea65..9307c1bb 100644
--- a/FS19_AutoDrive/scripts/Modules/RecordingModule.lua
+++ b/FS19_AutoDrive/scripts/Modules/RecordingModule.lua
@@ -10,11 +10,13 @@ function ADRecordingModule:new(vehicle)
o.lastWp = nil
o.secondLastWp = nil
o.isRecordingReverse = false
+ o.isSubPrio = false
return o
end
-function ADRecordingModule:start(dual)
+function ADRecordingModule:start(dual, subPrio)
self.isDual = dual
+ self.isSubPrio = subPrio
self.vehicle:stopAutoDrive()
local rearOffset = 0
@@ -28,7 +30,7 @@ function ADRecordingModule:start(dual)
if self.drivingReverse then
x1, y1, z1 = localToWorld(self.vehicle.ad.specialDrivingModule:getReverseNode(), 0, 0, rearOffset)
end
- self.lastWp = ADGraphManager:recordWayPoint(x1, y1, z1, false, false, self.drivingReverse)
+ self.lastWp = ADGraphManager:recordWayPoint(x1, y1, z1, false, false, self.drivingReverse, 0, self.isSubPrio)
self.lastWpPosition = {}
self.lastWpPosition.x, self.lastWpPosition.y, self.lastWpPosition.z = getWorldTranslation(self.vehicle.components[1].node)
@@ -102,7 +104,11 @@ function ADRecordingModule:updateTick(dt, isActiveForInput, isActiveForInputIgno
if self.isRecordingReverse then
minDistanceToLastWayPoint = (MathUtil.vector2Length(reverseX - self.lastWp.x, reverseZ - self.lastWp.z) > 1)
else
- minDistanceToLastWayPoint = (MathUtil.vector2Length(vehicleX - self.lastWp.x, vehicleZ - self.lastWp.z) > 1)
+ if not self.isDual and not self.isSubPrio then
+ minDistanceToLastWayPoint = (MathUtil.vector2Length(vehicleX - self.lastWp.x, vehicleZ - self.lastWp.z) > 1)
+ else
+ minDistanceToLastWayPoint = false
+ end
end
end
@@ -114,7 +120,7 @@ function ADRecordingModule:updateTick(dt, isActiveForInput, isActiveForInputIgno
if self.secondLastWp == nil then
if MathUtil.vector2Length(x - self.lastWp.x, z - self.lastWp.z) > 3 and MathUtil.vector2Length(vehicleX - self.lastWp.x, vehicleZ - self.lastWp.z) > 3 then
self.secondLastWp = self.lastWp
- self.lastWp = ADGraphManager:recordWayPoint(x, y, z, true, self.isDual, self.drivingReverse, self.secondLastWp.id)
+ self.lastWp = ADGraphManager:recordWayPoint(x, y, z, true, self.isDual, self.drivingReverse, self.secondLastWp.id, self.isSubPrio)
self.lastWpPosition.x, self.lastWpPosition.y, self.lastWpPosition.z = getWorldTranslation(self.vehicle.components[1].node)
self.isRecordingReverse = self.drivingReverse
end
@@ -145,7 +151,7 @@ function ADRecordingModule:updateTick(dt, isActiveForInput, isActiveForInputIgno
if MathUtil.vector2Length(x - self.lastWp.x, z - self.lastWp.z) > max_distance and minDistanceToLastWayPoint and speedMatchesRecording then
self.secondLastWp = self.lastWp
- self.lastWp = ADGraphManager:recordWayPoint(x, y, z, true, self.isDual, self.drivingReverse, self.secondLastWp.id)
+ self.lastWp = ADGraphManager:recordWayPoint(x, y, z, true, self.isDual, self.drivingReverse, self.secondLastWp.id, self.isSubPrio)
self.lastWpPosition.x, self.lastWpPosition.y, self.lastWpPosition.z = getWorldTranslation(self.vehicle.components[1].node)
self.isRecordingReverse = self.drivingReverse
end
diff --git a/FS19_AutoDrive/scripts/Modules/SpecialDrivingModule.lua b/FS19_AutoDrive/scripts/Modules/SpecialDrivingModule.lua
index 683a4e2b..881e0176 100644
--- a/FS19_AutoDrive/scripts/Modules/SpecialDrivingModule.lua
+++ b/FS19_AutoDrive/scripts/Modules/SpecialDrivingModule.lua
@@ -48,6 +48,11 @@ function ADSpecialDrivingModule:update(dt)
dbg.stoppedTimer = self.stoppedTimer.elapsedTime
AutoDrive.renderTable(0.6, 0.7, 0.009, dbg)
end
+
+ if not self.isReversing then
+ self.reverseTarget = nil
+ end
+ self.isReversing = false
end
function ADSpecialDrivingModule:isStoppingVehicle()
@@ -107,20 +112,29 @@ function ADSpecialDrivingModule:driveForward(dt)
AIVehicleUtil.driveInDirection(self.vehicle, dt, 30, acc, 0.2, 20, true, true, lx, lz, speed, 1)
end
-function ADSpecialDrivingModule:driveReverse(dt, maxSpeed, maxAcceleration)
+function ADSpecialDrivingModule:driveReverse(dt, maxSpeed, maxAcceleration, guided)
+ self.isReversing = true
local speed = maxSpeed
local acc = maxAcceleration
- local targetX, targetY, targetZ = localToWorld(self.vehicle.components[1].node, 0, 0, -20)
- local lx, lz = AIVehicleUtil.getDriveDirection(self.vehicle.components[1].node, targetX, targetY, targetZ)
if self.vehicle.ad.collisionDetectionModule:checkReverseCollision() then
self:stopAndHoldVehicle(dt)
else
- local storedSmootherDriving = AutoDrive.smootherDriving
- AutoDrive.smootherDriving = false
- AIVehicleUtil.driveInDirection(self.vehicle, dt, 30, acc, 0.2, 20, true, false, -lx, -lz, speed, 1)
- AutoDrive.smootherDriving = storedSmootherDriving
+ if guided ~= true then
+ local targetX, targetY, targetZ = localToWorld(self.vehicle.components[1].node, 0, 0, -20)
+ local lx, lz = AIVehicleUtil.getDriveDirection(self.vehicle.components[1].node, targetX, targetY, targetZ)
+ local storedSmootherDriving = AutoDrive.smootherDriving
+ AutoDrive.smootherDriving = false
+ AIVehicleUtil.driveInDirection(self.vehicle, dt, 30, acc, 0.2, 20, true, false, -lx, -lz, speed, 1)
+ AutoDrive.smootherDriving = storedSmootherDriving
+ else
+ if self.reverseTarget == nil then
+ local x, y, z = localToWorld(self.vehicle.components[1].node, 0, 0 , -100)
+ self.reverseTarget = {x=x, y=y, z=z}
+ end
+ self.vehicle.ad.specialDrivingModule:reverseToTargetLocation(dt, self.reverseTarget, maxSpeed)
+ end
end
end
@@ -315,7 +329,10 @@ function ADSpecialDrivingModule:getReverseNode()
return reverseNode
end
-function ADSpecialDrivingModule:reverseToPoint(dt)
+function ADSpecialDrivingModule:reverseToPoint(dt, maxSpeed)
+ if maxSpeed == nil then
+ maxSpeed = math.huge
+ end
local vehicleIsTruck = self:isTruck(self.vehicle)
if self.lastAngleToPoint == nil then
@@ -388,13 +405,14 @@ function ADSpecialDrivingModule:reverseToPoint(dt)
local storedSmootherDriving = AutoDrive.smootherDriving
AutoDrive.smootherDriving = false
+ speed = math.min(maxSpeed, speed)
AIVehicleUtil.driveInDirection(self.vehicle, dt, maxAngle, acc, 0.2, 20, true, false, lx, lz, speed, 1)
AutoDrive.smootherDriving = storedSmootherDriving
self.lastAngleToPoint = self.angleToPoint
end
-function ADSpecialDrivingModule:reverseToTargetLocation(dt, location)
+function ADSpecialDrivingModule:reverseToTargetLocation(dt, location, maxSpeed)
self.reverseNode = self:getReverseNode()
if self.reverseNode == nil then
return true
@@ -413,7 +431,7 @@ function ADSpecialDrivingModule:reverseToTargetLocation(dt, location)
if self.vehicle.ad.collisionDetectionModule:checkReverseCollision() then
self:stopAndHoldVehicle(dt)
else
- self:reverseToPoint(dt)
+ self:reverseToPoint(dt, maxSpeed)
end
return false
diff --git a/FS19_AutoDrive/scripts/Modules/StateModule.lua b/FS19_AutoDrive/scripts/Modules/StateModule.lua
index be29a841..dd651099 100644
--- a/FS19_AutoDrive/scripts/Modules/StateModule.lua
+++ b/FS19_AutoDrive/scripts/Modules/StateModule.lua
@@ -3,9 +3,16 @@ ADStateModule = {}
ADStateModule.CREATE_OFF = 1
ADStateModule.CREATE_NORMAL = 2
ADStateModule.CREATE_DUAL = 3
+ADStateModule.CREATE_SUB_PRIO = 4
+ADStateModule.CREATE_SUB_PRIO_DUAL = 5
ADStateModule.CALCULATE_REMAINING_DRIVETIME_INTERVAL = 1000
+ADStateModule.HIGHEST_MODE = 6
+
+ADStateModule.BUNKER_UNLOAD_TRIGGER = 1
+ADStateModule.BUNKER_UNLOAD_TRAILER = 2
+
function ADStateModule:new(vehicle)
local o = {}
setmetatable(o, self)
@@ -55,14 +62,17 @@ function ADStateModule:reset()
self.remainingDriveTime = 0
self.calculateRemainingDriveTimeInterval = 0
self.refuelFillType = 0
+ self.activeBeforeSave = false
+ self.AIVEActiveBeforeSave = false
+ self.bunkerUnloadType = ADStateModule.BUNKER_UNLOAD_TRIGGER
end
function ADStateModule:readFromXMLFile(xmlFile, key)
local mode = getXMLInt(xmlFile, key .. "#mode")
if mode ~= nil then
- if mode == AutoDrive.MODE_BGA then
- mode = AutoDrive.MODE_DRIVETO
- end
+ --if mode == AutoDrive.MODE_BGA then
+ --mode = AutoDrive.MODE_DRIVETO
+ --end
self.mode = mode
end
@@ -109,6 +119,21 @@ function ADStateModule:readFromXMLFile(xmlFile, key)
if driverName ~= nil then
self.driverName = driverName
end
+
+ local lastActive = getXMLBool(xmlFile, key .. "#lastActive")
+ if lastActive ~= nil then
+ self.activeBeforeSave = lastActive
+ end
+
+ local AIVElastActive = getXMLBool(xmlFile, key .. "#AIVElastActive")
+ if AIVElastActive ~= nil then
+ self.AIVEActiveBeforeSave = AIVElastActive
+ end
+
+ local bunkerUnloadType = getXMLInt(xmlFile, key .. "#bunkerUnloadType")
+ if bunkerUnloadType ~= nil then
+ self.bunkerUnloadType = bunkerUnloadType
+ end
end
function ADStateModule:saveToXMLFile(xmlFile, key)
@@ -124,6 +149,9 @@ function ADStateModule:saveToXMLFile(xmlFile, key)
setXMLInt(xmlFile, key .. "#speedLimit", self.speedLimit)
setXMLInt(xmlFile, key .. "#fieldSpeedLimit", self.fieldSpeedLimit)
setXMLString(xmlFile, key .. "#driverName", self.driverName)
+ setXMLBool(xmlFile, key .. "#lastActive", self.active)
+ setXMLBool(xmlFile, key .. "#AIVElastActive", (self.vehicle.acParameters ~= nil and self.vehicle.acParameters.enabled and self.vehicle.spec_aiVehicle.isActive))
+ setXMLInt(xmlFile, key .. "#bunkerUnloadType", self.bunkerUnloadType)
end
function ADStateModule:writeStream(streamId)
@@ -148,6 +176,7 @@ function ADStateModule:writeStream(streamId)
streamWriteString(streamId, self.driverName)
streamWriteUInt16(streamId, self.remainingDriveTime)
streamWriteUIntN(streamId, self.refuelFillType, 8)
+ streamWriteUIntN(streamId, self.bunkerUnloadType, 3)
end
function ADStateModule:readStream(streamId)
@@ -172,6 +201,7 @@ function ADStateModule:readStream(streamId)
self.driverName = streamReadString(streamId)
self.remainingDriveTime = streamReadUInt16(streamId)
self.refuelFillType = streamReadUIntN(streamId, 8)
+ self.bunkerUnloadType = streamReadUIntN(streamId, 3)
self.currentLocalizedTaskInfo = AutoDrive.localize(self.currentTaskInfo)
end
@@ -198,6 +228,7 @@ function ADStateModule:writeUpdateStream(streamId)
streamWriteString(streamId, self.driverName)
streamWriteUInt16(streamId, self.remainingDriveTime)
streamWriteUIntN(streamId, self.refuelFillType, 8)
+ streamWriteUIntN(streamId, self.bunkerUnloadType, 3)
end
function ADStateModule:readUpdateStream(streamId)
@@ -222,6 +253,7 @@ function ADStateModule:readUpdateStream(streamId)
self.driverName = streamReadString(streamId)
self.remainingDriveTime = streamReadUInt16(streamId)
self.refuelFillType = streamReadUIntN(streamId, 8)
+ self.bunkerUnloadType = streamReadUIntN(streamId, 3)
self.currentLocalizedTaskInfo = AutoDrive.localize(self.currentTaskInfo)
end
@@ -389,11 +421,12 @@ function ADStateModule:getCurrentMode()
end
function ADStateModule:nextMode()
- if self.mode < AutoDrive.MODE_UNLOAD then
+ if self.mode < ADStateModule.HIGHEST_MODE then
self.mode = self.mode + 1
else
self.mode = AutoDrive.MODE_DRIVETO
end
+ AutoDrive.Hud.lastUIScale = 0
self:raiseDirtyFlag()
end
@@ -401,14 +434,16 @@ function ADStateModule:previousMode()
if self.mode > AutoDrive.MODE_DRIVETO then
self.mode = self.mode - 1
else
- self.mode = AutoDrive.MODE_UNLOAD
+ self.mode = ADStateModule.HIGHEST_MODE
end
+ AutoDrive.Hud.lastUIScale = 0
self:raiseDirtyFlag()
end
function ADStateModule:setMode(newMode)
- if newMode >= AutoDrive.MODE_DRIVETO and newMode <= AutoDrive.MODE_UNLOAD and newMode ~= self.mode then
+ if newMode >= AutoDrive.MODE_DRIVETO and newMode <= ADStateModule.HIGHEST_MODE and newMode ~= self.mode then
self.mode = newMode
+ AutoDrive.Hud.lastUIScale = 0
self:raiseDirtyFlag()
end
end
@@ -431,7 +466,7 @@ function ADStateModule:setActive(active)
end
function ADStateModule:isInCreationMode()
- return (self.creationMode == ADStateModule.CREATE_NORMAL) or (self.creationMode == ADStateModule.CREATE_DUAL)
+ return (self.creationMode == ADStateModule.CREATE_NORMAL) or (self.creationMode == ADStateModule.CREATE_DUAL) or (self.creationMode == ADStateModule.CREATE_SUB_PRIO) or (self.creationMode == ADStateModule.CREATE_SUB_PRIO_DUAL)
end
function ADStateModule:isInNormalCreationMode()
@@ -442,6 +477,14 @@ function ADStateModule:isInDualCreationMode()
return self.creationMode == ADStateModule.CREATE_DUAL
end
+function ADStateModule:isInSubPrioCreationMode()
+ return self.creationMode == ADStateModule.CREATE_SUB_PRIO
+end
+
+function ADStateModule:isInSubPrioDualCreationMode()
+ return self.creationMode == ADStateModule.CREATE_SUB_PRIO_DUAL
+end
+
function ADStateModule:disableCreationMode()
self.creationMode = ADStateModule.CREATE_OFF
self:raiseDirtyFlag()
@@ -454,7 +497,7 @@ function ADStateModule:startNormalCreationMode()
self.creationMode = ADStateModule.CREATE_NORMAL
self:raiseDirtyFlag()
if self.vehicle.ad.recordingModule ~= nil then
- self.vehicle.ad.recordingModule:start(false)
+ self.vehicle.ad.recordingModule:start(false, false)
end
end
@@ -462,7 +505,23 @@ function ADStateModule:startDualCreationMode()
self.creationMode = ADStateModule.CREATE_DUAL
self:raiseDirtyFlag()
if self.vehicle.ad.recordingModule ~= nil then
- self.vehicle.ad.recordingModule:start(true)
+ self.vehicle.ad.recordingModule:start(true, false)
+ end
+end
+
+function ADStateModule:startSubPrioCreationMode()
+ self.creationMode = ADStateModule.CREATE_SUB_PRIO
+ self:raiseDirtyFlag()
+ if self.vehicle.ad.recordingModule ~= nil then
+ self.vehicle.ad.recordingModule:start(false, true)
+ end
+end
+
+function ADStateModule:startSubPrioDualCreationMode()
+ self.creationMode = ADStateModule.CREATE_SUB_PRIO_DUAL
+ self:raiseDirtyFlag()
+ if self.vehicle.ad.recordingModule ~= nil then
+ self.vehicle.ad.recordingModule:start(true, true)
end
end
@@ -835,3 +894,20 @@ function ADStateModule:setRefuelFillType(refuelFillType)
self.refuelFillType = refuelFillType
self:raiseDirtyFlag()
end
+
+function ADStateModule:nextBunkerUnloadType()
+ if self.bunkerUnloadType < ADStateModule.BUNKER_UNLOAD_TRAILER then
+ self.bunkerUnloadType = self.bunkerUnloadType + 1
+ else
+ self.bunkerUnloadType = ADStateModule.BUNKER_UNLOAD_TRIGGER
+ end
+ self:raiseDirtyFlag()
+end
+
+function ADStateModule:getBunkerUnloadType()
+ return self.bunkerUnloadType
+end
+
+function ADStateModule:getBunkerUnloadTypeIsTrigger()
+ return self.bunkerUnloadType == ADStateModule.BUNKER_UNLOAD_TRIGGER
+end
diff --git a/FS19_AutoDrive/scripts/Modules/TrailerModule.lua b/FS19_AutoDrive/scripts/Modules/TrailerModule.lua
index d51fb29d..f59361a7 100644
--- a/FS19_AutoDrive/scripts/Modules/TrailerModule.lua
+++ b/FS19_AutoDrive/scripts/Modules/TrailerModule.lua
@@ -56,7 +56,7 @@ function ADTrailerModule:reset()
end
function ADTrailerModule:isActiveAtTrigger()
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_TRAILERINFO, "[AD] ADTrailerModule:isActiveAtTrigger self.isLoading %s self.isUnloading %s", tostring(self.isLoading), tostring(self.isUnloading))
+ --AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_TRAILERINFO, "[AD] ADTrailerModule:isActiveAtTrigger self.isLoading %s self.isUnloading %s", tostring(self.isLoading), tostring(self.isUnloading))
return self.isLoading or self.isUnloading
end
@@ -389,15 +389,16 @@ function ADTrailerModule:updateUnload(dt)
AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_TRAILERINFO, "[AD] ADTrailerModule:updateUnload Monitor unloading")
--print("Monitor unloading")
local _, _, fillUnitEmpty = AutoDrive.getIsEmpty(self.vehicle, self.isUnloadingWithTrailer, self.isUnloadingWithFillUnit)
+ local allTrailersClosed = self:areAllTrailersClosed(dt)
self.unloadDelayTimer:timer(self.isUnloading, 250, dt)
if self.unloadDelayTimer:done() then
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_TRAILERINFO, "[AD] ADTrailerModule:updateUnload Monitor unloading unloadDelayTimer:done areAllTrailersClosed %s", tostring(self:areAllTrailersClosed(dt)))
+ AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_TRAILERINFO, "[AD] ADTrailerModule:updateUnload Monitor unloading unloadDelayTimer:done areAllTrailersClosed %s", tostring(allTrailersClosed))
self.unloadRetryTimer:timer(self.isUnloading, ADTrailerModule.UNLOAD_RETRY_TIME, dt)
- if self:areAllTrailersClosed(dt) and (fillUnitEmpty or ((AutoDrive.getSetting("rotateTargets", self.vehicle) == AutoDrive.RT_ONLYDELIVER or AutoDrive.getSetting("rotateTargets", self.vehicle) == AutoDrive.RT_PICKUPANDDELIVER) and AutoDrive.getSetting("useFolders"))) then
+ if allTrailersClosed and (fillUnitEmpty or ((AutoDrive.getSetting("rotateTargets", self.vehicle) == AutoDrive.RT_ONLYDELIVER or AutoDrive.getSetting("rotateTargets", self.vehicle) == AutoDrive.RT_PICKUPANDDELIVER) and AutoDrive.getSetting("useFolders"))) then
self.unloadDelayTimer:timer(false) -- clear timer
self.isUnloading = false
self.unloadingToBunkerSilo = false
- elseif (self:areAllTrailersClosed(dt) and self.isUnloadingWithTrailer ~= nil and self.isUnloadingWithTrailer.spec_pipe ~= nil) then
+ elseif allTrailersClosed and self.isUnloadingWithTrailer ~= nil and self.isUnloadingWithTrailer.spec_pipe ~= nil then
-- unload auger wagon to another trailer
self.unloadDelayTimer:timer(false) -- clear timer
self.isUnloading = false
diff --git a/FS19_AutoDrive/scripts/PathCalculation.lua b/FS19_AutoDrive/scripts/PathCalculation.lua
index ba12a3a0..84409bc9 100644
--- a/FS19_AutoDrive/scripts/PathCalculation.lua
+++ b/FS19_AutoDrive/scripts/PathCalculation.lua
@@ -1,9 +1,10 @@
ADPathCalculator = {}
-function ADPathCalculator:GetPath(startID, targetID)
+function ADPathCalculator:GetPath(startID, targetID, preferredStartIds)
local count = 0
if not ADGraphManager:areWayPointsPrepared() then
+ print("ADPathCalculator - preparing waypoints")
AutoDrive.checkWaypointsLinkedtothemselve(true) -- find WP linked to themselve, with parameter true issues will be fixed
AutoDrive.checkWaypointsMultipleSameOut(true) -- find WP with multiple same out ID, with parameter true issues will be fixed
ADGraphManager:prepareWayPoints()
@@ -11,7 +12,7 @@ function ADPathCalculator:GetPath(startID, targetID)
local network = ADGraphManager:getWayPoints()
local addedWeights = self:getDetourWeights()
-
+ local subPrioNode = ADGraphManager:getSubPrioMarkerNode()
if startID == nil or targetID == nil or network[startID] == nil or network[targetID] == nil then
return {}
@@ -32,8 +33,24 @@ function ADPathCalculator:GetPath(startID, targetID)
return sqrt(a * a + b * b)
end
+ local isSubPrio = function(pointToTest)
+ if subPrioNode == nil then
+ return false
+ end
+ for _, neighborId in pairs(pointToTest.out) do
+ local neighbor = network[neighborId]
+ if neighbor ~= nil then
+ if neighbor.id == subPrioNode.id then
+ return true
+ end
+ end
+ end
+
+ return false
+ end
+
local lastPredecessor = nil
- while not candidates:empty() and not foundTarget and count < 200000 do
+ while not candidates:empty() and not foundTarget do
local next = candidates:dequeue()
local point, distance, previousPoint = next.p, next.distance, next.pre
while point ~= nil do
@@ -54,8 +71,8 @@ function ADPathCalculator:GetPath(startID, targetID)
for _, outId in pairs(outMap) do
local outPoint = network[outId]
--- axel TODO implement automatic network check for such issue: waypoint linked to itself -> DONE with AutoDrive.checkWaypointsLinkedtothemselve(true)
- if point.id ~= outPoint.id then
+ -- axel TODO implement automatic network check for such issue: waypoint linked to itself -> DONE with AutoDrive.checkWaypointsLinkedtothemselve(true)
+ --if point.id ~= outPoint.id then
-- First check if this point needs to be added to the candidate list or if it has already been tested
local toBeAdded = true
if results[outId] ~= nil then
@@ -69,8 +86,18 @@ function ADPathCalculator:GetPath(startID, targetID)
toBeAdded = false
end
end
- if toBeAdded or (#point.incoming > 1) then
- candidates:enqueue({p=outPoint, distance=(distance + distanceFunc(outPoint.x - point.x, outPoint.z - point.z) + (addedWeights[outPoint.id] or 0)), pre=point.id})
+ if toBeAdded then --or (#point.incoming > 1)
+ local factor = 1
+ if isSubPrio(outPoint) then
+ factor = 20
+ end
+ local preventTurnaroundWeight = 0
+ if point.id == startID then
+ if not table.contains(preferredStartIds, outPoint.id) then
+ preventTurnaroundWeight = 5000000
+ end
+ end
+ candidates:enqueue({p=outPoint, distance=(distance + distanceFunc(outPoint.x - point.x, outPoint.z - point.z) * factor + (addedWeights[outPoint.id] or 0) + preventTurnaroundWeight), pre=point.id})
end
if results[point.id][outId] == nil then
@@ -80,7 +107,7 @@ function ADPathCalculator:GetPath(startID, targetID)
results[point.id][outId] = {distance=distance, pre=previousPoint}
end
end
- end
+ --end
end
point = nil
else
@@ -102,8 +129,7 @@ function ADPathCalculator:GetPath(startID, targetID)
end
end
end
- count = count + 1
-end
+ end
if not foundTarget then
return {}
diff --git a/FS19_AutoDrive/scripts/Sensors/VirtualSensors.lua b/FS19_AutoDrive/scripts/Sensors/VirtualSensors.lua
index 055cf836..00bf922e 100644
--- a/FS19_AutoDrive/scripts/Sensors/VirtualSensors.lua
+++ b/FS19_AutoDrive/scripts/Sensors/VirtualSensors.lua
@@ -225,7 +225,8 @@ function ADSensor:getLocationByPosition()
if location == nil then
location = {x = 0, z = vehicle.sizeLength / 2}
end
- location.z = location.z + 2
+ --location.z = location.z + AutoDrive.getVehicleLeadingEdge(vehicle)
+ --location.z = location.z + 2
elseif self.position == ADSensor.POS_REAR then
location.z = - vehicle.sizeLength / 2
self.frontFactor = -1
@@ -402,13 +403,17 @@ function ADSensor:onDrawDebug(box)
end
end
-function ADSensor:pollInfo(forced, widthFactor)
+function ADSensor:pollInfo(forced, widthFactor, lengthFactor)
self.executionDelay = self.executionDelay -1
if self.executionDelay <= 0 or forced or AutoDrive.getDebugChannelIsSet(AutoDrive.DC_SENSORINFO) then
local storedWidth = self.width
if widthFactor ~= nil then
self.width = self.width * widthFactor
end
+ local storedLength = self.length
+ if lengthFactor ~= nil then
+ self.length = self.length * lengthFactor
+ end
local wasEnabled = self.enabled
self:setEnabled(true)
if not wasEnabled then
@@ -417,6 +422,7 @@ function ADSensor:pollInfo(forced, widthFactor)
self.lastTriggered = self:isTriggered()
self.executionDelay = ADSensor.EXECUTION_DELAY
self.width = storedWidth
+ self.length = storedLength
end
return self.lastTriggered
@@ -450,7 +456,7 @@ function ADSensor:isTriggered()
end
function ADSensor:getRotatedFront()
- if self.frontAxle == nil then
+ --if self.frontAxle == nil then
local frontWheel = nil
local pairWheel = nil
local frontDistance = math.huge
@@ -476,17 +482,18 @@ function ADSensor:getRotatedFront()
local axleCenterZ = frontWheelZ + 0.5 * (pairWheelZ - frontWheelZ)
local _, _, diffZ = worldToLocal(self.vehicle.components[1].node, axleCenterX, axleCenterY, axleCenterZ)
local wheelBaseToFront = self.vehicle.sizeLength / 2 - diffZ
-
- self.frontAxleLength = wheelBaseToFront
+ local leadingEdge = AutoDrive.getVehicleLeadingEdge(self.vehicle)
+ self.frontAxleLength = wheelBaseToFront + leadingEdge
self.frontAxle = {}
self.frontAxle.x, self.frontAxle.y, self.frontAxle.z = worldToLocal(self.vehicle.components[1].node, axleCenterX, axleCenterY, axleCenterZ)
end
- else
- local rx, _, rz = localDirectionToWorld(self.vehicle.components[1].node, math.sin(self.vehicle.rotatedTime), 0, math.cos(self.vehicle.rotatedTime))
- local frontPoint = {x = self.frontAxle.x + self.frontAxleLength * math.sin(self.vehicle.rotatedTime), y = self.frontAxle.y, z = self.frontAxle.z + self.frontAxleLength * math.cos(self.vehicle.rotatedTime)}
- return frontPoint
- end
+ if self.frontAxle ~= nil then
+ local rx, _, rz = localDirectionToWorld(self.vehicle.components[1].node, math.sin(self.vehicle.rotatedTime), 0, math.cos(self.vehicle.rotatedTime))
+ local frontPoint = {x = self.frontAxle.x + self.frontAxleLength * math.sin(self.vehicle.rotatedTime), y = self.frontAxle.y, z = self.frontAxle.z + self.frontAxleLength * math.cos(self.vehicle.rotatedTime)}
+
+ return frontPoint
+ end
return nil
end
diff --git a/FS19_AutoDrive/scripts/Settings.lua b/FS19_AutoDrive/scripts/Settings.lua
index b058f3ee..bfa23cd3 100644
--- a/FS19_AutoDrive/scripts/Settings.lua
+++ b/FS19_AutoDrive/scripts/Settings.lua
@@ -569,10 +569,9 @@ AutoDrive.settings.enableTrafficDetection = {
isVehicleSpecific = false
}
---[[
AutoDrive.settings.shovelWidth = {
- values = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0},
- texts = {"0m", "0.1m", "0.2m", "0.3m", "0.4m", "0.5m", "0.6m", "0.7m", "0.8m", "0.9m", "1.0m", "1.1m", "1.2m", "1.3m", "1.4m", "1.5m", "1.6m", "1.7m", "1.8m", "1.9m", "2.0m"},
+ values = {0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0},
+ texts = {"0m", "0.2m", "0.4m", "0.6m", "0.8m", "1.0m", "1.2m", "1.4m", "1.6m", "1.8m", "2.0m", "2.2m", "2.4m", "2.6m", "2.8m", "3.0m", "3.2m", "3.4m", "3.6m", "3.8m", "4.0m"},
default = 1,
current = 1,
text = "gui_ad_shovelWidth",
@@ -580,9 +579,8 @@ AutoDrive.settings.shovelWidth = {
translate = false,
isVehicleSpecific = true
}
-]]
---[[
+
AutoDrive.settings.shovelHeight = {
values = {
-0.5,
@@ -697,7 +695,6 @@ AutoDrive.settings.shovelHeight = {
translate = false,
isVehicleSpecific = true
}
-]]
AutoDrive.settings.useFolders = {
values = {false, true},
@@ -938,6 +935,28 @@ AutoDrive.settings.autoTrailerCover = {
isVehicleSpecific = true
}
+AutoDrive.settings.showTipOfTheDay = {
+ values = {false, true},
+ texts = {"gui_ad_no", "gui_ad_yes"},
+ default = 2,
+ current = 2,
+ text = "gui_ad_showTipOfTheDay",
+ tooltip = "gui_ad_showTipOfTheDay_tooltip",
+ translate = true,
+ isVehicleSpecific = false
+}
+
+AutoDrive.settings.useForwardTurningManoeuvre = {
+ values = {false, true},
+ texts = {"gui_ad_no", "gui_ad_yes"},
+ default = 2,
+ current = 2,
+ text = "gui_ad_useForwardTurningManoeuvre",
+ tooltip = "gui_ad_useForwardTurningManoeuvre_tooltip",
+ translate = true,
+ isVehicleSpecific = true
+}
+
function AutoDrive.getSetting(settingName, vehicle)
if AutoDrive.settings[settingName] ~= nil then
local setting = AutoDrive.settings[settingName]
diff --git a/FS19_AutoDrive/scripts/Specialization.lua b/FS19_AutoDrive/scripts/Specialization.lua
index 9ccd4001..9658b7bb 100644
--- a/FS19_AutoDrive/scripts/Specialization.lua
+++ b/FS19_AutoDrive/scripts/Specialization.lua
@@ -532,7 +532,10 @@ function AutoDrive:onDrawEditorMode()
local x = point.x
local y = point.y
local z = point.z
- if AutoDrive.isInExtendedEditorMode() then
+ local isSubPrio = ADGraphManager:getIsPointSubPrio(point.id)
+ local isSubPrioMarker = ADGraphManager:getIsPointSubPrioMarker(point.id)
+
+ if AutoDrive.isInExtendedEditorMode() and not isSubPrioMarker then
arrowPosition = DrawingManager.arrows.position.middle
if AutoDrive.enableSphrere == true then
if AutoDrive.mouseIsAtPos(point, 0.01) then
@@ -585,21 +588,35 @@ function AutoDrive:onDrawEditorMode()
table.insert(outPointsSeen, neighbor)
local target = ADGraphManager:getWayPointById(neighbor)
if target ~= nil then
- --check if outgoing connection is a dual way connection
- local nWp = ADGraphManager:getWayPointById(neighbor)
- if point.incoming == nil or table.contains(point.incoming, neighbor) then
- --draw dual way line
- DrawingManager:addLineTask(x, y, z, nWp.x, nWp.y, nWp.z, 0, 0, 1)
- else
- --draw line with direction markers (arrow)
- if (nWp.incoming == nil or table.contains(nWp.incoming, point.id)) then
- -- one way line
- DrawingManager:addLineTask(x, y, z, nWp.x, nWp.y, nWp.z, 0, 1, 0)
- DrawingManager:addArrowTask(x, y, z, nWp.x, nWp.y, nWp.z, arrowPosition, 0, 1, 0)
+ local isSubPrioMarker = ADGraphManager:getIsPointSubPrioMarker(neighbor)
+ if not isSubPrioMarker then
+ --check if outgoing connection is a dual way connection
+ local nWp = ADGraphManager:getWayPointById(neighbor)
+ if point.incoming == nil or table.contains(point.incoming, neighbor) then
+ --draw dual way line
+ if point.id > nWp.id then
+ if isSubPrio then
+ DrawingManager:addLineTask(x, y, z, nWp.x, nWp.y, nWp.z, 0.389, 0.177, 0)
+ else
+ DrawingManager:addLineTask(x, y, z, nWp.x, nWp.y, nWp.z, 0, 0, 1)
+ end
+ end
else
- -- reverse way line
- DrawingManager:addLineTask(x, y, z, nWp.x, nWp.y, nWp.z, 0.0, 0.569, 0.835)
- DrawingManager:addArrowTask(x, y, z, nWp.x, nWp.y, nWp.z, arrowPosition, 0.0, 0.569, 0.835)
+ --draw line with direction markers (arrow)
+ if (nWp.incoming == nil or table.contains(nWp.incoming, point.id)) then
+ -- one way line
+ if isSubPrio then
+ DrawingManager:addLineTask(x, y, z, nWp.x, nWp.y, nWp.z, 1, 0.531, 0.14)
+ DrawingManager:addArrowTask(x, y, z, nWp.x, nWp.y, nWp.z, arrowPosition, 1, 0.531, 0.14)
+ else
+ DrawingManager:addLineTask(x, y, z, nWp.x, nWp.y, nWp.z, 0, 1, 0)
+ DrawingManager:addArrowTask(x, y, z, nWp.x, nWp.y, nWp.z, arrowPosition, 0, 1, 0)
+ end
+ else
+ -- reverse way line
+ DrawingManager:addLineTask(x, y, z, nWp.x, nWp.y, nWp.z, 0.0, 0.569, 0.835)
+ DrawingManager:addArrowTask(x, y, z, nWp.x, nWp.y, nWp.z, arrowPosition, 0.0, 0.569, 0.835)
+ end
end
end
end
@@ -607,7 +624,7 @@ function AutoDrive:onDrawEditorMode()
end
--just a quick way to highlight single (forgotten) points with no connections
- if (#point.out == 0) and (#point.incoming == 0) and not table.contains(outPointsSeen, point.id) then
+ if (#point.out == 0) and (#point.incoming == 0) and not table.contains(outPointsSeen, point.id) and not isSubPrioMarker then
y = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, x, 1, z) + 0.5
DrawingManager:addCrossTask(x, y, z)
end
diff --git a/FS19_AutoDrive/scripts/Tasks/CatchCombinePipeTask.lua b/FS19_AutoDrive/scripts/Tasks/CatchCombinePipeTask.lua
index 3ecab798..45829a52 100644
--- a/FS19_AutoDrive/scripts/Tasks/CatchCombinePipeTask.lua
+++ b/FS19_AutoDrive/scripts/Tasks/CatchCombinePipeTask.lua
@@ -21,6 +21,7 @@ function CatchCombinePipeTask:new(vehicle, combine)
o.reverseTimer = AutoDriveTON:new()
o.waitForCheckTimer = AutoDriveTON:new()
o.waitForCheckTimer.elapsedTime = 4000
+ o.taskType = "CatchCombinePipeTask"
return o
end
@@ -112,7 +113,7 @@ function CatchCombinePipeTask:update(dt)
self.reverseTimer:timer(false)
self.state = CatchCombinePipeTask.STATE_DELAY_PATHPLANNING
else
- self.vehicle.ad.specialDrivingModule:driveReverse(dt, 15, 1)
+ self.vehicle.ad.specialDrivingModule:driveReverse(dt, 15, 1, true)
end
end
end
diff --git a/FS19_AutoDrive/scripts/Tasks/ClearCropTask.lua b/FS19_AutoDrive/scripts/Tasks/ClearCropTask.lua
index d928e160..190a8b13 100644
--- a/FS19_AutoDrive/scripts/Tasks/ClearCropTask.lua
+++ b/FS19_AutoDrive/scripts/Tasks/ClearCropTask.lua
@@ -82,7 +82,7 @@ function ClearCropTask:update(dt)
elseif distanceToReversStart > 10 then
self.state = ClearCropTask.STATE_CLEARING
else
- self.vehicle.ad.specialDrivingModule:driveReverse(dt, 15, 1)
+ self.vehicle.ad.specialDrivingModule:driveReverse(dt, 15, 1, true)
end
end
end
diff --git a/FS19_AutoDrive/scripts/Tasks/EmptyHarvesterTask.lua b/FS19_AutoDrive/scripts/Tasks/EmptyHarvesterTask.lua
index 0b0c6943..957e1571 100644
--- a/FS19_AutoDrive/scripts/Tasks/EmptyHarvesterTask.lua
+++ b/FS19_AutoDrive/scripts/Tasks/EmptyHarvesterTask.lua
@@ -133,7 +133,7 @@ function EmptyHarvesterTask:update(dt)
AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_COMBINEINFO, "EmptyHarvesterTask:update - next: EmptyHarvesterTask.STATE_WAITING")
self.state = EmptyHarvesterTask.STATE_WAITING
else
- self.vehicle.ad.specialDrivingModule:driveReverse(dt, 5, 1)
+ self.vehicle.ad.specialDrivingModule:driveReverse(dt, 5, 1, true)
end
elseif self.state == EmptyHarvesterTask.STATE_WAITING then
self.waitTimer:timer(true, EmptyHarvesterTask.REVERSE_TIME, dt)
diff --git a/FS19_AutoDrive/scripts/Tasks/FollowCombineTask.lua b/FS19_AutoDrive/scripts/Tasks/FollowCombineTask.lua
index 8bf938c1..c2a17f37 100644
--- a/FS19_AutoDrive/scripts/Tasks/FollowCombineTask.lua
+++ b/FS19_AutoDrive/scripts/Tasks/FollowCombineTask.lua
@@ -4,6 +4,8 @@ FollowCombineTask.STATE_CHASING = 1
FollowCombineTask.STATE_WAIT_FOR_TURN = 2
FollowCombineTask.STATE_REVERSING = 3
FollowCombineTask.STATE_WAIT_FOR_PASS_BY = 4
+FollowCombineTask.STATE_CIRCLING_PATHPLANNING = 5
+FollowCombineTask.STATE_CIRCLING = 6
FollowCombineTask.MAX_REVERSE_DISTANCE = 25
FollowCombineTask.MIN_COMBINE_DISTANCE = 25
@@ -78,7 +80,7 @@ function FollowCombineTask:update(dt)
-- Also for small fields, there is often no purpose in chasing so far behind the combine as it will already start a turn soon
self:finished()
end
- if (not self.combine:getIsBufferCombine()) and self.combineFillPercent > 90 then
+ if (not self.combine:getIsBufferCombine()) and self.combineFillPercent > 90 and AutoDrive.getDistanceBetween(self.vehicle, self.combine) > self.MIN_COMBINE_DISTANCE then
-- Stop chasing and wait for a normal unload call while standing
self:finished()
end
@@ -95,11 +97,34 @@ function FollowCombineTask:update(dt)
if (AutoDrive.combineIsTurning(self.combine) and (self.angleToCombineHeading > 60 or not self.combine:getIsBufferCombine() or not self.combine.ad.sensors.frontSensorFruit:pollInfo())) or self.angleWrongTimer.elapsedTime > 10000 then
--print("Waiting for turn now - 1- t:" .. AutoDrive.boolToString(AutoDrive.combineIsTurning(self.combine)) .. " anglewrongtimer: " .. AutoDrive.boolToString(self.angleWrongTimer.elapsedTime > 10000))
AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_COMBINEINFO, "Detected combine turning: " .. AutoDrive.boolToString(AutoDrive.combineIsTurning(self.combine)) .. " - waiting for turn to be finished next")
- self.state = FollowCombineTask.STATE_WAIT_FOR_TURN
- self.angleWrongTimer:timer(false)
- --self.stuckTimer:timer(false)
+
+ local tryCircling = true
+ if self.chaseSide ~= nil and self.chaseSide ~= AutoDrive.CHASEPOS_REAR then
+ if self.chaseSide == AutoDrive.CHASEPOS_LEFT then
+ if self.vehicle.ad.sensors.frontSensorLong:pollInfo(true, 0.8, 1.5) or self.vehicle.ad.sensors.leftFrontSensor:pollInfo(true, 3, 3) then
+ tryCircling = false
+ end
+ else
+ if self.vehicle.ad.sensors.frontSensorLong:pollInfo(true, 0.8, 1.5) or self.vehicle.ad.sensors.rightFrontSensor:pollInfo(true, 3, 3) then
+ tryCircling = false
+ end
+ end
+ else
+ tryCircling = false
+ end
+
+ AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_COMBINEINFO, "Circling tests: tryCircling " .. tostring(tryCircling) .. " frontSensor: " .. tostring(self.vehicle.ad.sensors.frontSensorLong:pollInfo(true, 0.8, 1.5)) .. " leftFront: " .. tostring(self.vehicle.ad.sensors.leftFrontSensor:pollInfo(true, 3, 3)) .. " rightFront: " .. tostring(self.vehicle.ad.sensors.rightFrontSensor:pollInfo(true, 3, 3)))
+
+ if tryCircling and AutoDrive.getSetting("useForwardTurningManoeuvre", self.vehicle) and not self.combine:getIsBufferCombine() then
+ self:startPathPlanningForCircling()
+ self.state = FollowCombineTask.STATE_CIRCLING_PATHPLANNING
+ else
+ self.state = FollowCombineTask.STATE_WAIT_FOR_TURN
+ self.angleWrongTimer:timer(false)
+ --self.stuckTimer:timer(false)
+ end
elseif ((self.combine.lastSpeedReal * self.combine.movingDirection) <= -0.00005) then
- self.vehicle.ad.specialDrivingModule:driveReverse(dt, self.combine.lastSpeedReal * 3600 * 1.3, 1)
+ self.vehicle.ad.specialDrivingModule:driveReverse(dt, self.combine.lastSpeedReal * 3600 * 1.3, 1, true)
else
self:followChasePoint(dt)
end
@@ -119,7 +144,7 @@ function FollowCombineTask:update(dt)
self.vehicle.ad.specialDrivingModule:stopVehicle()
self.vehicle.ad.specialDrivingModule:update(dt)
end
- if not AutoDrive.combineIsTurning(self.combine) and (self.combine.ad.sensors.frontSensorFruit:pollInfo() or self.waitForTurnTimer.elapsedTime > 15000) then
+ if not AutoDrive.combineIsTurning(self.combine) and ((self.combine.ad.sensors.frontSensorFruit:pollInfo() and (self.combine:getIsBufferCombine() or self.combine.ad.driveForwardTimer.elapsedTime > 8000) ) or self.waitForTurnTimer.elapsedTime > 15000) then
if (self.angleToCombineHeading + self.angleToCombine) < 180 and
self.vehicle.ad.modes[AutoDrive.MODE_UNLOAD]:isUnloaderOnCorrectSide(self.chaseSide) then
AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_COMBINEINFO, "combine turn finished - Heading looks good - start chasing again")
@@ -166,11 +191,48 @@ function FollowCombineTask:update(dt)
AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_COMBINEINFO, "stuck in reversing - set finished")
self:finished()
else
- self.vehicle.ad.specialDrivingModule:driveReverse(dt, 15, 1)
+ self.vehicle.ad.specialDrivingModule:driveReverse(dt, 15, 1, true)
+ end
+ elseif self.state == FollowCombineTask.STATE_CIRCLING_PATHPLANNING then
+ if self.vehicle.ad.pathFinderModule:hasFinished() then
+ self.wayPoints = self.vehicle.ad.pathFinderModule:getPath()
+ if self.wayPoints == nil or #self.wayPoints == 0 then
+ AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_COMBINEINFO, "Could not find a path for circling - reversing next")
+ local x, y, z = getWorldTranslation(self.vehicle.components[1].node)
+ self.reverseStartLocation = {x = x, y = y, z = z}
+ self.state = FollowCombineTask.STATE_REVERSING
+ else
+ self.vehicle.ad.drivePathModule:setWayPoints(self.wayPoints)
+ self.state = FollowCombineTask.STATE_CIRCLING
+ end
+ else
+ self.vehicle.ad.pathFinderModule:update(dt)
+ self.vehicle.ad.specialDrivingModule:stopVehicle()
+ self.vehicle.ad.specialDrivingModule:update(dt)
+ end
+ elseif self.state == FollowCombineTask.STATE_CIRCLING then
+ if self.vehicle.ad.drivePathModule:isTargetReached() then
+ self:finished()
+ else
+ self.vehicle.ad.drivePathModule:update(dt)
end
end
end
+function FollowCombineTask:startPathPlanningForCircling()
+ local sideOffset = 0
+ if self.chaseSide ~= nil and self.chaseSide == AutoDrive.CHASEPOS_LEFT then
+ sideOffset = 8
+ elseif self.chaseSide ~= nil and self.chaseSide == AutoDrive.CHASEPOS_RIGHT then
+ sideOffset = -8
+ end
+
+ local targetPos = AutoDrive.createWayPointRelativeToVehicle(self.vehicle, sideOffset, 0)
+ local directionX, directionY, directionZ = localToWorld(self.vehicle.components[1].node, 0, 0, 0)
+ local direction = {x = directionX - targetPos.x, z = directionZ - targetPos.z}
+ self.vehicle.ad.pathFinderModule:startPathPlanningTo(targetPos, direction)
+end
+
function FollowCombineTask:updateStates()
local x, y, z = getWorldTranslation(self.vehicle.components[1].node)
local cx, cy, cz = getWorldTranslation(self.combine.components[1].node)
@@ -200,7 +262,7 @@ function FollowCombineTask:updateStates()
end
function FollowCombineTask:reverse(dt)
- self.vehicle.ad.specialDrivingModule:driveReverse(dt, 15, 1)
+ self.vehicle.ad.specialDrivingModule:driveReverse(dt, 15, 1, true)
end
function FollowCombineTask:followChasePoint(dt)
diff --git a/FS19_AutoDrive/scripts/Tasks/UnloadAtDestinationTask.lua b/FS19_AutoDrive/scripts/Tasks/UnloadAtDestinationTask.lua
index 51d56e0d..c54a89c6 100644
--- a/FS19_AutoDrive/scripts/Tasks/UnloadAtDestinationTask.lua
+++ b/FS19_AutoDrive/scripts/Tasks/UnloadAtDestinationTask.lua
@@ -66,46 +66,46 @@ function UnloadAtDestinationTask:update(dt)
self.vehicle.ad.trailerModule:update(dt)
end
if self.vehicle.ad.drivePathModule:isTargetReached() then
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isTargetReached")
+ --AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isTargetReached")
if not self.vehicle.ad.trailerModule:isActiveAtTrigger() then
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isTargetReached isActiveAtTrigger")
+ --AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isTargetReached isActiveAtTrigger")
local trailers, _ = AutoDrive.getTrailersOf(self.vehicle, false)
AutoDrive.setTrailerCoverOpen(self.vehicle, trailers, true)
local fillLevel, _ = AutoDrive.getFillLevelAndCapacityOfAll(trailers)
if fillLevel <= 1 or self.isContinued or (((AutoDrive.getSetting("rotateTargets", self.vehicle) == AutoDrive.RT_ONLYDELIVER or AutoDrive.getSetting("rotateTargets", self.vehicle) == AutoDrive.RT_PICKUPANDDELIVER) and AutoDrive.getSetting("useFolders")) and (not ((self.vehicle.ad.drivePathModule:getIsReversing() and self.vehicle.ad.trailerModule:getBunkerTrigger() ~= nil)))) then
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_VEHICLEINFO, "[AD] UnloadAtDestinationTask:update fillLevel <= 1")
+ --AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_VEHICLEINFO, "[AD] UnloadAtDestinationTask:update fillLevel <= 1")
AutoDrive.setAugerPipeOpen(trailers, false)
self:finished()
else
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update Wait at unload point until unloaded somehow")
+ -- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update Wait at unload point until unloaded somehow")
-- Wait at unload point until unloaded somehow
self.vehicle.ad.specialDrivingModule:stopVehicle()
self.vehicle.ad.specialDrivingModule:update(dt)
end
else
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isTargetReached NOT isActiveAtTrigger")
+ --AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isTargetReached NOT isActiveAtTrigger")
if self.vehicle.ad.trailerModule:isUnloadingToBunkerSilo() then
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isTargetReached NOT isActiveAtTrigger isUnloadingToBunkerSilo")
+ --AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isTargetReached NOT isActiveAtTrigger isUnloadingToBunkerSilo")
self.vehicle.ad.drivePathModule:update(dt)
else
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isTargetReached NOT isActiveAtTrigger stopVehicle")
+ --AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isTargetReached NOT isActiveAtTrigger stopVehicle")
self.vehicle.ad.specialDrivingModule:stopVehicle()
self.vehicle.ad.specialDrivingModule:update(dt)
end
end
else
if self.vehicle.ad.trailerModule:isActiveAtTrigger() then
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isActiveAtTrigger")
+ --AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isActiveAtTrigger")
if self.vehicle.ad.trailerModule:isUnloadingToBunkerSilo() then
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isActiveAtTrigger isUnloadingToBunkerSilo")
+ --AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isActiveAtTrigger isUnloadingToBunkerSilo")
self.vehicle.ad.drivePathModule:update(dt)
else
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isActiveAtTrigger stopVehicle")
+ --AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isActiveAtTrigger stopVehicle")
self.vehicle.ad.specialDrivingModule:stopVehicle()
self.vehicle.ad.specialDrivingModule:update(dt)
end
else
- AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isActiveAtTrigger drivePathModule:update")
+ --AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_PATHINFO, "[AD] UnloadAtDestinationTask:update isActiveAtTrigger drivePathModule:update")
self.vehicle.ad.drivePathModule:update(dt)
end
end
diff --git a/FS19_AutoDrive/scripts/Tasks/UnloadBGATask.lua b/FS19_AutoDrive/scripts/Tasks/UnloadBGATask.lua
index 1d2103c0..bf85810c 100644
--- a/FS19_AutoDrive/scripts/Tasks/UnloadBGATask.lua
+++ b/FS19_AutoDrive/scripts/Tasks/UnloadBGATask.lua
@@ -65,6 +65,10 @@ function UnloadBGATask:update(dt)
self.isActive = true
end
+ if self.targetUnloadTrigger == nil then
+ self.targetUnloadTrigger = self:getTargetUnloadPoint()
+ end
+
self:getCurrentStates()
if self.state == self.STATE_INIT then
@@ -117,6 +121,10 @@ function UnloadBGATask:update(dt)
self.lastState = self.state
self.lastAction = self.action
+
+ if AutoDrive.getDebugChannelIsSet(AutoDrive.DC_BGA_MODE) then
+ self:drawDebug()
+ end
end
function UnloadBGATask:abort()
@@ -131,6 +139,15 @@ function UnloadBGATask:getCurrentStates()
self.trailerFillLevel, self.trailerLeftCapacity = AutoDrive.getFillLevelAndCapacityOf(self.targetTrailer)
self.bunkerFillLevel = 10000 --self:getBunkerFillLevel();
+ self.targetUnloadTriggerFree = false
+ if self.targetUnloadTrigger ~= nil then
+ local fillType = self.shovel:getFillUnitFillType(1)
+ if fillType > 0 then
+ self.targetUnloadTriggerFree = self.targetUnloadTrigger:getFillUnitFreeCapacity(1, fillType) >= self.shovelFilledCapacity
+ --print("targetUnloadTriggerFree: " .. tostring(targetUnloadTriggerFree) .. " capacity: " .. self.targetUnloadTrigger:getFillUnitFreeCapacity(1, fillType))
+ end
+ end
+
if not self:checkCurrentTrailerStillValid() then
self.targetTrailer = nil
self.targetDriver = nil
@@ -145,8 +162,11 @@ function UnloadBGATask:checkIfPossibleToRestart()
if self.targetBunker == nil then
self.targetBunker = self:getTargetBunker()
end
+ if self.targetUnloadTrigger == nil then
+ self.targetUnloadTrigger = self:getTargetUnloadPoint()
+ end
- if self.targetTrailer ~= nil and self.trailerLeftCapacity >= 1 and self.targetBunker ~= nil and self.bunkerFillLevel > 0 then
+ if (self.targetUnloadTrigger and self.targetUnloadTriggerFree) or (not self.targetUnloadTrigger and self.targetTrailer ~= nil and self.trailerLeftCapacity >= 1 and self.targetBunker ~= nil and self.bunkerFillLevel > 0) then
return true
end
end
@@ -160,6 +180,7 @@ function UnloadBGATask:getShovelFillLevel()
fillLevel = fillLevel + self.shovel:getFillUnitFillLevel(shovelNode.fillUnitIndex)
capacity = capacity + self.shovel:getFillUnitCapacity(shovelNode.fillUnitIndex)
fillUnitCount = fillUnitCount + 1
+ --print("Detected shovelNode width: " .. shovelNode.width)
if self.shovelWidthTool == nil or self.shovelWidthTool < shovelNode.width then
self.shovelWidthTool = shovelNode.width
end
@@ -173,6 +194,7 @@ function UnloadBGATask:getShovelFillLevel()
if self.targetBunker ~= nil then
self:determineHighestShovelOffset()
end
+ self.shovelFilledCapacity = fillLevel
return fillLevel / capacity
end
@@ -186,6 +208,8 @@ function UnloadBGATask:initializeBGA()
self.shovelTarget = self.SHOVELSTATE_LOW
self.targetTrailer, self.targetDriver = self:findCloseTrailer()
self.targetBunker = self:getTargetBunker()
+ self.targetUnloadTrigger = self:getTargetUnloadPoint()
+ self.unloadToTrigger = self.vehicle.ad.stateModule:getBunkerUnloadTypeIsTrigger()
self.inShovelRangeTimer = AutoDriveTON:new()
self.strategyActiveTimer = AutoDriveTON:new()
@@ -196,6 +220,7 @@ function UnloadBGATask:initializeBGA()
self.shovelOffsetCounter = 0
self.highestShovelOffsetCounter = 0
self.reachedPreTargetLoadPoint = false
+ self.shovelInBunkerArea = false
if self.shovel == nil then
self:getVehicleShovel()
@@ -263,7 +288,7 @@ function UnloadBGATask:handleInitAxis(dt)
self.initAxisStartTranslation = translationObject.curTrans[translationObject.translationAxis]
translationTarget = (translationObject.transMax - translationObject.transMin) / 2 + translationObject.transMin
if math.abs(translationTarget - translationObject.curTrans[translationObject.translationAxis]) <= 0.1 then
- translationTarget = translationTarget.transMin
+ translationTarget = translationObject.transMin
end
self.armExtender.translationTarget = translationTarget
self.initAxisState = self.INITAXIS_STATE_EXTENDER_STEER
@@ -413,9 +438,9 @@ end
function UnloadBGATask:checkForUnloadCondition() --can unload if shovel is filled and trailer available
if self.action == self.ACTION_DRIVETOSILO_COMMON_POINT then
- return self.shovelFillLevel > 0 and self.targetTrailer ~= nil and self.trailerLeftCapacity > 1
+ return self.shovelFillLevel > 0 and ((self.targetTrailer ~= nil and self.trailerLeftCapacity > 1) or (self.unloadToTrigger and self.targetUnloadTriggerFree))
elseif self.action == self.ACTION_LOAD then
- return self.shovelFillLevel >= 0.98 and self.targetTrailer ~= nil and self.trailerLeftCapacity > 1
+ return self.shovelFillLevel >= 0.98 and ((self.targetTrailer ~= nil and self.trailerLeftCapacity > 1) or (self.unloadToTrigger and self.targetUnloadTriggerFree))
end
return false
end
@@ -425,7 +450,7 @@ function UnloadBGATask:checkForStopLoading() --stop loading when shovel is fille
end
function UnloadBGATask:checkForIdleCondition() --idle if shovel filled and no trailer available to fill;
- if self.shovelFillLevel >= 0.98 and (self.targetTrailer ~= nil or self.trailerLeftCapacity <= 1) or self.targetTrailer == nil then
+ if self.shovelFillLevel >= 0.98 and ((((self.targetTrailer ~= nil or self.trailerLeftCapacity <= 1) or self.targetTrailer == nil) and not self.self.unloadToTrigger) or (self.unloadToTrigger and not self.targetUnloadTriggerFree)) then
return true
end
return false
@@ -447,6 +472,9 @@ function UnloadBGATask:handleShovel(dt)
self.shovelState = self.shovelTarget
end
else
+ if self.shovelState == self.shovelTarget and self.shovelInBunkerArea ~= self:isShovelInBunkerArea() then
+ self.shovelState = self.SHOVELSTATE_UNKNOWN
+ end
if self.shovelState ~= self.shovelTarget then
if not self.shovelActiveTimer:done() then
self:moveShovelToTarget(self.shovelTarget, dt)
@@ -465,12 +493,20 @@ function UnloadBGATask:handleShovel(dt)
end
end
end
+
+ if self.shovel ~= nil then
+ self.shovelInBunkerArea = self:isShovelInBunkerArea()
+ end
end
function UnloadBGATask:moveShovelToTarget(_, dt)
if self.shovelTarget == self.SHOVELSTATE_LOADING then
- self.shovelTargetHeight = -0.20 + AutoDrive.getSetting("shovelHeight", self.vehicle)
- self.shovelTargetAngle = self.shovelRotator.horizontalPosition + self.shovelRotator.moveUpSign * 0.07
+ if self:isShovelInBunkerArea() then
+ self.shovelTargetHeight = -0.25 + AutoDrive.getSetting("shovelHeight", self.vehicle)
+ else
+ self.shovelTargetHeight = -0.20 + AutoDrive.getSetting("shovelHeight", self.vehicle)
+ end
+ self.shovelTargetAngle = self.shovelRotator.horizontalPosition + self.shovelRotator.moveUpSign * 0.11
if self.armExtender ~= nil then
self.shovelTargetExtension = self.armExtender.transMin
end
@@ -560,9 +596,9 @@ function UnloadBGATask:moveShovelToTarget(_, dt)
end
function UnloadBGATask:checkIfAllWheelsOnGround()
- local spec = self.vehicle.spec_wheels
+ local spec = self.vehicle.spec_wheels
for _, wheel in pairs(spec.wheels) do
- if wheel.contact ~= Wheels.WHEEL_GROUND_CONTACT then
+ if not wheel.hasGroundContact then
return false
end
end
@@ -624,12 +660,11 @@ function UnloadBGATask:findCloseTrailer()
local closest = nil
local closestTrailer = nil
for _, vehicle in pairs(g_currentMission.vehicles) do
- if vehicle ~= self.vehicle and self:vehicleHasTrailersAttached(self.vehicle) and vehicle.ad ~= nil then
- if AutoDrive.getDistanceBetween(vehicle, self.vehicle) < closestDistance and vehicle.ad.noMovementTimer:done() and (not vehicle.ad.trailerModule:isActiveAtTrigger()) then
+ if vehicle ~= self.vehicle and self:vehicleHasTrailersAttached(vehicle) and vehicle.ad ~= nil then
+ if AutoDrive.getDistanceBetween(vehicle, self.vehicle) < closestDistance and vehicle.ad.noMovementTimer:timer(vehicle.lastSpeedReal < 0.0004, 3000, 16) and (not vehicle.ad.trailerModule:isActiveAtTrigger()) then
local _, trailers = self:vehicleHasTrailersAttached(vehicle)
for _, trailer in pairs(trailers) do
if trailer ~= nil then
- --local trailerFillLevel = 0
local trailerLeftCapacity = 0
_, trailerLeftCapacity = AutoDrive.getFillLevelAndCapacityOf(trailer)
if trailerLeftCapacity >= 10 then
@@ -648,15 +683,8 @@ function UnloadBGATask:findCloseTrailer()
return
end
-function UnloadBGATask:getDistanceBetween(vehicleOne, vehicleTwo)
- local x1, _, z1 = getWorldTranslation(vehicleOne.components[1].node)
- local x2, _, z2 = getWorldTranslation(vehicleTwo.components[1].node)
-
- return math.sqrt(math.pow(x2 - x1, 2) + math.pow(z2 - z1, 2))
-end
-
-function UnloadBGATask:vehicleHasTrailersAttached()
- local trailers, _ = AutoDrive.getTrailersOf(self.vehicle)
+function UnloadBGATask:vehicleHasTrailersAttached(vehicle)
+ local trailers, _ = AutoDrive.getTrailersOf(vehicle)
local tipTrailers = {}
if trailers ~= nil then
for _, trailer in pairs(trailers) do
@@ -705,6 +733,28 @@ function UnloadBGATask:getTargetBunker()
return closest
end
+function UnloadBGATask:getTargetUnloadPoint()
+ local x, _, z = getWorldTranslation(self.vehicle.components[1].node)
+ local closestDistance = math.huge
+ local closest = nil
+ if self.shovel ~= nil and self.shovel.getFillUnitFillType ~= nil then
+ local fillType = self.shovel:getFillUnitFillType(1)
+ if fillType ~= nil then
+ for _, trigger in pairs(ADTriggerManager.getAllTriggersForFillType(fillType)) do
+ local triggerX, _, triggerZ = ADTriggerManager.getTriggerPos(trigger)
+ local distance = math.sqrt(math.pow(triggerX - x, 2) + math.pow(triggerZ - z, 2))
+ if distance < closestDistance and distance < 1000 then
+ closest = trigger
+ closestDistance = distance
+ end
+ end
+ end
+ --print("Found closest trigger with distance: " .. closestDistance)
+ end
+
+ return closest
+end
+
function UnloadBGATask:getTargetBunkerLoadingSide()
if self.targetBunker == nil then
self:getTargetBunker()
@@ -718,11 +768,11 @@ function UnloadBGATask:getTargetBunkerLoadingSide()
end
local trigger = self.targetBunker
- -- vecW
+ -- vecW
local x1, z1 = trigger.bunkerSiloArea.sx, trigger.bunkerSiloArea.sz -- 1 ---- 2
local x2, z2 = trigger.bunkerSiloArea.wx, trigger.bunkerSiloArea.wz -- vecH | ---- |
local x3, z3 = trigger.bunkerSiloArea.hx, trigger.bunkerSiloArea.hz -- | ---- |
- local x4, z4 = x2 + (x3 - x1), z2 + (z3 - z1) -- 3 ---- 4 4 = 2 + vecH
+ local x4, z4 = x2 + (x3 - x1), z2 + (z3 - z1) -- 3 ---- 4 4 = 2 + vecH
local x, _, z = getWorldTranslation(self.vehicle.components[1].node)
@@ -804,13 +854,32 @@ function UnloadBGATask:isAlmostInBunkerSiloArea(distanceToCheck)
return AutoDrive.boxesIntersect(boundingBox, otherBoundingBox)
end
+function UnloadBGATask:isShovelInBunkerArea()
+ if self.shovel ~= nil and self.targetBunker ~= nil then
+ local x, y, z = getWorldTranslation(self.shovel.spec_shovel.shovelDischargeInfo.node)
+ local tx, _, tz = localToWorld(self.shovel.spec_shovel.shovelDischargeInfo.node, 0, 0, -1)
+ --local tx, _, tz = x, y, z + 1
+ if self.targetBunker ~= nil and self.targetBunker.bunkerSiloArea ~= nil then
+ local x1, z1 = self.targetBunker.bunkerSiloArea.sx, self.targetBunker.bunkerSiloArea.sz
+ local x2, z2 = self.targetBunker.bunkerSiloArea.wx, self.targetBunker.bunkerSiloArea.wz
+ local x3, z3 = self.targetBunker.bunkerSiloArea.hx, self.targetBunker.bunkerSiloArea.hz
+ if MathUtil.hasRectangleLineIntersection2D(x1, z1, x2 - x1, z2 - z1, x3 - x1, z3 - z1, x, z, tx - x, tz - z) then
+ return true
+ end
+ end
+ end
+
+ return false
+end
+
function UnloadBGATask:driveToSiloCommonPoint(dt)
if (self.checkedCurrentRow == nil or self.checkedCurrentRow == false) then
self:setShovelOffsetToNonEmptyRow()
self.checkedCurrentRow = true
end
- self.targetPoint = self:getTargetForShovelOffset(14)
+ --self.targetPoint = self:getTargetForShovelOffset(14)
+ self.targetPoint = self:getTargetForShovelOffset(AutoDrive.getVehicleLeadingEdge(vehicle) + 6)
local angleToSilo = self:getAngleToTarget() -- in +/- 180°
if self.storedDirection == nil then
@@ -844,7 +913,8 @@ function UnloadBGATask:driveToSiloClosePoint(dt)
end
function UnloadBGATask:driveToSiloReversePoint(dt)
- self.targetPoint = self:getTargetForShovelOffset(18)
+ --self.targetPoint = self:getTargetForShovelOffset(18)
+ self.targetPoint = self:getTargetForShovelOffset(AutoDrive.getVehicleLeadingEdge(vehicle) + 6)
self.driveStrategy = self:getDriveStrategyToTarget(false, dt)
self.shovelTarget = self.SHOVELSTATE_LOW
@@ -976,6 +1046,13 @@ function UnloadBGATask:getDriveStrategyToTrailerInit(dt)
return self:getDriveStrategyByAngle(angleToTrailer, true, dt)
end
+function UnloadBGATask:getDriveStrategyToTrigger(dt)
+ local triggerX, _, triggerZ = ADTriggerManager.getTriggerPos(self.targetUnloadTrigger)
+ self.targetPoint = {x = triggerX, z = triggerZ}
+
+ return self:getDriveStrategyByAngle(self:getAngleToTarget(), true, dt)
+end
+
function UnloadBGATask:getDriveStrategyToTrailer(dt)
local xT, _, zT = getWorldTranslation(self.targetTrailer.components[1].node)
@@ -1082,6 +1159,10 @@ function UnloadBGATask:getPointXInFrontAndYOffsetFromBunker(inFront, offset, fro
local normalizedVec = {x = (p2.x - p1.x) / (math.abs(p2.x - p1.x) + math.abs(p2.z - p1.z)), z = (p2.z - p1.z) / (math.abs(p2.x - p1.x) + math.abs(p2.z - p1.z))}
--get ortho for 'inFront' parameter
local ortho = {x = -normalizedVec.z, z = normalizedVec.x}
+ local factor = math.sqrt(math.pow(ortho.x, 2) + math.pow(ortho.z, 2))
+ ortho.x = ortho.x / factor
+ ortho.z = ortho.z / factor
+
--get shovel offset correct position on silo line
local targetPoint = {x = p1.x + normalizedVec.x * offset, z = p1.z + normalizedVec.z * offset}
@@ -1108,7 +1189,8 @@ function UnloadBGATask:reverseFromBGALoad(dt)
self.shovelTarget = self.SHOVELSTATE_LOW
self.targetPoint = self:getTargetForShovelOffset(200)
- self.targetPointClose = self:getTargetForShovelOffset(16)
+ --self.targetPointClose = self:getTargetForShovelOffset(16)
+ self.targetPointClose = self:getTargetForShovelOffset(AutoDrive.getVehicleLeadingEdge(vehicle) + 10)
local finalSpeed = 30
local acc = 1
@@ -1133,7 +1215,7 @@ function UnloadBGATask:reverseFromBGALoad(dt)
end
function UnloadBGATask:driveToBGAUnloadInit(dt)
- if self.targetTrailer == nil then
+ if self.targetTrailer == nil and not self.unloadToTrigger then
self:getVehicleToPause()
self.vehicle.ad.specialDrivingModule:stopVehicle()
self.vehicle.ad.specialDrivingModule:update(dt)
@@ -1142,8 +1224,11 @@ function UnloadBGATask:driveToBGAUnloadInit(dt)
self.shovelTarget = self.SHOVELSTATE_BEFORE_UNLOAD
- self.driveStrategy = self:getDriveStrategyToTrailerInit(dt)
-
+ if not self.unloadToTrigger then
+ self.driveStrategy = self:getDriveStrategyToTrailerInit(dt)
+ else
+ self.driveStrategy = self:getDriveStrategyToTrigger(dt)
+ end
self:handleDriveStrategy(dt)
local x, _, z = getWorldTranslation(self.vehicle.components[1].node)
@@ -1151,7 +1236,7 @@ function UnloadBGATask:driveToBGAUnloadInit(dt)
if math.sqrt(math.pow(self.targetPoint.x - x, 2) + math.pow(self.targetPoint.z - z, 2)) <= 4 then
self.action = self.ACTION_DRIVETOUNLOAD
end
- if self.targetTrailer == nil or (self.trailerLeftCapacity <= 0.001) then
+ if ((self.targetTrailer == nil or (self.trailerLeftCapacity <= 0.001)) and not self.unloadToTrigger) or ((self.unloadToTrigger and not self.targetUnloadTriggerFree)) then
self.action = self.ACTION_REVERSEFROMUNLOAD
self.shovelTarget = self.SHOVELSTATE_BEFORE_UNLOAD
self.shovel:setDischargeState(Dischargeable.DISCHARGE_STATE_OFF, true)
@@ -1159,14 +1244,14 @@ function UnloadBGATask:driveToBGAUnloadInit(dt)
end
function UnloadBGATask:driveToBGAUnload(dt)
- if self.targetTrailer == nil then
+ if self.targetTrailer == nil and not self.unloadToTrigger then
AutoDriveMessageEvent.sendMessageOrNotification(self.vehicle, ADMessagesManager.messageTypes.ERROR, "$l10n_AD_Driver_of; %s $l10n_AD_No_Trailer;", 5000, self.vehicle.stateModule:getName())
self:getVehicleToPause()
self.vehicle.ad.specialDrivingModule:stopVehicle()
self.vehicle.ad.specialDrivingModule:update(dt)
return
end
- if AutoDrive.getDistanceBetween(self.vehicle, self.targetTrailer) <= 10 then
+ if self.unloadToTrigger or (AutoDrive.getDistanceBetween(self.vehicle, self.targetTrailer) <= 10) then
self.shovelTarget = self.SHOVELSTATE_BEFORE_UNLOAD
elseif AutoDrive.getDistanceBetween(self.vehicle, self.targetTrailer) > 20 then
self.shovelTarget = self.SHOVELSTATE_TRANSPORT
@@ -1177,14 +1262,18 @@ function UnloadBGATask:driveToBGAUnload(dt)
return
end
- self.driveStrategy = self:getDriveStrategyToTrailer(dt)
+ if not self.unloadToTrigger then
+ self.driveStrategy = self:getDriveStrategyToTrailer(dt)
+ else
+ self.driveStrategy = self:getDriveStrategyToTrigger(dt)
+ end
self:handleDriveStrategy(dt)
if self.inShovelRangeTimer:timer(self:getShovelInTrailerRange(), 350, dt) then
self.action = self.ACTION_UNLOAD
end
- if self.targetTrailer == nil or (self.trailerLeftCapacity <= 0.1) then
+ if (not self.unloadToTrigger and (self.targetTrailer == nil or (self.trailerLeftCapacity <= 0.1))) or (self.unloadToTrigger and not self.targetUnloadTriggerFree) then
self.action = self.ACTION_REVERSEFROMUNLOAD
self.shovelTarget = self.SHOVELSTATE_BEFORE_UNLOAD
self.shovel:setDischargeState(Dischargeable.DISCHARGE_STATE_OFF, true)
@@ -1204,7 +1293,7 @@ function UnloadBGATask:handleBGAUnload(dt)
self.action = self.ACTION_REVERSEFROMUNLOAD
self.shovel:setDischargeState(Dischargeable.DISCHARGE_STATE_OFF, true)
end
- if self.targetTrailer == nil or (self.trailerLeftCapacity <= 0.1) then
+ if (not self.unloadToTrigger and (self.targetTrailer == nil or (self.trailerLeftCapacity <= 0.1))) or (self.unloadToTrigger and not self.targetUnloadTriggerFree) then
self.action = self.ACTION_REVERSEFROMUNLOAD
self.shovelState = self.SHOVELSTATE_UNLOAD
self.shovelTarget = self.SHOVELSTATE_BEFORE_UNLOAD
@@ -1244,12 +1333,12 @@ function UnloadBGATask:reverseFromBGAUnload(dt)
else
self.shovelTarget = self.SHOVELSTATE_BEFORE_UNLOAD
end
- end
- if MathUtil.vector2Length(x - self.shovelUnloadPosition.x, z - self.shovelUnloadPosition.z) >= 8 then
- self.shovel:setDischargeState(Dischargeable.DISCHARGE_STATE_OFF, true)
- self.action = self.ACTION_DRIVETOSILO_COMMON_POINT
- end
+ if MathUtil.vector2Length(x - self.shovelUnloadPosition.x, z - self.shovelUnloadPosition.z) >= 8 then
+ self.shovel:setDischargeState(Dischargeable.DISCHARGE_STATE_OFF, true)
+ self.action = self.ACTION_DRIVETOSILO_COMMON_POINT
+ end
+ end
end
function UnloadBGATask:getVehicleToPause()
@@ -1261,7 +1350,7 @@ function UnloadBGATask:getShovelInTrailerRange()
if dischargeNode ~= nil then
local dischargeTarget = dischargeNode.dischargeObject
if dischargeTarget ~= nil then
- local result = self.shovel:getDischargeState() == Dischargeable.DISCHARGE_STATE_OBJECT and dischargeTarget == self.targetTrailer
+ local result = self.shovel:getDischargeState() == Dischargeable.DISCHARGE_STATE_OBJECT --and dischargeTarget == self.targetTrailer
return result
end
end
@@ -1378,4 +1467,34 @@ function UnloadBGATask:driveInDirection(dt, steeringAngleLimit, acceleration, sl
AIVehicleUtil.driveInDirection(self.vehicle, dt, steeringAngleLimit, acceleration, slowAcceleration, slowAngleLimit, allowedToDrive, moveForwards, lx, lz, maxSpeed, slowDownFactor)
end
+end
+
+function UnloadBGATask:drawDebug()
+ local node = self.vehicle.components[1].node
+ local x, y, z = getWorldTranslation(node)
+
+ -- line to trailer or trigger
+ if self.targetUnloadTrigger ~= nil then
+ local triggerX, triggerY, triggerZ = ADTriggerManager.getTriggerPos(self.targetUnloadTrigger)
+ ADDrawingManager:addLineTask(x, y, z, triggerX, triggerY, triggerZ, 0, 1, 0)
+ end
+ -- line to current target
+ if self.targetPoint ~= nil then
+ ADDrawingManager:addLineTask(x, y, z, self.targetPoint.x, y, self.targetPoint.z, 1, 0, 0)
+ end
+
+ -- Bunker size
+ if self.targetBunker ~= nil then
+ local trigger = self.targetBunker
+ local x1, z1 = trigger.bunkerSiloArea.sx, trigger.bunkerSiloArea.sz
+ local x2, z2 = trigger.bunkerSiloArea.wx, trigger.bunkerSiloArea.wz
+ local x3, z3 = trigger.bunkerSiloArea.hx, trigger.bunkerSiloArea.hz
+
+ local corners = {{x = x1, z = z1}, {x = x2, z = z2}, {x = x3, z = z3}, {x = x2 + (x3 - x1), z = z2 + (z3 - z1)}}
+
+ ADDrawingManager:addLineTask(corners[1].x, y, corners[1].z, corners[2].x, y, corners[2].z, 1, 0, 0)
+ ADDrawingManager:addLineTask(corners[2].x, y, corners[2].z, corners[3].x, y, corners[3].z, 1, 0, 0)
+ ADDrawingManager:addLineTask(corners[3].x, y, corners[3].z, corners[4].x, y, corners[4].z, 1, 0, 0)
+ ADDrawingManager:addLineTask(corners[4].x, y, corners[4].z, corners[1].x, y, corners[1].z, 1, 0, 0)
+ end
end
\ No newline at end of file
diff --git a/FS19_AutoDrive/scripts/TelemetryExport.lua b/FS19_AutoDrive/scripts/TelemetryExport.lua
index f9ae3277..e74fe90f 100644
--- a/FS19_AutoDrive/scripts/TelemetryExport.lua
+++ b/FS19_AutoDrive/scripts/TelemetryExport.lua
@@ -19,7 +19,7 @@ function AutoDrive.initTelemetry()
g_logManager:info("[AD] AutoDrive.xmlFileName_telemetry " .. AutoDrive.xmlFileName_telemetry)
- AutoDrive:registerDestinationListener(AutoDrive, AutoDrive.triggerStaticOutput)
+ --AutoDrive:registerDestinationListener(AutoDrive, AutoDrive.triggerStaticOutput)
end
function AutoDrive.triggerStaticOutput()
diff --git a/FS19_AutoDrive/scripts/TipOfTheDayHandler.lua b/FS19_AutoDrive/scripts/TipOfTheDayHandler.lua
new file mode 100644
index 00000000..3e5c4931
--- /dev/null
+++ b/FS19_AutoDrive/scripts/TipOfTheDayHandler.lua
@@ -0,0 +1,80 @@
+AutoDrive.tipOfTheDay = {}
+AutoDrive.tipOfTheDay.Entries = {}
+AutoDrive.tipOfTheDay.Entries[1] = {}
+AutoDrive.tipOfTheDay.Entries[1].imageFile = g_autoDriveTipOfTheDayUIFilename
+AutoDrive.tipOfTheDay.Entries[1].imageUV = {0, 0, 128, 128}
+AutoDrive.tipOfTheDay.Entries[1].imageSize = {128, 128}
+AutoDrive.tipOfTheDay.Entries[1].text = "ad_totd_01_text"
+AutoDrive.tipOfTheDay.Entries[1].titletext = "ad_totd_01_title"
+
+AutoDrive.tipOfTheDay.Entries[2] = {}
+AutoDrive.tipOfTheDay.Entries[2].imageFile = g_autoDriveTipOfTheDayUIFilename
+AutoDrive.tipOfTheDay.Entries[2].imageUV = {0, 0, 128, 512}
+AutoDrive.tipOfTheDay.Entries[2].imageSize = {128, 512}
+AutoDrive.tipOfTheDay.Entries[2].text = "ad_totd_02_text"
+AutoDrive.tipOfTheDay.Entries[2].titletext = "ad_totd_02_title"
+
+AutoDrive.tipOfTheDay.Entries[3] = {}
+AutoDrive.tipOfTheDay.Entries[3].imageFile = g_autoDriveTipOfTheDayUIFilename
+AutoDrive.tipOfTheDay.Entries[3].imageUV = {128, 0, 128, 128}
+AutoDrive.tipOfTheDay.Entries[3].imageSize = {128, 128}
+AutoDrive.tipOfTheDay.Entries[3].text = "ad_totd_03_text"
+AutoDrive.tipOfTheDay.Entries[3].titletext = "ad_totd_03_title"
+
+AutoDrive.tipOfTheDay.Entries[4] = {}
+AutoDrive.tipOfTheDay.Entries[4].imageFile = g_autoDriveTipOfTheDayUIFilename
+AutoDrive.tipOfTheDay.Entries[4].imageUV = {128, 128, 128, 128}
+AutoDrive.tipOfTheDay.Entries[4].imageSize = {128, 128}
+AutoDrive.tipOfTheDay.Entries[4].text = "ad_totd_04_text"
+AutoDrive.tipOfTheDay.Entries[4].titletext = "ad_totd_04_title"
+
+AutoDrive.tipOfTheDay.currentTipId = 1
+AutoDrive.tipOfTheDay.highestTipId = 1
+AutoDrive.tipOfTheDay.displayedYet = true
+
+AutoDrive.tipOfTheDay.delayTime = 500
+
+function AutoDrive.initTipOfTheDay()
+
+end
+
+function AutoDrive.handleTipOfTheDay(dt)
+ if not (g_server ~= nil and g_client ~= nil) then
+ return
+ end
+
+ if AutoDrive.tipOfTheDay.delayTime > 0 then
+ AutoDrive.tipOfTheDay.delayTime = AutoDrive.tipOfTheDay.delayTime - dt
+ return
+ end
+
+ if (AutoDrive.getSetting("showTipOfTheDay") or AutoDrive.tipOfTheDay.Entries[AutoDrive.tipOfTheDay.highestTipId + 1] ~= nil) and not AutoDrive.tipOfTheDay.displayedYet then
+ -- The idea is to still diplay new tips that arrived with a new AutoDrive version
+ if not AutoDrive.getSetting("showTipOfTheDay") then
+ AutoDrive.tipOfTheDay.currentTipId = AutoDrive.tipOfTheDay.highestTipId + 1
+ end
+
+ if not AutoDrive.gui.ADTipOfTheDayGUI.isOpen then
+ g_gui:showGui("ADTipOfTheDayGui")
+ AutoDrive.tipOfTheDay.displayedYet = true
+ end
+ end
+end
+
+function AutoDrive.showNextTipOfTheDay()
+ AutoDrive.tipOfTheDay.currentTipId = AutoDrive.tipOfTheDay.currentTipId + 1
+ if AutoDrive.tipOfTheDay.Entries[AutoDrive.tipOfTheDay.currentTipId] == nil then
+ AutoDrive.tipOfTheDay.currentTipId = 1
+ end
+
+ AutoDrive.tipOfTheDay.highestTipId = math.max(AutoDrive.tipOfTheDay.highestTipId, AutoDrive.tipOfTheDay.currentTipId)
+ AutoDrive.tipOfTheDay.currentTipOfTheDay = AutoDrive.tipOfTheDay.Entries[AutoDrive.tipOfTheDay.currentTipId]
+end
+
+function AutoDrive.toggleTipOfTheDay()
+ if AutoDrive.getSetting("showTipOfTheDay") then
+ AutoDrive.setSettingState("showTipOfTheDay", 1)
+ else
+ AutoDrive.setSettingState("showTipOfTheDay", 2)
+ end
+end
\ No newline at end of file
diff --git a/FS19_AutoDrive/scripts/Utils/AutoDriveUtilFuncs.lua b/FS19_AutoDrive/scripts/Utils/AutoDriveUtilFuncs.lua
index 7f8713d3..dcdf8029 100644
--- a/FS19_AutoDrive/scripts/Utils/AutoDriveUtilFuncs.lua
+++ b/FS19_AutoDrive/scripts/Utils/AutoDriveUtilFuncs.lua
@@ -290,6 +290,41 @@ function AutoDrive.getSelectedWorkTool(vehicle)
return selectedWorkTool
end
+function AutoDrive.getVehicleLeadingEdge(vehicle)
+ local leadingEdge = 0
+ local implements = AutoDrive.getAllImplements(vehicle)
+ if implements ~= nil then
+ for i = 1, #implements do
+ local implement = implements[i]
+ if implement ~= nil and implement.object ~= nil then
+ local implementX, implementY, implementZ = getWorldTranslation(implement.object.components[1].node)
+ local _, _, diffZ = worldToLocal(vehicle.components[1].node, implementX, implementY, implementZ)
+ if diffZ > 0 and implement.object.sizeLength ~= nil then
+ leadingEdge = math.max(leadingEdge, diffZ + (implement.object.sizeLength / 2) - (vehicle.sizeLength / 2))
+ end
+ end
+ end
+ end
+ return leadingEdge
+end
+
+function AutoDrive.getAllImplements(vehicle)
+ if vehicle ~= nil and vehicle.getAttachedImplements and #vehicle:getAttachedImplements() > 0 then
+ local allImp = {}
+ -- Credits to Tardis from FS17
+ local function addAllAttached(obj)
+ for _, imp in pairs(obj:getAttachedImplements()) do
+ addAllAttached(imp.object)
+ table.insert(allImp, imp)
+ end
+ end
+
+ addAllAttached(vehicle)
+
+ return allImp
+ end
+end
+
-- set or delete park destination for selected vehicle, tool from user input action, client mode!
function AutoDrive.setActualParkDestination(vehicle)
local actualParkDestination = -1
@@ -338,7 +373,6 @@ function AutoDrive.setActualParkDestination(vehicle)
-- formatting
messageText = string.format(messageText, messageArg)
ADMessagesManager:addMessage(ADMessagesManager.messageTypes.INFO, messageText, 5000)
-
end
end
end
diff --git a/FS19_AutoDrive/scripts/Utils/CombineUtil.lua b/FS19_AutoDrive/scripts/Utils/CombineUtil.lua
index b0db77db..31d10edf 100644
--- a/FS19_AutoDrive/scripts/Utils/CombineUtil.lua
+++ b/FS19_AutoDrive/scripts/Utils/CombineUtil.lua
@@ -126,7 +126,7 @@ function AutoDrive.isPipeOut(combine)
end
function AutoDrive.isSugarcaneHarvester(combine)
- local isSugarCaneHarvester = true
+ local isSugarCaneHarvester = combine.typeName == "combineCutterFruitPreparer"
if combine.getAttachedImplements ~= nil then
for _, implement in pairs(combine:getAttachedImplements()) do
if implement ~= nil and implement ~= combine and (implement.object == nil or implement.object ~= combine) then
diff --git a/FS19_AutoDrive/scripts/XML.lua b/FS19_AutoDrive/scripts/XML.lua
index 15c10dd3..8eb23816 100644
--- a/FS19_AutoDrive/scripts/XML.lua
+++ b/FS19_AutoDrive/scripts/XML.lua
@@ -249,6 +249,10 @@ function AutoDrive.readFromXML(xmlFile)
-- if debug channel for road network was saved and loaded, the debug wayPoints shall be created
ADGraphManager:createDebugMarkers()
+
+ AutoDrive.tipOfTheDay.currentTipId = getXMLInt(xmlFile, "AutoDrive.lastTipOfTheDay") or 1
+ AutoDrive.tipOfTheDay.highestTipId = getXMLInt(xmlFile, "AutoDrive.highestTipOfTheDay") or 1
+
g_logManager:info("[AD] AutoDrive.readFromXML waypoints: %s", tostring(ADGraphManager:getWayPointsCount()))
g_logManager:info("[AD] AutoDrive.readFromXML markers: %s", tostring(#ADGraphManager:getMapMarkers()))
g_logManager:info("[AD] AutoDrive.readFromXML groups: %s", tostring(table.count(ADGraphManager:getGroups())))
@@ -325,6 +329,10 @@ function AutoDrive.saveToXML(xmlFile)
markerIndex = markerIndex + 1
end
end
+
+ setXMLInt(xmlFile, "AutoDrive.lastTipOfTheDay", AutoDrive.tipOfTheDay.currentTipId)
+ setXMLInt(xmlFile, "AutoDrive.highestTipOfTheDay", AutoDrive.tipOfTheDay.highestTipId)
+
saveXMLFile(xmlFile)
if g_client == nil then
g_logManager:info("[AD] AutoDrive.saveToXML waypoints: %s", tostring(ADGraphManager:getWayPointsCount()))
diff --git a/FS19_AutoDrive/textures/input_bunkerUnloadType_1.dds b/FS19_AutoDrive/textures/input_bunkerUnloadType_1.dds
new file mode 100644
index 00000000..e2d29d0a
Binary files /dev/null and b/FS19_AutoDrive/textures/input_bunkerUnloadType_1.dds differ
diff --git a/FS19_AutoDrive/textures/input_bunkerUnloadType_2.dds b/FS19_AutoDrive/textures/input_bunkerUnloadType_2.dds
new file mode 100644
index 00000000..5a3deb25
Binary files /dev/null and b/FS19_AutoDrive/textures/input_bunkerUnloadType_2.dds differ
diff --git a/FS19_AutoDrive/textures/input_record_4.dds b/FS19_AutoDrive/textures/input_record_4.dds
new file mode 100644
index 00000000..4df5d3ea
Binary files /dev/null and b/FS19_AutoDrive/textures/input_record_4.dds differ
diff --git a/FS19_AutoDrive/textures/input_record_5.dds b/FS19_AutoDrive/textures/input_record_5.dds
new file mode 100644
index 00000000..92cf879d
Binary files /dev/null and b/FS19_AutoDrive/textures/input_record_5.dds differ
diff --git a/FS19_AutoDrive/textures/tipOfTheDay_icons.dds b/FS19_AutoDrive/textures/tipOfTheDay_icons.dds
new file mode 100644
index 00000000..caa6c55d
Binary files /dev/null and b/FS19_AutoDrive/textures/tipOfTheDay_icons.dds differ
diff --git a/FS19_AutoDrive/translations/translation_br.xml b/FS19_AutoDrive/translations/translation_br.xml
index 86470187..9bda6ea5 100644
--- a/FS19_AutoDrive/translations/translation_br.xml
+++ b/FS19_AutoDrive/translations/translation_br.xml
@@ -32,8 +32,10 @@
+
+
@@ -186,6 +188,8 @@
+
+
@@ -219,6 +223,7 @@
+
@@ -325,6 +330,46 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_cz.xml b/FS19_AutoDrive/translations/translation_cz.xml
index 9e77dfe8..f89e7abe 100644
--- a/FS19_AutoDrive/translations/translation_cz.xml
+++ b/FS19_AutoDrive/translations/translation_cz.xml
@@ -32,8 +32,10 @@
+
+
@@ -186,6 +188,8 @@
+
+
@@ -219,6 +223,7 @@
+
@@ -325,6 +330,46 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_de.xml b/FS19_AutoDrive/translations/translation_de.xml
index af533338..63936b5d 100644
--- a/FS19_AutoDrive/translations/translation_de.xml
+++ b/FS19_AutoDrive/translations/translation_de.xml
@@ -32,9 +32,11 @@
+
-
+
+
@@ -186,6 +188,8 @@
+
+
@@ -219,6 +223,7 @@
+
@@ -320,11 +325,48 @@
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+ 1. Eine ganz normale Strecke (grün). Hier können die Fahrzeuge nur entlang der Pfeilrichtung fahren. Eine Aufnahme kann durch einen Klick mit der linken Maustaste auf den 'Aufzeichnen' Knopf im Hud gestartet werden.
+
+ 2. Beidseitig befahrbare Strecken (blau). Hier können Fahrzeuge aus beiden Richtungen kommend entlang fahren. Eine Aufnahme kann durch einen Klick mit entweder der mittleren oder der rechten Maustaste auf den 'Aufzeichnen' Knopf im Hud gestartet werden.
+
+ 3. Rückwärtsstrecken (hellblau) - Hier können die Fahrzeuge entlang der Pfeilrichtung zurücksetzen. Diese Pfade können während einer normalen Aufzeichnung erstellt werden indem man einfach rückwärts fährt.
+
+ 4. Nebenstrecken - Diese werden bei der Pfadplanung nach Möglichkeit vermieden und nur benutzt wenn das Ziel auf diesem Weg liegt oder ein Umweg unverhältnismäßig lang wäre. Eine Aufnahme kann durch Mausrad - Hoch über dem 'Aufzeichnen' Knopf gestartet werden." />
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_en.xml b/FS19_AutoDrive/translations/translation_en.xml
index c6d3ec7d..81d1b7da 100644
--- a/FS19_AutoDrive/translations/translation_en.xml
+++ b/FS19_AutoDrive/translations/translation_en.xml
@@ -32,9 +32,11 @@
+
-
+
+
@@ -186,6 +188,8 @@
+
+
@@ -219,6 +223,7 @@
+
@@ -325,6 +330,47 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_es.xml b/FS19_AutoDrive/translations/translation_es.xml
index e31749e2..e64607c2 100644
--- a/FS19_AutoDrive/translations/translation_es.xml
+++ b/FS19_AutoDrive/translations/translation_es.xml
@@ -32,8 +32,10 @@
+
+
@@ -184,6 +186,8 @@
+
+
@@ -217,6 +221,7 @@
+
@@ -323,6 +328,46 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_fr.xml b/FS19_AutoDrive/translations/translation_fr.xml
index b344ec0d..e0938d11 100644
--- a/FS19_AutoDrive/translations/translation_fr.xml
+++ b/FS19_AutoDrive/translations/translation_fr.xml
@@ -32,8 +32,10 @@
+
+
@@ -172,6 +174,8 @@
+
+
@@ -221,6 +225,7 @@
+
@@ -327,7 +332,46 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_hu.xml b/FS19_AutoDrive/translations/translation_hu.xml
index 8d60e5f2..4ffa8971 100644
--- a/FS19_AutoDrive/translations/translation_hu.xml
+++ b/FS19_AutoDrive/translations/translation_hu.xml
@@ -33,7 +33,9 @@
+
+
@@ -184,6 +186,8 @@
+
+
@@ -213,6 +217,7 @@
+
@@ -304,6 +309,46 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_it.xml b/FS19_AutoDrive/translations/translation_it.xml
index ed1f5309..3c1cd8bb 100644
--- a/FS19_AutoDrive/translations/translation_it.xml
+++ b/FS19_AutoDrive/translations/translation_it.xml
@@ -32,8 +32,10 @@
+
+
@@ -186,6 +188,8 @@
+
+
@@ -219,6 +223,7 @@
+
@@ -321,10 +326,44 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_nl.xml b/FS19_AutoDrive/translations/translation_nl.xml
index 2e7666fa..cf77e324 100644
--- a/FS19_AutoDrive/translations/translation_nl.xml
+++ b/FS19_AutoDrive/translations/translation_nl.xml
@@ -32,8 +32,10 @@
+
+
@@ -186,6 +188,8 @@
+
+
@@ -219,6 +223,7 @@
+
@@ -321,10 +326,44 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_pl.xml b/FS19_AutoDrive/translations/translation_pl.xml
index 44a93689..96c3b883 100644
--- a/FS19_AutoDrive/translations/translation_pl.xml
+++ b/FS19_AutoDrive/translations/translation_pl.xml
@@ -32,8 +32,10 @@
+
+
@@ -184,6 +186,8 @@
+
+
@@ -219,6 +223,7 @@
+
@@ -320,10 +325,44 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_pt.xml b/FS19_AutoDrive/translations/translation_pt.xml
index 770daf0a..88a4b514 100644
--- a/FS19_AutoDrive/translations/translation_pt.xml
+++ b/FS19_AutoDrive/translations/translation_pt.xml
@@ -32,8 +32,10 @@
+
+
@@ -186,6 +188,8 @@
+
+
@@ -223,6 +227,7 @@
+
@@ -324,10 +329,44 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_ru.xml b/FS19_AutoDrive/translations/translation_ru.xml
index 3b3dce18..8704ea5e 100644
--- a/FS19_AutoDrive/translations/translation_ru.xml
+++ b/FS19_AutoDrive/translations/translation_ru.xml
@@ -32,8 +32,10 @@
+
+
@@ -186,6 +188,8 @@
+
+
@@ -219,6 +223,7 @@
+
@@ -321,10 +326,44 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_tr.xml b/FS19_AutoDrive/translations/translation_tr.xml
index c08fe327..43f135e5 100644
--- a/FS19_AutoDrive/translations/translation_tr.xml
+++ b/FS19_AutoDrive/translations/translation_tr.xml
@@ -32,8 +32,10 @@
+
+
@@ -47,7 +49,7 @@
-
+
@@ -184,6 +186,8 @@
+
+
@@ -217,6 +221,7 @@
+
@@ -323,7 +328,46 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+