diff --git a/FS19_AutoDrive/gui/setRmParkDestinationGUI.xml b/FS19_AutoDrive/gui/setRmParkDestinationGUI.xml
new file mode 100644
index 00000000..2ac889ed
--- /dev/null
+++ b/FS19_AutoDrive/gui/setRmParkDestinationGUI.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FS19_AutoDrive/register.lua b/FS19_AutoDrive/register.lua
index 82fee900..5b8bb7be 100644
--- a/FS19_AutoDrive/register.lua
+++ b/FS19_AutoDrive/register.lua
@@ -131,6 +131,7 @@ source(Utils.getFilename("scripts/Gui/ExperimentalFeaturesSettingsPage.lua", g_c
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))
+source(Utils.getFilename("scripts/Gui/SetRmParkDestinationGUI.lua", g_currentModDirectory))
AutoDriveRegister = {}
AutoDriveRegister.version = g_modManager:getModByName(g_currentModName).version
diff --git a/FS19_AutoDrive/scripts/Gui.lua b/FS19_AutoDrive/scripts/Gui.lua
index f00de2e2..18913c86 100644
--- a/FS19_AutoDrive/scripts/Gui.lua
+++ b/FS19_AutoDrive/scripts/Gui.lua
@@ -10,6 +10,7 @@ function AutoDrive:loadGUI()
AutoDrive.gui.ADRoutesManagerGui = ADRoutesManagerGui:new()
AutoDrive.gui.ADNotificationsHistoryGui = ADNotificationsHistoryGui:new()
AutoDrive.gui.ADTipOfTheDayGUI = ADTipOfTheDayGUI:new()
+ AutoDrive.gui.ADSetRmParkDestinationGui = ADSetRmParkDestinationGui: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)
@@ -18,6 +19,7 @@ function AutoDrive:loadGUI()
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)
+ g_gui:loadGui(AutoDrive.directory .. "gui/setRmParkDestinationGUI.xml", "ADSetRmParkDestinationGui", AutoDrive.gui.ADSetRmParkDestinationGui)
AutoDrive.gui.ADSettingsPage = ADSettingsPage:new()
AutoDrive.gui.ADUserSettingsPage = ADSettingsPage:new()
@@ -102,3 +104,9 @@ function AutoDrive.onOpenTipOfTheDay()
g_gui:showGui("ADTipOfTheDayGui")
end
end
+
+function AutoDrive.onOpenSetRmParkDestination()
+ if not AutoDrive.gui.ADSetRmParkDestinationGui.isOpen then
+ g_gui:showGui("ADSetRmParkDestinationGui")
+ end
+end
\ No newline at end of file
diff --git a/FS19_AutoDrive/scripts/Gui/SetRmParkDestinationGUI.lua b/FS19_AutoDrive/scripts/Gui/SetRmParkDestinationGUI.lua
new file mode 100644
index 00000000..513cdcc8
--- /dev/null
+++ b/FS19_AutoDrive/scripts/Gui/SetRmParkDestinationGUI.lua
@@ -0,0 +1,112 @@
+--
+-- AutoDrive Enter Driver Name GUI
+-- V1.1.0.0
+--
+-- @author Stephan Schlosser
+-- @date 09/06/2019
+
+ADSetRmParkDestinationGui = {}
+ADSetRmParkDestinationGui.CONTROLS = {"SelectedWorktoolText", "CurrentParkDestinationText", "Button_ok", "Button_cancel"}
+selectedWorkTool = nil
+vehicle = nil
+firstMarkerID = nil
+
+local ADSetRmParkDestinationGui_mt = Class(ADSetRmParkDestinationGui, ScreenElement)
+
+function ADSetRmParkDestinationGui:new(target)
+ local o = ScreenElement:new(target, ADSetRmParkDestinationGui_mt)
+ o.returnScreenName = ""
+ o.textInputElement = nil
+ o:registerControls(ADSetRmParkDestinationGui.CONTROLS)
+ return o
+end
+
+function ADSetRmParkDestinationGui:onOpen()
+ ADSetRmParkDestinationGui:superClass().onOpen(self)
+ self.CurrentParkDestinationText.blockTime = 0
+ self.CurrentParkDestinationText:onFocusActivate()
+ self.SelectedWorktoolText.blockTime = 0
+ self.SelectedWorktoolText:onFocusActivate()
+ local actualParkDestination = -1
+
+ vehicle = g_currentMission.controlledVehicle
+
+ if vehicle ~= nil and vehicle.ad ~= nil and vehicle.ad.stateModule ~= nil and vehicle.ad.stateModule:getFirstMarker() ~= nil then
+ firstMarkerID = vehicle.ad.stateModule:getFirstMarkerId()
+ if firstMarkerID > 0 then
+ local mapMarker = ADGraphManager:getMapMarkerById(firstMarkerID)
+ -- do not allow to set debug marker as park destination
+ if mapMarker ~= nil and mapMarker.isADDebug ~= true then
+ self.Button_ok:setText(g_i18n:getText("button_set") .. " " .. mapMarker.name)
+ selectedWorkTool = AutoDrive.getSelectedWorkTool(vehicle)
+
+ if selectedWorkTool == nil then
+ -- no attachment selected, so use the vehicle itself
+ selectedWorkTool = vehicle
+ end
+
+ if selectedWorkTool ~= nil then
+ self.Button_ok:setDisabled(false)
+ self.SelectedWorktoolText:setText(selectedWorkTool:getFullName())
+ if selectedWorkTool.advd.parkDestination ~= -1 then
+ self.CurrentParkDestinationText:setText(g_i18n:getText("gui_ad_currentParkDestinationText") .. ADGraphManager:getMapMarkerById(selectedWorkTool.advd.parkDestination).name)
+ self.Button_cancel:setDisabled(false)
+ else
+ self.CurrentParkDestinationText:setText(g_i18n:getText("gui_ad_noCurrentParkDestinationText"))
+ self.Button_cancel:setDisabled(true)
+ end
+ end
+ else
+ self.SelectedWorktoolText:setText(g_i18n:getText("gui_ad_targetEmpty"))
+ self.CurrentParkDestinationText:setText("")
+ self.Button_ok:setDisabled(true)
+ self.Button_cancel:setDisabled(true)
+ end
+ else
+ self.SelectedWorktoolText:setText(g_i18n:getText("gui_ad_targetEmpty"))
+ self.CurrentParkDestinationText:setText("")
+ self.Button_ok:setDisabled(true)
+ self.Button_cancel:setDisabled(true)
+ end
+ else
+ self.SelectedWorktoolText:setText(g_i18n:getText("gui_ad_targetEmpty"))
+ self.CurrentParkDestinationText:setText("")
+ self.Button_ok:setDisabled(true)
+ self.Button_cancel:setDisabled(true)
+ end
+end
+
+-- set destination
+function ADSetRmParkDestinationGui:onClickOk()
+ ADSetRmParkDestinationGui:superClass().onClickOk(self)
+ if g_currentMission.controlledVehicle ~= nil then
+ if vehicle.advd ~= nil then
+ vehicle.advd:setParkDestination(selectedWorkTool, firstMarkerID)
+ end
+ end
+ self:onClickBack()
+end
+
+-- rm destination
+function ADSetRmParkDestinationGui:onClickCancel()
+ if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle.ad ~= nil then
+ if vehicle.advd ~= nil then
+ vehicle.advd:setParkDestination(selectedWorkTool, -1)
+ end
+ end
+ self:onClickBack()
+end
+
+function ADSetRmParkDestinationGui:onClickBack()
+ ADSetRmParkDestinationGui:superClass().onClickBack(self)
+end
+
+function ADSetRmParkDestinationGui:onEnterPressed(_, isClick)
+ if not isClick then
+ self:onClickOk()
+ end
+end
+
+function ADSetRmParkDestinationGui:onEscPressed()
+ self:onClickBack()
+end
diff --git a/FS19_AutoDrive/scripts/Manager/InputManager.lua b/FS19_AutoDrive/scripts/Manager/InputManager.lua
index a7a32c53..1917dc83 100644
--- a/FS19_AutoDrive/scripts/Manager/InputManager.lua
+++ b/FS19_AutoDrive/scripts/Manager/InputManager.lua
@@ -279,7 +279,7 @@ function ADInputManager:input_decLoopCounter(vehicle)
end
function ADInputManager:input_setParkDestination(vehicle)
- AutoDrive.setActualParkDestination(vehicle)
+ AutoDrive.onOpenSetRmParkDestination(vehicle)
end
function ADInputManager:input_silomode(vehicle)
diff --git a/FS19_AutoDrive/scripts/Utils/AutoDriveUtilFuncs.lua b/FS19_AutoDrive/scripts/Utils/AutoDriveUtilFuncs.lua
index aa266158..3a466d11 100644
--- a/FS19_AutoDrive/scripts/Utils/AutoDriveUtilFuncs.lua
+++ b/FS19_AutoDrive/scripts/Utils/AutoDriveUtilFuncs.lua
@@ -1,107 +1,107 @@
-- positive X -> left
-- negative X -> right
function AutoDrive.createWayPointRelativeToVehicle(vehicle, offsetX, offsetZ)
- local wayPoint = {}
- wayPoint.x, wayPoint.y, wayPoint.z = localToWorld(vehicle.components[1].node, offsetX, 0, offsetZ)
- return wayPoint
+ local wayPoint = {}
+ wayPoint.x, wayPoint.y, wayPoint.z = localToWorld(vehicle.components[1].node, offsetX, 0, offsetZ)
+ return wayPoint
end
function AutoDrive.createWayPointRelativeToNode(node, offsetX, offsetZ)
- local wayPoint = {}
- wayPoint.x, wayPoint.y, wayPoint.z = localToWorld(node, offsetX, 0, offsetZ)
- return wayPoint
+ local wayPoint = {}
+ wayPoint.x, wayPoint.y, wayPoint.z = localToWorld(node, offsetX, 0, offsetZ)
+ return wayPoint
end
function AutoDrive.isTrailerInCrop(vehicle, enlargeDetectionArea)
- local widthFactor = 1
- if enlargeDetectionArea then
- widthFactor = 1.5
- end
-
- local trailers, trailerCount = AutoDrive.getTrailersOf(vehicle)
- local trailer = trailers[trailerCount]
- local inCrop = false
- if trailer ~= nil then
- if trailer.ad == nil then
- trailer.ad = {}
- end
- ADSensor:handleSensors(trailer, 0)
- inCrop = trailer.ad.sensors.centerSensorFruit:pollInfo(true, widthFactor)
- end
- return inCrop
+ local widthFactor = 1
+ if enlargeDetectionArea then
+ widthFactor = 1.5
+ end
+
+ local trailers, trailerCount = AutoDrive.getTrailersOf(vehicle)
+ local trailer = trailers[trailerCount]
+ local inCrop = false
+ if trailer ~= nil then
+ if trailer.ad == nil then
+ trailer.ad = {}
+ end
+ ADSensor:handleSensors(trailer, 0)
+ inCrop = trailer.ad.sensors.centerSensorFruit:pollInfo(true, widthFactor)
+ end
+ return inCrop
end
function AutoDrive.isVehicleOrTrailerInCrop(vehicle, enlargeDetectionArea)
- local widthFactor = 1
- if enlargeDetectionArea then
- widthFactor = 1.5
- end
+ local widthFactor = 1
+ if enlargeDetectionArea then
+ widthFactor = 1.5
+ end
- return AutoDrive.isTrailerInCrop(vehicle, enlargeDetectionArea) or vehicle.ad.sensors.centerSensorFruit:pollInfo(true, widthFactor)
+ return AutoDrive.isTrailerInCrop(vehicle, enlargeDetectionArea) or vehicle.ad.sensors.centerSensorFruit:pollInfo(true, widthFactor)
end
function AutoDrive:checkIsConnected(toCheck, other)
- local isAttachedToMe = false
- if toCheck == nil or other == nil then
- return false
- end
- if toCheck.getAttachedImplements == nil then
- return false
- end
-
- for _, impl in pairs(toCheck:getAttachedImplements()) do
- if impl.object ~= nil then
- if impl.object == other then
- return true
- end
-
- if impl.object.getAttachedImplements ~= nil then
- isAttachedToMe = isAttachedToMe or AutoDrive:checkIsConnected(impl.object, other)
- end
- end
- end
-
- return isAttachedToMe
+ local isAttachedToMe = false
+ if toCheck == nil or other == nil then
+ return false
+ end
+ if toCheck.getAttachedImplements == nil then
+ return false
+ end
+
+ for _, impl in pairs(toCheck:getAttachedImplements()) do
+ if impl.object ~= nil then
+ if impl.object == other then
+ return true
+ end
+
+ if impl.object.getAttachedImplements ~= nil then
+ isAttachedToMe = isAttachedToMe or AutoDrive:checkIsConnected(impl.object, other)
+ end
+ end
+ end
+
+ return isAttachedToMe
end
function AutoDrive.defineMinDistanceByVehicleType(vehicle)
- local min_distance = 1.8
- if
- vehicle.typeDesc == "combine" or vehicle.typeDesc == "harvester" or vehicle.typeName == "combineDrivable" or vehicle.typeName == "selfPropelledMower" or vehicle.typeName == "woodHarvester" or vehicle.typeName == "combineCutterFruitPreparer" or vehicle.typeName == "drivableMixerWagon" or
- vehicle.typeName == "cottonHarvester" or
- vehicle.typeName == "pdlc_claasPack.combineDrivableCrawlers"
- then
- min_distance = 6
- elseif vehicle.typeDesc == "telehandler" or vehicle.spec_crabSteering ~= nil then --If vehicle has 4 steering wheels like xerion or hardi self Propelled sprayer then also min_distance = 3;
- min_distance = 3
- elseif vehicle.typeDesc == "truck" then
- min_distance = 3
- end
- -- If vehicle is quadtrack then also min_distance = 6;
- if vehicle.spec_articulatedAxis ~= nil and vehicle.spec_articulatedAxis.rotSpeed ~= nil then
- min_distance = 6
- end
- return min_distance
+ local min_distance = 1.8
+ if
+ vehicle.typeDesc == "combine" or vehicle.typeDesc == "harvester" or vehicle.typeName == "combineDrivable" or vehicle.typeName == "selfPropelledMower" or vehicle.typeName == "woodHarvester" or vehicle.typeName == "combineCutterFruitPreparer" or vehicle.typeName == "drivableMixerWagon" or
+ vehicle.typeName == "cottonHarvester" or
+ vehicle.typeName == "pdlc_claasPack.combineDrivableCrawlers"
+ then
+ min_distance = 6
+ elseif vehicle.typeDesc == "telehandler" or vehicle.spec_crabSteering ~= nil then --If vehicle has 4 steering wheels like xerion or hardi self Propelled sprayer then also min_distance = 3;
+ min_distance = 3
+ elseif vehicle.typeDesc == "truck" then
+ min_distance = 3
+ end
+ -- If vehicle is quadtrack then also min_distance = 6;
+ if vehicle.spec_articulatedAxis ~= nil and vehicle.spec_articulatedAxis.rotSpeed ~= nil then
+ min_distance = 6
+ end
+ return min_distance
end
function AutoDrive.getVehicleMaxSpeed(vehicle)
- -- 255 is the max value to prevent errors with MP sync
- if vehicle ~= nil and vehicle.spec_motorized ~= nil and vehicle.spec_motorized.motor ~= nil then
- local motor = vehicle.spec_motorized.motor
- return math.min(motor:getMaximumForwardSpeed() * 3.6, 255)
- end
- return 255
+ -- 255 is the max value to prevent errors with MP sync
+ if vehicle ~= nil and vehicle.spec_motorized ~= nil and vehicle.spec_motorized.motor ~= nil then
+ local motor = vehicle.spec_motorized.motor
+ return math.min(motor:getMaximumForwardSpeed() * 3.6, 255)
+ end
+ return 255
end
function AutoDrive.renameDriver(vehicle, name, sendEvent)
- if name:len() > 1 and vehicle ~= nil and vehicle.ad ~= nil then
- if sendEvent == nil or sendEvent == true then
- -- Propagating driver rename all over the network
- AutoDriveRenameDriverEvent.sendEvent(vehicle, name)
- else
- vehicle.ad.stateModule:setName(name)
- end
- end
+ if name:len() > 1 and vehicle ~= nil and vehicle.ad ~= nil then
+ if sendEvent == nil or sendEvent == true then
+ -- Propagating driver rename all over the network
+ AutoDriveRenameDriverEvent.sendEvent(vehicle, name)
+ else
+ vehicle.ad.stateModule:setName(name)
+ end
+ end
end
-- return fillType to refuel or nil if no refuel required
@@ -125,267 +125,212 @@ function AutoDrive.getRequiredRefuel(vehicle, ignoreFillLevel)
end
function AutoDrive.combineIsTurning(combine)
- local cpIsTurning = combine.cp ~= nil and (combine.cp.isTurning or (combine.cp.turnStage ~= nil and combine.cp.turnStage > 0))
- local cpIsTurningTwo = combine.cp ~= nil and combine.cp.driver and (combine.cp.driver.turnIsDriving or (combine.cp.driver.fieldworkState ~= nil and combine.cp.driver.fieldworkState == combine.cp.driver.states.TURNING))
- local aiIsTurning = (combine.getAIIsTurning ~= nil and combine:getAIIsTurning() == true)
- --local combineSteering = combine.rotatedTime ~= nil and (math.deg(combine.rotatedTime) > 30)
- local combineIsTurning = cpIsTurning or cpIsTurningTwo or aiIsTurning --or combineSteering
-
- --local b = AutoDrive.boolToString
- --print("cpIsTurning: " .. b(cpIsTurning) .. " cpIsTurningTwo: " .. b(cpIsTurningTwo) .. " aiIsTurning: " .. b(aiIsTurning) .. " combineIsTurning: " .. b(combineIsTurning) .. " driveForwardDone: " .. b(combine.ad.driveForwardTimer:done()))
- if not combineIsTurning then --(combine.ad.driveForwardTimer:done() and (not combine:getIsBufferCombine()))
- return false
- end
- if combine.ad.noMovementTimer.elapsedTime > 3000 then
- return false
- end
- return true
+ local cpIsTurning = combine.cp ~= nil and (combine.cp.isTurning or (combine.cp.turnStage ~= nil and combine.cp.turnStage > 0))
+ local cpIsTurningTwo = combine.cp ~= nil and combine.cp.driver and (combine.cp.driver.turnIsDriving or (combine.cp.driver.fieldworkState ~= nil and combine.cp.driver.fieldworkState == combine.cp.driver.states.TURNING))
+ local aiIsTurning = (combine.getAIIsTurning ~= nil and combine:getAIIsTurning() == true)
+ --local combineSteering = combine.rotatedTime ~= nil and (math.deg(combine.rotatedTime) > 30)
+ local combineIsTurning = cpIsTurning or cpIsTurningTwo or aiIsTurning --or combineSteering
+
+ --local b = AutoDrive.boolToString
+ --print("cpIsTurning: " .. b(cpIsTurning) .. " cpIsTurningTwo: " .. b(cpIsTurningTwo) .. " aiIsTurning: " .. b(aiIsTurning) .. " combineIsTurning: " .. b(combineIsTurning) .. " driveForwardDone: " .. b(combine.ad.driveForwardTimer:done()))
+ if not combineIsTurning then --(combine.ad.driveForwardTimer:done() and (not combine:getIsBufferCombine()))
+ return false
+ end
+ if combine.ad.noMovementTimer.elapsedTime > 3000 then
+ return false
+ end
+ return true
end
function AutoDrive.pointIsBetweenTwoPoints(x, z, startX, startZ, endX, endZ)
- local xInside = (startX >= x and endX <= x) or (startX <= x and endX >= x)
- local zInside = (startZ >= z and endZ <= z) or (startZ <= z and endZ >= z)
- return xInside and zInside
+ local xInside = (startX >= x and endX <= x) or (startX <= x and endX >= x)
+ local zInside = (startZ >= z and endZ <= z) or (startZ <= z and endZ >= z)
+ return xInside and zInside
end
function AutoDrive.semanticVersionToValue(versionString)
- local codes = versionString:split(".")
- local value = 0
- if codes ~= nil then
- for i, code in ipairs(codes) do
- local subCodes = code:split("-")
- if subCodes ~= nil and subCodes[1] ~= nil then
- value = value * 10 + tonumber(subCodes[1])
- if subCodes[2] ~= nil then
- value = value + (tonumber(subCodes[2]) / 1000)
- end
- end
- end
- end
-
- return value
+ local codes = versionString:split(".")
+ local value = 0
+ if codes ~= nil then
+ for i, code in ipairs(codes) do
+ local subCodes = code:split("-")
+ if subCodes ~= nil and subCodes[1] ~= nil then
+ value = value * 10 + tonumber(subCodes[1])
+ if subCodes[2] ~= nil then
+ value = value + (tonumber(subCodes[2]) / 1000)
+ end
+ end
+ end
+ end
+
+ return value
end
function AutoDrive.mouseIsAtPos(position, radius)
- local x, y, _ = project(position.x, position.y + AutoDrive.drawHeight + AutoDrive.getSetting("lineHeight"), position.z)
+ local x, y, _ = project(position.x, position.y + AutoDrive.drawHeight + AutoDrive.getSetting("lineHeight"), position.z)
- if g_lastMousePosX < (x + radius) and g_lastMousePosX > (x - radius) then
- if g_lastMousePosY < (y + radius) and g_lastMousePosY > (y - radius) then
- return true
- end
- end
+ if g_lastMousePosX < (x + radius) and g_lastMousePosX > (x - radius) then
+ if g_lastMousePosY < (y + radius) and g_lastMousePosY > (y - radius) then
+ return true
+ end
+ end
- return false
+ return false
end
function AutoDrive.isVehicleInBunkerSiloArea(vehicle)
- if not (vehicle.ad.stateModule:getCurrentMode():shouldUnloadAtTrigger() == true) then
- -- check only for bunker silo if should unload to improve performance
- return false
- end
- for _, trigger in pairs(ADTriggerManager.getUnloadTriggers()) do
- local x, y, z = getWorldTranslation(vehicle.components[1].node)
- local tx, _, tz = x, y, z + 1
- if trigger ~= nil and trigger.bunkerSiloArea ~= nil then
- 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
- if MathUtil.hasRectangleLineIntersection2D(x1, z1, x2 - x1, z2 - z1, x3 - x1, z3 - z1, x, z, tx - x, tz - z) then
- return true
- end
-
- local trailers, trailerCount = AutoDrive.getTrailersOf(vehicle)
- if trailerCount > 0 then
- for _, trailer in pairs(trailers) do
- if AutoDrive.isTrailerInBunkerSiloArea(trailer, trigger) then
- return true
- end
- end
- end
- end
- end
-
- return false
+ if not (vehicle.ad.stateModule:getCurrentMode():shouldUnloadAtTrigger() == true) then
+ -- check only for bunker silo if should unload to improve performance
+ return false
+ end
+ for _, trigger in pairs(ADTriggerManager.getUnloadTriggers()) do
+ local x, y, z = getWorldTranslation(vehicle.components[1].node)
+ local tx, _, tz = x, y, z + 1
+ if trigger ~= nil and trigger.bunkerSiloArea ~= nil then
+ 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
+ if MathUtil.hasRectangleLineIntersection2D(x1, z1, x2 - x1, z2 - z1, x3 - x1, z3 - z1, x, z, tx - x, tz - z) then
+ return true
+ end
+
+ local trailers, trailerCount = AutoDrive.getTrailersOf(vehicle)
+ if trailerCount > 0 then
+ for _, trailer in pairs(trailers) do
+ if AutoDrive.isTrailerInBunkerSiloArea(trailer, trigger) then
+ return true
+ end
+ end
+ end
+ end
+ end
+
+ return false
end
function AutoDrive.isEditorModeEnabled()
- return (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_ON) or (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_EXTENDED)
+ return (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_ON) or (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_EXTENDED)
end
function AutoDrive.isEditorShowEnabled()
- return (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_SHOW)
+ return (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_SHOW)
end
function AutoDrive.isInExtendedEditorMode()
- return (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_EXTENDED)
+ return (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_EXTENDED)
end
function AutoDrive.getEditorMode()
- return (AutoDrive.getSetting("EditorMode"))
+ return (AutoDrive.getSetting("EditorMode"))
end
function AutoDrive.setEditorMode(editorMode)
- AutoDrive.setSettingState("EditorMode", editorMode)
+ AutoDrive.setSettingState("EditorMode", editorMode)
end
function AutoDrive.cycleEditMode()
- local vehicle = g_currentMission.controlledVehicle
- if g_client ~= nil then
+ local vehicle = g_currentMission.controlledVehicle
+ if g_client ~= nil then
- if vehicle ~= nil and vehicle.ad ~= nil then
- vehicle.ad.selectedNodeId = nil
- vehicle.ad.nodeToMoveId = nil
- vehicle.ad.hoveredNodeId = nil
+ if vehicle ~= nil and vehicle.ad ~= nil then
+ vehicle.ad.selectedNodeId = nil
+ vehicle.ad.nodeToMoveId = nil
+ vehicle.ad.hoveredNodeId = nil
vehicle.ad.newcreated = nil
- end
- if (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_OFF) then
- AutoDrive.setEditorMode(AutoDrive.EDITOR_EXTENDED)
- else
- AutoDrive.setEditorMode(AutoDrive.EDITOR_OFF)
- if vehicle ~= nil and vehicle.ad ~= nil and vehicle.ad.stateModule ~= nil then
- vehicle.ad.stateModule:disableCreationMode()
- end
- end
- end
+ end
+ if (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_OFF) then
+ AutoDrive.setEditorMode(AutoDrive.EDITOR_EXTENDED)
+ else
+ AutoDrive.setEditorMode(AutoDrive.EDITOR_OFF)
+ if vehicle ~= nil and vehicle.ad ~= nil and vehicle.ad.stateModule ~= nil then
+ vehicle.ad.stateModule:disableCreationMode()
+ end
+ end
+ end
end
function AutoDrive.cycleEditorShowMode()
- local vehicle = g_currentMission.controlledVehicle
+ local vehicle = g_currentMission.controlledVehicle
- if (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_OFF) then
- AutoDrive.setEditorMode(AutoDrive.EDITOR_SHOW)
- else
- AutoDrive.setEditorMode(AutoDrive.EDITOR_OFF)
+ if (AutoDrive.getSetting("EditorMode") == AutoDrive.EDITOR_OFF) then
+ AutoDrive.setEditorMode(AutoDrive.EDITOR_SHOW)
+ else
+ AutoDrive.setEditorMode(AutoDrive.EDITOR_OFF)
if vehicle ~= nil and vehicle.ad ~= nil and vehicle.ad.stateModule ~= nil then
- vehicle.ad.stateModule:disableCreationMode()
- end
- end
+ vehicle.ad.stateModule:disableCreationMode()
+ end
+ end
end
function AutoDrive.getSelectedWorkTool(vehicle)
- local selectedWorkTool = nil
-
- 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)
-
- if allImp ~= nil then
- for i = 1, #allImp do
- local imp = allImp[i]
- if imp ~= nil and imp.object ~= nil and imp.object:getIsSelected() then
- selectedWorkTool = imp.object
- break
- end
- end
- end
- end
- return selectedWorkTool
+ local selectedWorkTool = nil
+
+ 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)
+
+ if allImp ~= nil then
+ for i = 1, #allImp do
+ local imp = allImp[i]
+ if imp ~= nil and imp.object ~= nil and imp.object:getIsSelected() then
+ selectedWorkTool = imp.object
+ break
+ end
+ end
+ end
+ end
+ 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
+ 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
- local selectedWorkTool = nil
-
- if vehicle ~= nil and vehicle.ad ~= nil and vehicle.ad.stateModule ~= nil and vehicle.ad.stateModule:getFirstMarker() ~= nil then
- local firstMarkerID = vehicle.ad.stateModule:getFirstMarkerId()
- if firstMarkerID > 0 then
- local mapMarker = ADGraphManager:getMapMarkerById(firstMarkerID)
- -- do not allow to set debug marker as park destination
- if mapMarker ~= nil and mapMarker.isADDebug ~= true then
- selectedWorkTool = AutoDrive.getSelectedWorkTool(vehicle)
-
- if selectedWorkTool == nil then
- -- no attachment selected, so use the vehicle itself
- selectedWorkTool = vehicle
- end
-
- if selectedWorkTool ~= nil then
- if AutoDrive.isInExtendedEditorMode() and AutoDrive.leftCTRLmodifierKeyPressed and not AutoDrive.leftALTmodifierKeyPressed then
- -- assign park destination
- if vehicle.advd ~= nil then
- vehicle.advd:setParkDestination(selectedWorkTool, firstMarkerID)
- end
-
- -- on client sendMessage is not allowed, so add the message to ADMessagesManager to show it
- local messageText = "$l10n_AD_parkVehicle_selected; %s"
- local messageArg = vehicle.ad.stateModule:getFirstMarker().name
- -- localization
- messageText = AutoDrive.localize(messageText)
- -- formatting
- messageText = string.format(messageText, messageArg)
- ADMessagesManager:addMessage(ADMessagesManager.messageTypes.INFO, messageText, 5000)
-
- elseif AutoDrive.isInExtendedEditorMode() and not AutoDrive.leftCTRLmodifierKeyPressed and AutoDrive.leftALTmodifierKeyPressed then
- -- delete park destination
- if vehicle.advd ~= nil then
- vehicle.advd:setParkDestination(selectedWorkTool, -1)
- end
-
- -- on client sendMessage is not allowed, so add the message to ADMessagesManager to show it
- local messageText = "$l10n_AD_parkVehicle_deleted; %s"
- local messageArg = vehicle.ad.stateModule:getFirstMarker().name
- -- localization
- messageText = AutoDrive.localize(messageText)
- -- formatting
- messageText = string.format(messageText, messageArg)
- ADMessagesManager:addMessage(ADMessagesManager.messageTypes.INFO, messageText, 5000)
- end
- end
- end
- end
- end
+ 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
-- MP: Important! vehicle:getIsEntered() is not working as expected on server!
-- This is the alternative MP approach
function AutoDrive:getIsEntered(vehicle)
- local user = nil
- if vehicle ~= nil and g_currentMission.userManager ~= nil and g_currentMission.userManager.getUserByConnection ~= nil then
- user = g_currentMission.userManager:getUserByConnection(vehicle:getOwner())
- end
- return user ~= nil
+ local user = nil
+ if vehicle ~= nil and g_currentMission.userManager ~= nil and g_currentMission.userManager.getUserByConnection ~= nil then
+ user = g_currentMission.userManager:getUserByConnection(vehicle:getOwner())
+ end
+ return user ~= nil
end
diff --git a/FS19_AutoDrive/translations/translation_de.xml b/FS19_AutoDrive/translations/translation_de.xml
index 0b5de0fe..99753c6f 100644
--- a/FS19_AutoDrive/translations/translation_de.xml
+++ b/FS19_AutoDrive/translations/translation_de.xml
@@ -327,6 +327,14 @@
+
+
+
+
+
+
+
+
diff --git a/FS19_AutoDrive/translations/translation_en.xml b/FS19_AutoDrive/translations/translation_en.xml
index 4657fc1f..e240fd3d 100644
--- a/FS19_AutoDrive/translations/translation_en.xml
+++ b/FS19_AutoDrive/translations/translation_en.xml
@@ -327,6 +327,13 @@
+
+
+
+
+
+
+