diff --git a/AutoOvercharge.lua b/AutoOvercharge.lua
deleted file mode 100644
index 3f0c19eaf..000000000
--- a/AutoOvercharge.lua
+++ /dev/null
@@ -1,405 +0,0 @@
---
--- automatic overcharging for trailers with courseplay-attachervehicles
---
--- Brent Avelanche, Hilken, Agroliner TUW & Co., HAWE SUW 5000, Kverneland Taarup Shuttle & Co.
--- Bastian82
-
-AutoOvercharge = {};
-
-function AutoOvercharge.prerequisitesPresent(specializations)
- return true;
-end
-
-function AutoOvercharge:load(xmlFile)
- self.wasfolded = true;
- self.wasclosed = false;
-end
-
-function AutoOvercharge:delete()
-end
-
-function AutoOvercharge:readStream(streamId, connection)
-end
-
-function AutoOvercharge:writeStream(streamId, connection)
-end
-
-function AutoOvercharge:mouseEvent(posX, posY, isDown, isUp, button)
-end
-
-function AutoOvercharge:keyEvent(unicode, sym, modifier, isDown)
-end
-
-function AutoOvercharge:update(dt)
-
- if self.attacherVehicle ~= nil and (self.attacherVehicle.isHired or self.attacherVehicle.drive) then
- if self.attacherVehicle.ai_mode ~= nil and self.attacherVehicle.ai_mode == 3 then
- -- Brent Avelanche
- if self.lowerRmp ~= nil and self.attacherVehicle.movingDirection == 0 then
- if not self.turnOn and self.inRangeDraw and self.Go.trsp and self.CheckDone.trsp then
- self.turnOn = true;
- end;
- end;
-
- if self.animationParts ~= nil then
- -- Automatischer �berlademodus Taarup Shuttle
- if self.toggleUnloadingState ~= nil then
- if self:getIsActive() then
-
- if self.allowunload and self.activeUnloading == false then
- self:setUnloadingState(true);
- end;
-
- if self.attacherVehicle.ai_state == 0 and self.attacherVehicle.movingDirection == 0 and self.allowunload == false and self.unloadingState == 1 then
- self:setAnimationTime(2, self.animationParts[2].animDuration, false);
- end;
-
- if self.attacherVehicle.ai_state == 0 and self.attacherVehicle.movingDirection == 0 and self.unloadingState == 0 then
- self:setAnimationTime(1, self.animationParts[1].animDuration, false);
- self.open = true;
- end;
-
- if (self.filllevel == 0 or self.attacherVehicle.ai_state > 0) and self.unloadingState == 1 then
- self:setAnimationTime(1, self.animationParts[1].offSet, false);
- self:setUnloadingState(false);
- end;
- end;
- end;
-
-
-
- -- Hilken & Agroliner TUW & HAWE SUW 5000
- if self.toggleUnloadingState == nil and self.setUnloadingState ~= nil then
- if self:getIsActive() then
- -- HAWE SUW 5000
- if self.isDrumActivated ~= nil then
- if self.pipe ~= nil and self.attacherVehicle.ai_state == 0 and self.attacherVehicle.movingDirection == 0 then
- if not self.pipe.out then
- self:setAnimationTime(1, self.animationParts[1].animDuration, false);
- end;
- end;
- if (self.filllevel == 0 or self.attacherVehicle.ai_state > 0) then
- if self.pipe ~= nil and self.pipe.out then
- self:setAnimationTime(1, self.animationParts[1].offSet, false);
- end;
- end;
- self.isDrumActivated = self.isUnloading;
- else
- -- Agroliner, Hilken with optional folding of the pipe
- if self.pipe ~= nil and self.attacherVehicle.ai_state == 0 and self.attacherVehicle.movingDirection == 0 then
- if not self.pipe.out then
- if self.planeOpen == nil then
- -- Hilken
- self:setAnimationTime(1, self.animationParts[self.pipe.animOpenIdx].animDuration, false);
- else
- -- Agroliner
- self:setAnimationTime(1, self.animationParts[1].animDuration, false);
- end;
- end;
- end;
- -- Agroliner Plane close
- if (self.attacherVehicle.ai_state == 0 or self.loaded) and self.planeOpen ~= nil and self.planeOpen and self.wasclosed then
- self:setAnimationTime(3, self.animationParts[3].offSet, false);
- end;
-
- if (self.filllevel == 0 or self.attacherVehicle.ai_state > 0) then
- if self.pipe ~= nil and self.pipe.out and self.wasfolded then
- if self.planeOpen == nil then
- -- Hilken
- self:setAnimationTime(1, self.animationParts[self.pipe.animOpenIdx].offSet, false);
- else
- -- Agroliner
- self:setAnimationTime(1, self.animationParts[1].offSet, false);
- end;
- end;
- -- Agroliner Plane open
- if self.planeOpen ~= nil and not self.planeOpen then
- self:setAnimationTime(3, self.animationParts[3].animDuration, false);
- end;
- end;
- end;
- end;
- end;
- end;
-
-
- -- save pipe and plane status before courseplay start
- if self.toggleUnloadingState == nil and self.setUnloadingState ~= nil and self.pipe ~= nil and self.attacherVehicle ~= nil and not self.attacherVehicle.drive then
- self.wasfolded = not self.pipe.out;
- if self.planeOpen ~= nil then
- self.wasclosed = not self.planeOpen;
- end;
- end;
- end;
- end;
-end
-
-function AutoOvercharge:updateTick(dt)
- if self.attacherVehicle ~= nil and self.attacherVehicle.ai_mode ~= nil and self.attacherVehicle.ai_mode == 3 then
- -- Hilken & Agroliner TUW & HAWE SUW 5000
- if self.toggleUnloadingState == nil and self.setUnloadingState ~= nil then
-
- if self:getIsActive() then
- if self.trailerFoundId ~= nil and self.trailerFoundId ~= 0 then
- courseplay:debug("AutoOvercharge trailer found!", 3);
- local trailer = g_currentMission.nodeToVehicle[self.trailerFoundId];
- if trailer ~= nil and trailer ~= self and
- trailer.allowFillFromAir and trailer.capacity ~= trailer.fillLevel and
- (trailer:allowFillType(Fillable.fillTypeNameToInt["seeds"], true) or
- trailer:allowFillType(self.currentFillType, true)) then
- -- Automatischer �berlademodus
- if self.isUnloading == false and self.attacherVehicle ~= nil and self.attacherVehicle.movingDirection == 0 and (self.attacherVehicle.isHired or self.attacherVehicle.drive) then
- self:setUnloadingState(true);
- end;
- --
- end;
- end;
- end;
- end;
- end;
-end
-
-function AutoOvercharge:draw()
-end
-
-function AutoOvercharge:onAttach(attacherVehicle)
-end
-
-function AutoOvercharge:onDetach()
-end
-
-function AutoOvercharge:onLeave()
-end
-
-function AutoOvercharge:onDeactivate()
-end
-
-function AutoOvercharge:onDeactivateSounds()
-end
-
-
-
---Perard Innerbanne 25
---hz888
-
--- edited (optimized for courseplay) by Bastian82 - (find on planet-ls.de)
-
-perard = {};
-
-function perard.prerequisitesPresent(specializations)
- return SpecializationUtil.hasSpecialization(Trailer, specializations);
-end
-
-function perard:load(xmlFile)
-
- self.pipeParticles = {};
- local i = 0;
- while true do
- local key = string.format("vehicle.pipeParticles.pipeParticle(%d)", i);
- local t = getXMLString(xmlFile, key .. "#type");
- if t == nil then
- break;
- end;
- local desc = FruitUtil.fruitTypes[t];
- if desc ~= nil then
- local fillType = FruitUtil.fruitTypeToFillType[desc.index];
- local currentPS = {};
- local particleNode = Utils.loadParticleSystem(xmlFile, currentPS, key, self.components, false, "particleSystems/wheatParticleSystem.i3d", self.baseDirectory);
- self.pipeParticles[fillType] = currentPS;
- if self.defaultpipeParticles == nil then
- self.defaultpipeParticles = currentPS;
- end;
- end;
- i = i + 1;
- end;
-
- self.TrailerTrigger = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.TrailerTrigger#index"));
- self.onTrigger = perard.onTrigger;
- if self.TrailerTrigger ~= nil then
- addTrigger(self.TrailerTrigger, "onTrigger", self);
- end;
- self.isTrailerInRange = false;
- self.kardan1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.kardan1#index"));
- self.kardan2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.kardan2#index"));
- self.grainUnloading = 15;
-
- local pipeNode = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.pipe#index"));
- if pipeNode ~= nil then
- self.pipe = {};
- self.pipe.node = pipeNode;
- local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.pipe#minRot"));
- self.pipe.minRot = {};
- self.pipe.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
- self.pipe.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
- self.pipe.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
-
- x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.pipe#maxRot"));
- self.pipe.maxRot = {};
- self.pipe.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
- self.pipe.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
- self.pipe.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
-
- self.pipe.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.pipe#rotTime"), 2) * 1000;
- self.pipe.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.pipe#touchRotLimit"), 10));
- end;
-
- local pipe1Node = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.pipe1#index"));
- if pipe1Node ~= nil then
- self.pipe1 = {};
- self.pipe1.node = pipe1Node;
- local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.pipe1#minRot"));
- self.pipe1.minRot = {};
- self.pipe1.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
- self.pipe1.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
- self.pipe1.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
-
- x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.pipe1#maxRot"));
- self.pipe1.maxRot = {};
- self.pipe1.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
- self.pipe1.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
- self.pipe1.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
-
- self.pipe1.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.pipe1#rotTime"), 2) * 1000;
- self.pipe1.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.pipe1#touchRotLimit"), 10));
- end;
-
- self.pipeMax = false;
- self.ont = false;
-end
-
-function perard:delete()
-
- for _, particleSystem in pairs(self.pipeParticles) do
- Utils.deleteParticleSystem(particleSystem);
- end;
-end
-
-function perard:readStream(streamId, connection)
-end
-
-function perard:writeStream(streamId, connection)
-end
-
-function perard:mouseEvent(posX, posY, isDown, isUp, button)
-end
-
-function perard:keyEvent(unicode, sym, modifier, isDown)
-end
-
-function perard:update(dt)
-
- if self:getIsActiveForInput() then
- if InputBinding.hasEvent(InputBinding.IMPLEMENT_EXTRA) then
- self.pipeMax = not self.pipeMax;
- end;
-
- if InputBinding.hasEvent(InputBinding.IMPLEMENT_EXTRA2) and self.trailerFound ~= nil and self.pipeMax then
- self.ont = not self.ont;
- end;
- end;
-
- if self:getIsActive() and self.attacherVehicle ~= nil and self.attacherVehicle.drive then
- -- Pipe
- if self.attacherVehicle.ai_state == 0 and self.attacherVehicle.movingDirection == 0 and self.pipeMax == false then
- self.pipeMax = true
- end;
- if self.filllevel == 0 or self.attacherVehicle.ai_state > 0 and self.pipeMax == true then
- self.pipeMax = false
- end;
- end;
-
- --self.trailerFound = 0;
-
- if self:getIsActive() then
- local trailer = g_currentMission.nodeToVehicle[self.trailerFound];
- if self.trailerFound ~= nil and self.pipeMax then
- if self.attacherVehicle ~= nil and self.attacherVehicle.drive then
- self.ont = true
- end;
- if self.ont then
- local deltaLevel = self.grainUnloading;
- if trailer ~= nil and trailer ~= self and
- trailer.capacity ~= trailer.fillLevel and
- (trailer:allowFillType(Fillable.fillTypeNameToInt["seeds"], true) or
- trailer:allowFillType(self.currentFillType, true)) then
- deltaLevel = math.min(deltaLevel, trailer.capacity - trailer.fillLevel);
- if trailer.fillLevel >= trailer.capacity then
- self.ont = false;
- end;
- if self.fillLevel <= 0.0 then
- Utils.setEmittingState(self.pipeParticles[self.currentFillType], false);
- else
- Utils.setEmittingState(self.pipeParticles[self.currentFillType], true);
- end;
- else
- deltaLevel = 0;
- self.ont = false;
- Utils.setEmittingState(self.pipeParticles[self.currentFillType], false);
- end;
- if self.fillLevel <= 0.0 then
- deltaLevel = deltaLevel + self.fillLevel;
- self.fillLevel = 0.0;
- self.ont = false;
- end;
- self:setFillLevel(self.fillLevel - deltaLevel, self.currentFillType);
- if trailer ~= nil then
- trailer:setFillLevel(trailer.fillLevel + deltaLevel, self.currentFillType);
- end;
- else
- Utils.setEmittingState(self.pipeParticles[self.currentFillType], false);
- end;
- if self.ont and self.kardan1 ~= nil then
- rotate(self.kardan1, 0, 0, dt * 0.02);
- end;
- if self.ont and self.kardan2 ~= nil then
- rotate(self.kardan2, 0, 0, dt * -0.02);
- end;
- else
- Utils.setEmittingState(self.pipeParticles[self.currentFillType], false);
- end;
- if self.pipe ~= nil then
- local x, y, z = getRotation(self.pipe.node);
- local rot = { x, y, z };
- local newRot = Utils.getMovedLimitedValues(rot, self.pipe.maxRot, self.pipe.minRot, 3, self.pipe.rotTime, dt, not self.pipeMax);
- setRotation(self.pipe.node, unpack(newRot));
- end;
- if self.pipe1 ~= nil then
- local x, y, z = getRotation(self.pipe1.node);
- local rot = { x, y, z };
- local newRot = Utils.getMovedLimitedValues(rot, self.pipe1.maxRot, self.pipe1.minRot, 3, self.pipe1.rotTime, dt, not self.pipeMax);
- setRotation(self.pipe1.node, unpack(newRot));
- end;
- end;
-end
-
-function perard:draw()
-
- if self.pipeMax then
- if self.trailerFound ~= nil then
- if self.ont then
- g_currentMission:addHelpButtonText("Ueberladen ausschalten", InputBinding.IMPLEMENT_EXTRA2);
- else
- if self.fillLevel > 0.0 then
- g_currentMission:addHelpButtonText("Ueberladen einschalten", InputBinding.IMPLEMENT_EXTRA2);
- end;
- end;
- end;
- g_currentMission:addHelpButtonText("Schnecke einklappen", InputBinding.IMPLEMENT_EXTRA);
- else
- g_currentMission:addHelpButtonText("Schnecke ausklappen", InputBinding.IMPLEMENT_EXTRA);
- end;
-end
-
-function perard:onTrigger(triggerId, otherId, onEnter, onLeave, onStay, otherShapeId)
-
- if self:getIsActive() then
- if onStay or onEnter then
- self.isTrailerInRange = true;
- self.trailerFound = otherId;
- elseif onLeave then
- self.isTrailerInRange = false;
- self.trailerFound = nil;
- end;
- end;
-end
-
diff --git a/Readme.txt b/Readme.txt
deleted file mode 100644
index 19ae7aa99..000000000
--- a/Readme.txt
+++ /dev/null
@@ -1,276 +0,0 @@
-Courseplay - Abfahrhelfer für LS 2011 v 3.2
-
-Inhaltsverzeichnis
-
-
-
-I. Changelog
-II. Installationsanweisung
-III. Bedienungsanleitung
-IV. Credits
-
-1a. Changlog - Änderungen seit Version 3.12
- - Konvertierung auf LS 2013
- - Unterstützung mehrerer Abkippseiten beim Hänger
- - Automatische Einstellung des seitlichen Abstandes
- - Fruchtumfahrung dekativiert (gab zu viele Probleme damit)
- - Unterstützung für Rüben/Kartoffelernter
- - Optimiertes Wendemanöver beim Dreschen und Häckseln
- - Einstellungen im HUD können mit gedrückter STRG-Taste in größeren Schritten verstellt werden.
- - Debug-Level in allgemeinen Einstellungen einstellbar
- - Abkippen auf der BGA erfolgt während der Fahrt
- - Doppelbelegung der EINFG-Taste behoben
- - Infomeldung wenn Abfahrer im Verkehr steckt wird wieder angezeigt
- - Bedienung von Courseplay mit STRG+7 STRG+8 und STRG+9 statt ohne STRG
- - manuelles Rückwärtsfahren: Um einen Kurs rückwärts aufzuzeichnen muss man jetzt die Fahrtrichtung im HUD ändern
- - und zig Bugfixes
-
-Ib. Changelog - Änderungen seit Version 2.2 / 2.4
- - Neuer Modus: Drescher fährt selbst zum abtanken
- - Mähdrescher können jetzt auch selbstständig zu Hängern am Feldrand fahren. Dazu muss man mit dem Drescher einen Kurs einfahren der einen Wartepunkt enthält. Dieser Wartepunkt ist die Stelle an der auf den Hänger übergeladen wird. Nach dem Überladepunkt muss die Aufzeichnung beendet werden. Dann richtet man den Drescher auf dem Feld aus, schaltet den Helfer ein und ERST DANN stellt man den Abfahrhelfer ein.
- - Überladewagen kippen im Überlademodus automatisch ab
- - Brent Avelanche, Hilken, Agroliner TUW & Co., HAWE SUW 5000, Perard Innerbanne 25, Kverneland Taarup Shuttle & Co. laden am Überladepunkt automatisch ab. Der Taarup fährt sogar seinen Aufbau hoch und auch wieder runter.
- - AlternativeTipping von SFM wird voll unterstützt
- - Wendemanöver im Kombimodus wurden überarbeitet
- - A*Star Pathfinding
- - Abfahrer versuchen auf dem Feld nicht durch die Frucht zu fahren. Es wird automatisch nach einem Umweg um die Frucht herum gesucht. Wird ein Weg gefunden wird dieser genutzt und der Abfahrer fährt um die Frucht herum. (Dieses Feature ist noch experimentell)
- - beim speichern von Kursen steigt man nicht mehr aus dem Fahrzeug aus
- - Im Feldmodus werden weitere Rundballenpressen unterstützt
- - Man kann in den Einstellungen die max. Geschwindigkeit auswählen zwischen "max Geschwindigkeit" und "eingefahrener Geschwindigkeit". Das erste ist die alte Einstellung, courseplay ermittelt die auf der Straße zu fahrende Geschwindigkeit. Bei der zweiten Option wird immer die Geschwindigkeit genutzt die beim Einfahren des Kurses gefahren wurde.
- - man kann auf der letzten Seite der Einstellungen die Haltezeit am Wartepunkt definieren. Ist diese auf "0" wartet der Abfahrer am Wartepunkt bis er weitergeschickt wird. Ansonsten wartet er die vorgegebene Zeit am Wartepunkt und fährt dann automatisch weiter. (Ideal für die MapWeightStation)
-
-
-Ic. Changelog - Änderungen seit Version 2.11
- - Neuer Modus: Drescher fährt selbst zum abtanken
- - support für das BGA Silo des Giants DLC2
- - support für typanywhere mod
- - support für kommenden drescher autopilotenn 3.0.5
- - bessere unterstützung für ballensammelwagen
- - fehler beim befüllen von überladewagen und abfahrern auf der zweiten Runde gefixt
- - selten auftretenden multiplayer-callstacks behoben
-
-
-Id. Changelog - Änderungen seit Version 2.0
- In der Version 2.0 waren leider noch einige Fehler die den Multiplayermodus gestört haben. Diese wurden behoben.
- Neu in dieser Version ist vor allem, dass ihr eure Schlepper nicht mehr mit courseplay nachrüsten müsst. Einfach den Mod ins Modverzeichnis und alle Fahrzeuge sind automatisch damit ausgestattet.
- Durch diese Änderung müsst ihr leider in allen bereits umgerüsteten Schleppern den Eintrag "" entfernen.
- Weiterhin wurde in dieser Version das Kombinieren von Kursen verbessert.
-
- Wichtig: die Datei aaacourseplay.zip (v2 und kleiner) MUSS aus dem Mod-Verzeichnis gelöscht werden.
-
-Ie. Changelog - Änderungen seit Version 1.6
-
- Die größte Änderung im courseplay ist natürlich die Multiplayerfähigkeit. Dabei werden beim Spielstart alle Werte und sogar gespeicherte Kurse vom Host an die Clients übertragen. Das kann mitunter ein bisschen dauern ist aber notwendig.
- Neben zahlreichen Bugfixes und Performance-Optimierungen die hier nicht weiter erwähnt werden sollen gibt es im wesentlichen die folgende Neuerungen:
-
- Kursverwaltung: Gespeicherte Kurse werden jetzt alphabetisch sortiert und werden immmer global für alle Fahrzeuge gespeichert. Dadurch ist kein Synchronisieren der Kurse zwischen den einzelnen Fahrzeugen mehr nötig und der Speicherverbrauch ist drastisch gesunken.
-
- Kurse aufnhemen: Das Pausieren der Kursaufnahme wurde überarbeitet. Man kann jetzt die Kursaufzeichnung pausieren und die letzten Wegpunkte löschen. Dabei wird jetzt immer nur der letzte Wegpunkt angezeigt und nicht mehr alle.
-
- Neu: Kurs Offset
-
- Dieses Feature ist noch experimentell und soll dafür sorgen, dass der Schlepper den gespeicherten Kurs leicht versetzt abfährt. Gedacht ist dies zum Beispiel für Ballensammelwagen.
-
- Neue Kurskombination:
-
- Ihr könnt beim Einfahren eines Kurses jetzt Kreuzungspunkte setzen. Wenn ihr später mehrere Kurse hintereinander ladet werden diese immer am ersten gemeinsamen Kreuzungspunkt (Abstand unter 30 Metern!) zusammengefügt. Damit könnt ihr also auch Teile von Routen wieder verwenden.
-
- Das Rückwärtsfahren wurden optimiert und sollte jetzt wieder richtig funktionieren.
-
- Wenn ihr das Spiel speichert werden die Einstellungen eurer Abfahrer mit gespeichert. Nach dem Neuladen müsst ihr also normalerweise nichts mehr einstellen. Die zuvor geladenen Kurse und Einstellungen sollten komplett wieder verfügbar sein.
-
- Außerdem gibt es neue Symbole für die Wegpunkte und spezielle Wegpunkte wie Kreuzungspunkte und Startpunkte sind auch sichtbar wenn ihr nicht im Fahrzeug seid welches die Route gespeichert hat.
-
-
-If. Changelog - Änderungen seit Version 1.2
-
- Neu hinzugekommen sind vor allem der Feldmodus mit dem man Ballen pressen und Heusammeln kann. Der Güllemodus wurde weiter perfektioniert und es ist jetzt auch möglich den Abfahrhelfer in Drescher und Häcksler einzubauen.
- Damit kann man beispielsweise mit Dreschern im Helfermodus Kurse aufzeichnen lassen die man dann später für den Gülle- oder Feldmodus verändern kann.
- Zudem gibt es eine Steuerung des Abfahrhelfers aus dem Drescher heraus. Man kann einen Abfahrhelfer rufen, starten, stoppen und beim Häcksler die Seite des Abfahrers ändern.
- Beim Abfahrhelfer kann man jetzt einstellen bei wieviel Prozenz Füllstand er frühzeitig abfahren soll. Hat ein Abfahrer zum Beispiel einen Füllstand von 90% und der Drescher wendet am Ende des Feldes, fährt der Abfahrer gleich ab und wartet nicht auf das Wendemanöver.
- Zudem fährt der Überladewagen an seinem Überladepunkt wieder zurück aufs Feld wenn er einen gewissen Füllstand unterschritten hat und für etwa 20 Sekunden kein weiterer Abfahrer zum überladen konmmt.
- Außerdem wurrde gewünscht, dass der Abfahrhelfer auf der Straße seine Rundumleuchte einschaltet - das tut er jetzt ;)
- Dann gab es natürlich auch noch etwas Feintuning: Das unsinnige Kreiseln auf dem Feld sollte jetzt vorbei sein, HW80 Drehschemel und Agroliner Container werden jetzt auch unterstützt.
-
-
-Ig. Changelog - Änderungen seit Version 1.0
-
- Als neue Funktionen sind im wesentlichen der Düngemodus und das Rückwärtsfahren hinzugekommen. Außerdem wurde das Fahrverhalten (besonders in Kurven) verbessert und es werden mehr EntladeTrigger (Gras und Silage) erkannt.
- Zudem kann man jetzt gespeicherte Kurse kombinieren indem man mehrere Kurse hintereinander lädt. Wenn man nur einen neuen Kurs laden will muss man allerdings jetzt vorher die Wegpunkte des alten zurücksetzen.
- Außerdem ist der Abfahrhelfer jetzt kein "hireable" mehr, das heißt er verbraucht jetzt Benzin(Dünger..) beim Fahren. Damit der Abfahrer nicht einfach irgendwo stehen bleibt bekommt man eine Warnung sobald der Tank fast leer ist und bei einem minimalen Tankinhalt bleibt der Abfahrhelfer stehen damit man ihn noch bis zur Zapfsäule bekommt.
- Im Menu wurde noch der "BUG" behoben, dass man das Menu mit allen Maustasten steuern konnte.
- Natürlich gab es noch viele weitere kleine Bugfixes.
-
- Dieses Mal geht ein besonders großer Dank an Wolverine, der einen Großteil dieses Updates (Düngemodus und Rückwärtsfahren) implementiert hat.
- Wir haben weiterhin an einer Version 2 die komplett multiplayerfähig ist, die aktuelle Version 1.20 ist aber zumindest im MP vom Host bedienbar.
-
-
-
-II. Installationsanweisung
-
-1. Das Archiv ZZZ_courseplay.zip in das Verzeichnis C:\Users\dein Username\MyGames\FarmingSimulator2013\mods kopieren. Das War es!
-
-
-III. Bedienungsanleitung
-
-
- Steuerung:
-
- Die Steuerung des Abfahrhelfers funktioniert im wesentlichem mit der Maus da freie Tasten im Landwirtschafts Simulator ja sehr rah sind.
- Mit einem Klick auf die rechte Maustaste aktiviert ihr das Courseplay HUD in dem ihr den Abfahrer konfigurieren könnt. Zusätzlich sind einige Funktionen wie Abfahrer starten und stoppen auch über die Tastatur über die Tasten NUMPAD 7 bis NUMPAD 9 belegt.
-
- HUD:
-
- Wenn ihr das HUD öffnet wird automatisch die Maussteuerung aktiviert. Das heißt ihr könnt euch mit der Maus nicht mehr umgucken. Um die Maussteuerung zu deaktivieren müsst ihr einfach nochmal auf die rechte Maustaste klicken.
- Alternativ könnt ihr auch auf das rote X oben rechts im HUD klicken. Dabei wird das HUD geschlossen und die Maussteuerung wieder deaktiviert.
-
- Das HUD ist in mehrere Unterseiten unterteilt. Diese könnt ihr mit den blauen Pfeilen im oberen Bereich des HUDs wechseln.
- Im mittleren Bereich des HUDs könnt ihr auf jeder Unterseite verschiede Einstellungen vornehmen oder Befehle geben. Klickt dazu einfach auf die gewünschte Aktion.
-
- Im unteren Bereich des HUDs findet ihr Infos über euren Abfahrer den geladenen Kurs und den aktuellen Status. Dort könnt ihr durch klick auf die Diskette euren eingefahrenen Kurs auch speichern.
-
- HUD "Abfahrhelfer Steuerung":
-
- Kursaufzeichnung beginnen:
-
- Mit dieser Option wird der Aufnahmemodus des Abfahrhelfers aktiviert. Ihr könnt damit den Kurs einfahren den der Abfahrer später fahren soll.
- Bei Aktivierung werden anfangs drei Fässchen im Abstand von 10-20 Metern gesetzt. Ihr solltet darauf achten, dass ihr bis zum dritten Fass nach Möglichkeit geradeaus fahrt.
- Wenn ihr diese Funktion aktiviert habt könnt ihr mit der rechten Maustaste die Maussteuerung deaktivieren damit ihr euch beim Einfahren des Kurses auch umschauen könnt.
-
- Kursaufzeichnung anhalten:
-
- Wenn die Kursaufzeichnung läuft könnt ihr mit dieser Funktion die Kursaufzeichnung pausieren. Es wird ein gelber Pfeil angezeigt der zum letzten Wegpunkt zeigt. Zusätzlich könnt ihr in diesem Modus auch den letzten Wegpunkt löschen.
-
- Kursaufzeichnung beenden:
-
- Diese Aktion ist nur im Aufnahmemodus vergügbar und dient dazu diesen zu beenden. Klickt auf diese Funktion wenn ihr den Endpunkt eurer eingefahrenen Route erreicht habt.
- Es empfiehlt sich, dass der Endpunkt etwa 10 Meter vor dem Startpunkt liegt und dass man grob aus der Richtung kommt in die der Abfahrer beim Startpunkt auch weiterfahren soll.
-
- Hier Wartepunkt setzen:
-
- Im Aufnahmemodus habt ihr die Möglichkeit auf der Strecke Wartepunkte zu setzen. An diesen Punkten wird der Abfahrer später beim Abfahren anhalten bis man ihn manuell weiter schickt.
- Wenn ein Abfahrer einen Wartepunkt erreicht hat wird euch das am unteren Bildschirmrand angezeigt.
-
- Abfahrer einstellen:
-
- Wenn ihr einen Kurs eingefahren habt könnt ihr jetzt den Abfahrer einstellen. Dabei wird der Abfahrhelfer aktiviert und fährt brav seine Route ab.
-
- Abfahrer entlassen:
-
- Den aktivierten Abfahrer könnt ihr natürlich auch jederzeit entlassen bzw. anhalten.
- Wenn ihr den Abfahrhelfer später wieder aktiviert wird er seine Route am letzen Punkt fortführen.
-
- weiterfahren:
-
- Diese Option steht euch zur Verfügung wenn der Abfahrer einen Wartepunkt erreicht hat.
-
- Abfahrer-Typ wechseln:
-
- Damit der Abfahrhelfer möglichst viele Aufgaben erledigen kann gibt es verschiedene Abfahrhelfer Typen.
- Der aktuelle Typ wird im unteren Bereich des HUDs angezeigt. Mit klick auf diese Aktion könnt ihr die Typen durchgehen.
-
- Typ: Abfahrer
-
- Der Typ Abfahrer wartet am Startpunkt bis er voll beladen ist und fährt erst dann die Route ab. Wenn er auf seiner Route über eine Abkippstelle kommt hält er an und entleert seine(n) Anhänger.
- Man kann dem Abfahrer am Startpunkt allerdings auch sagen, dass er sofort abfahren soll.
-
-
- Typ: Kombiniert
-
- Der Kombinierte Modus ist ähnlich wie der Abfahrer Modus mit dem Unterschied, dass der Abfahrer am Startpunkt nicht wartet bis er beladen ist sondern selbstständig zu einem Drescher oder Häcksler auf dem aktuellen Feld fährt und diese bedient.
- Wenn alle Hänger voll sind fährt der Abfahrer das zweite Fässchen auf seiner Route an und fährt von da an die Route ab wie der normale Abfahrer.
- Damit der kombinierte Modus funktioniert muss der Startpunkt des Abfahrers unbedingt auf dem gleichen Feld liegen auf dem der oder die Drescher sind.
-
- Typ: Überladewagen
-
- Beim Typ Überladewagen fährt der Abfahrer auch direkt zum Drescher oder Häcksler und fährt anschließend seine Route ab. Der Unterschied hierbei ist, dass der Überladewagen "Wartepunkte" als "Abladepunkte" nutzt.
- Wenn der Überladewagen also voll ist fährt er seine Route bis zum Wartepunkt ab und fährt dort automatisch weiter, wenn der Überladewagen leer ist.
-
- Typ: Überführung
-
- In diesem Modus fährt der Abfahrer lediglich seine Route ab. Er wartet nicht am Startpunkt und wird an Abladestellen auch nicht entladen.
- Dieser Modus eignet sich in Verbindung mit Wartepunkten um Gerätschaften zum Feld zu bringen oder zum Beispiel auch auf andere Höfe.
-
- Typ: Düngen
-
- Im Düngemodus füllt der Abfahrhelfer am Startpunkt eine Spritze oder ein Güllefass und fährt dann seine Route ab. Man fährt mit dem Abfahrhelfer zum Feld, setzt einen Wartepunkt an der Stelle an der er mit dem Düngen beginnen soll, fährt das Feld ab und setzt einen Wartepunkt am Feldende.
- Beim Abfahren klappt der Abfahrhelfer automatisch die Spritze/Güllefass aus und schaltet es an, fährt das Feld ab bis der Tank leer ist und fährt zurück zum auftanken. Nach dem Auftanken macht er an der Position weiter an der er aufgehört hat.
-
- Typ: Feldarbeit (Ballenpressen, Schwadaufnahme)
-
- Der Feldarbeitsmodus funktioniert ähnlich wie der Düngemodus. Hierbei wird ein zuvor aufgezeichneter Kurs mit Feldgeschwindigkeit abgefahren.
- Als Besonderheit kann man in diesem Modus zum Beispiel eine Ballenpresse anhängen. Die Rundballenpresse hält hierbei an wenn sie voll ist und wirft den Ballen aus.
- Wenn man einen Ladewagen anhängt wird der Kurs abgefahren bis dieser voll ist, dann wird die letzte Position gespeichert und der Kurs abgefahren. Der Kurs sollte dann natürlich an einem Abladetrigger vorbei führen. Dort wird der Wagen entleert und dann fährt er zurück zum Feld und setzt seine Arbeit am letzten Punkt fort.
- Der Arbeitsbereich des Modus Feldarbeit muss wie im Düngemodus durch zwei Wartepunkte markiert werden.
-
- Typ: Drescher färht selbst zum abtanken
-
- Dieser Modus ist ähnlich dem des Überladewagens, nur eben für Drescher. Der Startpunkt der Route ist der Punkt den der Drescher anfährt wenn er den eingestellen Füllstand erreicht hat. Er fährt dann die Route bis zum
- 1. Wartepunkt ab. Am Wartepunkt tankt der Drescher ab und fährt, sobald er leer ist die Route weiter. Der Endpunkt der Route ist der Punkt an dem der Drescher den Helfer aktiviert. Wenn er bereits auf dieser Route gedroschen hat, fährt er nach dem abtanken den letzten Wegpunkt an und dann weiter an den Punkt an dem der Drescher
- weggefahren ist.
-
-
- Wegpunkte löschen:
-
- Wenn ein Kurs eingefahren ist kannst du über diese Option den Kurs wieder zurücksetzen. Dabei wird der gespeicherte Kurs nicht aus der Konfigurationsdaten gelöscht sondern nur der aktuelle Abfahrer wieder zurückgesetzt.
-
-
- HUD Kurs speichern
-
- Im unteren Breich des Huds findet ihr eine Diskette. Wenn ihr einen Kurs eingefahren habt könnt ihr durch Klick auf die Diskette euren Kurs speichern.
- Dabei wird im oberen Bereich eine Eingabemaske angezeigt. Hier könnt ihr mit der Tastatur einen Namen für euren Kurs vergeben und diesen mit ENTER (Eingabetaste) bestätigen.
-
- Hinweis: Aktuell ist die Steuerung des Spiels im Speichermodus noch aktiv. Das heißt wenn ihr zum Beispiel "e" drückt steigt ihr leider noch aus dem Fahrzeug aus.
- In diesem Fall einfach wieder einsteigen und weiter tippen. Dieses Problem wird in einer späteren Version natürlich behoben.
-
-
- HUD "Kurse verwalten":
-
- Auf diser Unterseite des HUD findet ihr eine Übersicht eurer gespeicherten Kurse. Ihr könnt durch Klick auf das Ordner Symbol einen Kurs laden und durch einen Klick auf das rote X einen Kurs komplett löschen.
- ACHTUNG: seit version 1.2 müsst ihr wenn ihr einen neuen Kurs laden wollt erst die alten Wegpunkte zurücksetzen, sonst kombiniert ihr die beiden Kurse!
- Mit den blauen Pfeilen rechts oben und rechts unten könnt ihr durch die gespeicherten Kurse blättern.
- Hinweis zum Kombinieren von Kursen: Das Ordner Symbol ohne den blauen Pfeil kombiniert die Kurse am ersten gemeinsamen Kreuzungspunkt, der mit dem blauen Pfeil hängt die Kurse einfach hintereinander.
-
- HUD "Einstellungen Combi Modus":
-
- Diese Einstellungen gelten (wie der Name es andeutet) nur für den kombinierten Modus und den Überlademodus. Hiermit könnt ihr euren Abfahrer an den jeweiligen Drescher anpassen.
- Ihr könnt die Werte mit einem Klick auf das +/- Symbol daneben anpassen (Bei klick mit gedrückter STRG-Taste verstellt ihr die Werte in größeren Abständen)
-
- seitl. Abstand
-
- Dieser Wert definiert den seitlichen Abstand den ein Abfahrer zum Drescher oder Häcksler beim nebenher fahren einhalten soll.
- Voreingestellt ist hier "auto" damit passt sich der Abfahrer automatisch an den Drescher oder Häcksler an.
-
- Start bei %:
-
- Dieser Wert legt fest ab welchem Füllstand des Dreschers der Abfahrer zu ihm fährt und ihn abtankt.
- Bei Häckslern wird durch diesen Wert festgelegt ab wann der zweite Abfahrer in der Kette dem ersten hinterherfahren soll.
-
- Wenderadius:
-
- Dieser Wert ist nur beim Häckseln wichtig und legt fest wie weit der Abfahrer beim Wenden des Häckslers von ihm wegfahren soll ohne ihm im Weg zu stehen.
-
- Pipe Abstand:
-
- wird im Spiel nicht mehr berücksichtigt
-
- HUD "Drescher verwalten":
-
- Auch diese Einstellungen sind nur für den kombinierten Modus relevant. Hier könnt ihr einstellen ob der Abfahrer sich automatisch einen Drescher oder Häcksler suchen soll (Standard) oder er einen manuell zugewiesenen Drescher nutzen soll.
- Wenn ihr einen Drescher manuell zuweist muss dieser auch nicht auf dem gleichen Feld stehen. Der Abfahrer fährt von seinem Startpunkt automatisch zum Drescher, egal wo dieser sich befindet.
-
- Interessant ist diese Einstellung vor allem bei großen oder hügeligen Feldern auf denen die automatische Zuweisung nicht immer funktioniert und auf Feldern ohne Grubbertextur z.B. Wiesen.
-
- HUD "Geschwidigkeiten":
-
- Hier könnt ihr festlegen wie schnell euer Abfahrer fahren soll. Ich denke mal die Einstellungen sind selbst erklärend ;)
-
-
-IV. Credits
- Lautschreier (Grundversion)
- Hummel (modhoster.de)
- Wolverin0815 (Feldarbeitsmodus, HUD, ...)
- Bastian82 (Feldarbeitsmodus, Optimierungen, ...)
- Skydancer (Feldkursgenerierung, Güllezubringerunterstützung, ...)
- JakobT (debug Modus, automatischer Abstand, neue Steuerung mit STRG)
-
diff --git a/astar.lua b/astar.lua
deleted file mode 100644
index 6c6558839..000000000
--- a/astar.lua
+++ /dev/null
@@ -1,283 +0,0 @@
---[[
-A* algorithm for LUA
-Ported to LUA by Altair
-21 septembre 2006
-courseplay edit by hummel 2011
---]]
-
-
-function round(num, idp)
- return math.floor(num / idp) * idp
-end
-
-function CalcMoves(px, py, tx, ty, fruit_type) -- Based on some code of LMelior but made it work and improved way beyond his code, still thx LMelior!
- if not courseplay:is_field(py, px) then
- return nil
- end
-
- local interval = 5
- local vertical_costs = 10
- local diagnoal_costs = 14
-
- px = round(px, interval)
- py = round(py, interval)
- tx = round(tx, interval)
- ty = round(ty, interval)
-
- --[[ PRE:
-mapmat is a 2d array
-px is the player's current x
-py is the player's current y
-tx is the target x
-ty is the target y
-
-Note: all the x and y are the x and y to be used in the table.
-By this I mean, if the table is 3 by 2, the x can be 1,2,3 and the y can be 1 or 2.
---]]
-
- --[[ POST:
-closedlist is a list with the checked nodes.
-It will return nil if all the available nodes have been checked but the target hasn't been found.
---]]
-
- -- variables
- local openlist = {} -- Initialize table to store possible moves
- local closedlist = {} -- Initialize table to store checked gridsquares
- local listk = 1 -- List counter
- local closedk = 0 -- Closedlist counter
- local tempH = math.abs(px - tx) + math.abs(py - ty)
- local tempG = 0
- openlist[1] = { x = px, y = py, g = 0, h = tempH, f = 0 + tempH, par = 1 } -- Make starting point in list
- local xsize = 1024 -- horizontal map size
- local ysize = 1024 -- vertical map size
- local curbase = {} -- Current square from which to check possible moves
- local basis = 1 -- Index of current base
- local max_tries = 2000
- local max_distance_factor = 10
- local air_distance = tempH
-
- -- Growing loop
- while listk > 0 do
-
- -- Get the lowest f of the openlist
- local lowestF = openlist[listk].f
- basis = listk
- for k = listk, 1, -1 do
- if openlist[k].f < lowestF then
- lowestF = openlist[k].f
- basis = k
- end
- end
-
- if closedk >= max_tries then
- return nil
- end
-
- closedk = closedk + 1
- table.insert(closedlist, closedk, openlist[basis])
-
- curbase = closedlist[closedk] -- define current base from which to grow list
-
- --courseplay:debug(string.format("a star check x: %f y %f - closedk: %d", curbase.x, curbase.y, closedk ), 4)
-
- local wOK = true
- local eOK = true -- Booleans defining if they're OK to add
- local sOK = true -- (must be reset for each while loop)
- local nOK = true
-
- local nwOK = true
- local seOK = true
- local swOK = true
- local noOK = true
-
- -- Look through closedlist
- if closedk > 0 then
- for k = 1, closedk do
- if closedlist[k].x == curbase.x + interval and closedlist[k].y == curbase.y then
- wOK = false
- end
- if closedlist[k].x == curbase.x - interval and closedlist[k].y == curbase.y then
- eOK = false
- end
- if closedlist[k].x == curbase.x and closedlist[k].y == curbase.y + interval then
- sOK = false
- end
- if closedlist[k].x == curbase.x and closedlist[k].y == curbase.y - interval then
- nOK = false
- end
-
- if closedlist[k].x == curbase.x + interval and closedlist[k].y == curbase.y - interval then
- nwOK = false
- end
-
- if closedlist[k].x == curbase.x - interval and closedlist[k].y == curbase.y - interval then
- neOK = false
- end
-
- if closedlist[k].x == curbase.x + interval and closedlist[k].y == curbase.y + interval then
- swOK = false
- end
-
- if closedlist[k].x == curbase.x - interval and closedlist[k].y == curbase.y + interval then
- seOK = false
- end
- end
- end
-
- -- Check if next points are on the map and within moving distance
- if curbase.x + interval > xsize then
- wOK = false
- nwOK = false
- swOK = false
- end
- if curbase.x - interval < -1024 then
- eOK = false
- neOK = false
- seOK = false
- end
- if curbase.y + interval > ysize then
- sOK = false
- swOK = false
- seOK = false
- end
- if curbase.y - interval < -1024 then
- nOK = false
- nwOK = false
- neOK = false
- end
-
- -- If it IS on the map, check map for obstacles
- --(Lua returns an error if you try to access a table position that doesn't exist, so you can't combine it with above)
- if wOK and curbase.x + interval <= xsize and courseplay:area_has_fruit(curbase.y, curbase.x + interval, fruit_type) then
- wOK = false
- end
- if eOK and curbase.x - interval >= -1024 and courseplay:area_has_fruit(curbase.y, curbase.x - interval, fruit_type) then
- eOK = false
- end
- if sOK and curbase.y + interval <= ysize and courseplay:area_has_fruit(curbase.y + interval, curbase.x, fruit_type) then
- sOK = false
- end
- if nOK and curbase.y - interval >= -1024 and courseplay:area_has_fruit(curbase.y - interval, curbase.x, fruit_type) then
- nOK = false
- end
-
- -- check if the move from the current base is shorter then from the former parrent
- tempG = curbase.g + interval
- for k = 1, listk do
- if wOK and openlist[k].x == curbase.x + interval and openlist[k].y == curbase.y then
- if openlist[k].g > tempG then
- --courseplay:debug("right OK 1", 4)
- tempH = math.abs((curbase.x + interval) - tx) + math.abs(curbase.y - ty)
- table.insert(openlist, k, { x = curbase.x + interval, y = curbase.y, g = tempG, h = tempH, f = tempG + tempH, par = closedk })
- end
- wOK = false
- end
-
- if eOK and openlist[k].x == curbase.x - interval and openlist[k].y == curbase.y then
- if openlist[k].g > tempG then
- --courseplay:debug("left OK 1", 4)
- tempH = math.abs((curbase.x - interval) - tx) + math.abs(curbase.y - ty)
- table.insert(openlist, k, { x = curbase.x - interval, y = curbase.y, g = tempG, h = tempH, f = tempG + tempH, par = closedk })
- end
- eOK = false
- end
-
- if sOK and openlist[k].x == curbase.x and openlist[k].y == curbase.y + interval then
- if openlist[k].g > tempG then
- --courseplay:debug("down OK 1", 4)
- tempH = math.abs((curbase.x) - tx) + math.abs(curbase.y + interval - ty)
-
- table.insert(openlist, k, { x = curbase.x, y = curbase.y + interval, g = tempG, h = tempH, f = tempG + tempH, par = closedk })
- end
- sOK = false
- end
-
- if nOK and openlist[k].x == curbase.x and openlist[k].y == curbase.y - interval then
- if openlist[k].g > tempG then
- --courseplay:debug("up OK 1", 4)
- tempH = math.abs((curbase.x) - tx) + math.abs(curbase.y - interval - ty)
- table.insert(openlist, k, { x = curbase.x, y = curbase.y - interval, g = tempG, h = tempH, f = tempG + tempH, par = closedk })
- end
- nOK = false
- end
- end
-
- -- Add points to openlist
- -- Add point to the right of current base point
- if wOK then
- --courseplay:debug("right OK", 4)
- listk = listk + 1
- tempH = math.abs((curbase.x + interval) - tx) + math.abs(curbase.y - ty)
-
- table.insert(openlist, listk, { x = curbase.x + interval, y = curbase.y, g = tempG, h = tempH, f = tempG + tempH, par = closedk })
- end
-
- -- Add point to the left of current base point
- if eOK then
- --courseplay:debug("left OK", 4)
- listk = listk + 1
- tempH = math.abs((curbase.x - interval) - tx) + math.abs(curbase.y - ty)
- table.insert(openlist, listk, { x = curbase.x - interval, y = curbase.y, g = tempG, h = tempH, f = tempG + tempH, par = closedk })
- end
-
- -- Add point on the top of current base point
- if sOK then
- --courseplay:debug("down OK", 4)
- listk = listk + 1
- tempH = math.abs(curbase.x - tx) + math.abs((curbase.y + interval) - ty)
-
- table.insert(openlist, listk, { x = curbase.x, y = curbase.y + interval, g = tempG, h = tempH, f = tempG + tempH, par = closedk })
- end
-
- -- Add point on the bottom of current base point
- if nOK then
- --courseplay:debug("up OK", 4)
- listk = listk + 1
- tempH = math.abs(curbase.x - tx) + math.abs((curbase.y - interval) - ty)
-
- table.insert(openlist, listk, { x = curbase.x, y = curbase.y - interval, g = tempG, h = tempH, f = tempG + tempH, par = closedk })
- end
-
- table.remove(openlist, basis)
- listk = listk - 1
-
- if closedlist[closedk].x == tx and closedlist[closedk].y == ty then
- return CalcPath(closedlist)
- end
- end
-
- return nil
-end
-
-function CalcPath(closedlist)
- --[[ PRE:
-closedlist is a list with the checked nodes.
-OR nil if all the available nodes have been checked but the target hasn't been found.
---]]
-
- --[[ POST:
-path is a list with all the x and y coords of the nodes of the path to the target.
-OR nil if closedlist==nil
---]]
-
- if closedlist == nil then
- return nil
- end
- local path = {}
- local pathIndex = {}
- local last = table.getn(closedlist)
- table.insert(pathIndex, 1, last)
-
- local i = 1
- while pathIndex[i] > 1 do
- i = i + 1
- table.insert(pathIndex, i, closedlist[pathIndex[i - 1]].par)
- end
-
- for n = table.getn(pathIndex), 1, -1 do
- table.insert(path, { x = closedlist[pathIndex[n]].x, y = closedlist[pathIndex[n]].y })
- end
-
- closedlist = nil
- return path
-end
\ No newline at end of file
diff --git a/base.lua b/base.lua
deleted file mode 100644
index 5c08ac869..000000000
--- a/base.lua
+++ /dev/null
@@ -1,910 +0,0 @@
-local cp_directory = g_currentModDirectory
-
-function courseplay.prerequisitesPresent(specializations)
- return true;
-end
-
-function courseplay:load(xmlFile)
- -- global array for courses, no refreshing needed any more
- --if courseplay_courses == nil and g_server ~= nil then
- -- courseplay_courses = courseplay:load_courses()
- --elseif not courseplay_courses then
- -- courseplay_courses = {}
- --end
-
- self.setCourseplayFunc = SpecializationUtil.callSpecializationsFunction("setCourseplayFunc");
-
- local aNameSearch = { "vehicle.name." .. g_languageShort, "vehicle.name.en", "vehicle.name", "vehicle#type" };
-
- if not steerable_overwritten then
- steerable_overwritten = true
- if Steerable.load ~= nil then
- local orgSteerableLoad = Steerable.load
- courseplay:debug("overwriting steerable.load", 1)
- Steerable.load = function(self, xmlFile)
- orgSteerableLoad(self, xmlFile)
-
- for nIndex, sXMLPath in pairs(aNameSearch) do
- self.name = getXMLString(xmlFile, sXMLPath);
- if self.name ~= nil then break; end;
- end;
- if self.name == nil then self.name = g_i18n:getText("UNKNOWN") end;
- end;
- end;
-
- if Attachable.load ~= nil then
- courseplay:debug("overwriting Attachable.load", 1)
- local orgAttachableLoad = Attachable.load
-
- Attachable.load = function(self, xmlFile)
- orgAttachableLoad(self, xmlFile)
-
- for nIndex, sXMLPath in pairs(aNameSearch) do
- self.name = getXMLString(xmlFile, sXMLPath);
- if self.name ~= nil then break; end;
- end;
- if self.name == nil then self.name = g_i18n:getText("UNKNOWN") end;
- end
- end;
- end
-
- if self.name == nil then
- for nIndex, sXMLPath in pairs(aNameSearch) do
- self.name = getXMLString(xmlFile, sXMLPath);
- if self.name ~= nil then break; end;
- end;
- if self.name == nil then self.name = g_i18n:getText("UNKNOWN") end;
- end
-
- self.cp = {};
- self.toggledTipState = 0;
-
- self.auto_combine_offset = true
- self.mouse_right_key_enabled = true
- self.drive = false
- self.runOnceStartCourse = false;
- self.StopEnd = false
- self.lastGui = nil
- self.currentGui = nil
- self.input_gui = "emptyGui";
- self.calculated_course = false
-
- self.recordnumber = 1
- self.tmr = 1
- self.startlastload = 1
- self.timeout = 1
- self.timer = 0.00
- self.drive_slow_timer = 0
- self.courseplay_position = nil
- self.waitPoints = 0
- self.waitTime = 0
- self.crossPoints = 0
- self.waypointMode = 1
- self.RulMode = 1
- self.workWidthChanged = 0
- -- saves the shortest distance to the next waypoint (for recocnizing circling)
- self.shortest_dist = nil
- self.use_speed = true
-
- -- clickable buttons
- self.buttons = {}
-
- -- waypoints are stored in here
- self.Waypoints = {}
-
- -- TODO still needed?
- self.play = false
- -- total number of course players
- self.working_course_player_num = nil
-
- -- info text on tractor
- self.info_text = nil
-
- -- global info text - also displayed when not in vehicle
- self.global_info_text = nil
- self.testhe = false
-
- -- ai mode: 1 abfahrer, 2 kombiniert
- self.ai_mode = 1
- self.follow_mode = 1
- self.ai_state = 0
- self.next_ai_state = nil
- self.startWork = nil
- self.stopWork = nil
- self.abortWork = nil
- self.wait = true
- self.waitTimer = nil
- self.realistic_driving = true
-
- self.cp_directory = cp_directory
-
- -- our arrow is displaying dirction to waypoints
- self.ArrowPath = Utils.getFilename("img/arrow.dds", self.cp_directory);
- self.ArrowOverlay = Overlay:new("Arrow", self.ArrowPath, 0.4, 0.08, 0.250, 0.250);
- --self.ArrowOverlay:render()
-
- -- kegel der route
- local baseDirectory = getAppBasePath()
- local i3dNode = Utils.loadSharedI3DFile("data/maps/models/objects/egg/egg.i3d", baseDirectory)
- local itemNode = getChildAt(i3dNode, 0)
- link(getRootNode(), itemNode)
- setRigidBodyType(itemNode, "NoRigidBody")
- setTranslation(itemNode, 0, 0, 0)
- setVisibility(itemNode, false)
- delete(i3dNode)
- self.sign = itemNode
-
- local i3dNode2 = Utils.loadSharedI3DFile("img/NurGerade/NurGerade.i3d", self.cp_directory)
- local itemNode2 = getChildAt(i3dNode2, 0)
- link(getRootNode(), itemNode2)
- setRigidBodyType(itemNode2, "NoRigidBody")
- setTranslation(itemNode2, 0, 0, 0)
- setVisibility(itemNode2, false)
- delete(i3dNode2)
- self.start_sign = itemNode2
-
- local i3dNode3 = Utils.loadSharedI3DFile("img/STOP/STOP.i3d", self.cp_directory)
- local itemNode3 = getChildAt(i3dNode3, 0)
- link(getRootNode(), itemNode3)
- setRigidBodyType(itemNode3, "NoRigidBody")
- setTranslation(itemNode3, 0, 0, 0)
- setVisibility(itemNode3, false)
- delete(i3dNode3)
- self.stop_sign = itemNode3
-
- local i3dNode4 = Utils.loadSharedI3DFile("img/VorfahrtAnDieserKreuzung/VorfahrtAnDieserKreuzung.i3d", self.cp_directory)
- local itemNode4 = getChildAt(i3dNode4, 0)
- link(getRootNode(), itemNode4)
- setRigidBodyType(itemNode4, "NoRigidBody")
- setTranslation(itemNode4, 0, 0, 0)
- setVisibility(itemNode4, false)
- delete(i3dNode4)
- self.cross_sign = itemNode4
-
- local i3dNode5 = Utils.loadSharedI3DFile("img/Parkplatz/Parkplatz.i3d", self.cp_directory)
- local itemNode5 = getChildAt(i3dNode5, 0)
- link(getRootNode(), itemNode5)
- setRigidBodyType(itemNode5, "NoRigidBody")
- setTranslation(itemNode5, 0, 0, 0)
- setVisibility(itemNode5, false)
- delete(i3dNode5)
- self.wait_sign = itemNode5
-
- -- visual waypoints saved in this
- self.signs = {}
- courseplay:RefreshGlobalSigns(self) -- Global Signs Crosspoints
-
- self.workMarkerLeft = clone(self.sign, true)
- setVisibility(self.workMarkerLeft, false)
- self.workMarkerRight = clone(self.sign, true)
- setVisibility(self.workMarkerRight, false)
-
- -- course name for saving
- self.current_course_name = nil
- self.courseID = 0
- -- array for multiple courses
- self.loaded_courses = {}
- self.direction = false
- -- forced waypoints
- self.target_x = nil
- self.target_y = nil
- self.target_z = nil
-
- self.next_targets = {}
-
- -- speed limits
- self.max_speed_level = nil
- self.max_speed = 50 / 3600 -- >5
- self.turn_speed = 10 / 3600 -- >5
- self.field_speed = 24 / 3600 -- >5
- self.unload_speed = 6 / 3600 -- >3
- self.sl = 3
- self.tools_dirty = false
-
- self.orgRpm = nil;
-
- -- Course list
- self.courseListPrev = false;
- self.courseListNext = table.getn(g_currentMission.courseplay_courses) > 5;
-
-
-
- -- traffic collision
- self.onTrafficCollisionTrigger = courseplay.cponTrafficCollisionTrigger;
- --self.aiTrafficCollisionTrigger = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.aiTrafficCollisionTrigger#index"));
- self.steering_angle = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.wheels.wheel(1)" .. "#rotMax"), 30)
-
- self.CPnumCollidingVehicles = 0;
- -- self.numToolsCollidingVehicles = {};
- -- self.trafficCollisionIgnoreList = {};
- self.cpTrafficCollisionIgnoreList = {};
- -- for k,v in pairs(self.components) do
- -- self.trafficCollisionIgnoreList[v.node] = true;
- -- end;
- self.cpTrafficBrake = false
- -- tipTrigger
- self.findTipTriggerCallback = courseplay.findTipTriggerCallback;
-
-
- -- tippers
- self.tippers = {}
- self.tipper_attached = false
- self.currentTrailerToFill = nil
- self.lastTrailerToFillDistance = nil
- self.unloaded = false
- self.loaded = false
- self.unloading_tipper = nil
- self.last_fill_level = nil
- self.tipRefOffset = 0;
- self.cp.tipperHasCover = false;
- self.cp.tippersWithCovers = {};
-
- -- for user input like saving
- self.user_input_active = false
- self.user_input_message = nil
- self.user_input = nil
- self.save_name = false
-
-
- self.selected_course_number = 0
- self.course_Del = false
-
- -- combines
- self.reachable_combines = {}
- self.active_combine = nil
-
- self.combine_offset = 0.0
- self.tipper_offset = 0.0
-
- self.forced_side = nil
- self.forced_to_stop = false
-
- self.allow_following = false
- self.required_fill_level_for_follow = 50
- self.required_fill_level_for_drive_on = 90
-
- self.turn_factor = nil
- self.turn_radius = 10;
- self.autoTurnRadius = 10;
- self.turnRadiusAutoMode = true;
-
- self.WpOffsetX = 0
- self.WpOffsetZ = 0
- self.toolWorkWidht = 3
- self.createCourse = false
- -- loading saved courses from xml
-
- self.search_combine = true
- self.saved_combine = nil
- self.selected_combine_number = 0
-
- self.mouse_enabled = false
-
- -- HUD -- Function in Signs
- self.hudInfoBaseWidth = 0.512; --try: 512/1920
- self.hudInfoBaseHeight = 0.512; --try: 512/1080
-
- self.infoPanelPath = Utils.getFilename("img/hud_bg.dds", self.cp_directory);
- self.hudInfoBaseOverlay = Overlay:new("hudInfoBaseOverlay", self.infoPanelPath, courseplay.hud.infoBasePosX - 10/1920, courseplay.hud.infoBasePosY - 10/1920, courseplay.hud.infoBaseWidth, courseplay.hud.infoBaseHeight);
-
- self.min_hud_page = 1
- if courseplay:is_a_combine(self) then
- self.min_hud_page = 0
- end
-
- self.showHudInfoBase = self.min_hud_page;
-
- self.hudpage = {}
- self.hudpage[0] = {}
- self.hudpage[0][1] = {}
- self.hudpage[0][2] = {}
- self.hudpage[0][3] = {}
- self.hudpage[0][4] = {}
- self.hudpage[1] = {}
- self.hudpage[1][1] = {}
- self.hudpage[1][2] = {}
- self.hudpage[2] = {}
- self.hudpage[2][1] = {}
- self.hudpage[2][2] = {}
- self.hudpage[3] = {}
- self.hudpage[3][1] = {}
- self.hudpage[3][2] = {}
- self.hudpage[4] = {}
- self.hudpage[4][1] = {}
- self.hudpage[4][2] = {}
- self.hudpage[5] = {}
- self.hudpage[5][1] = {}
- self.hudpage[5][2] = {}
- self.hudpage[6] = {}
- self.hudpage[6][1] = {}
- self.hudpage[6][2] = {}
-
- self.hudpage[7] = {}
- self.hudpage[7][1] = {}
- self.hudpage[7][2] = {}
-
- local w16px = 16/1920;
- local h16px = 16/1080;
- local w24px = 24/1920;
- local h24px = 24/1080;
-
- self.hudinfo = {}
-
- self.show_hud = false
-
- -- buttons for hud
- courseplay:register_button(self, nil, "navigate_left.dds", "switch_hud_page", -1, courseplay.hud.infoBasePosX + 0.035, courseplay.hud.infoBasePosY + 0.2395, w24px, h24px); --ORIG: +0.242
- courseplay:register_button(self, nil, "navigate_right.dds", "switch_hud_page", 1, courseplay.hud.infoBasePosX + 0.280, courseplay.hud.infoBasePosY + 0.2395, w24px, h24px);
-
-
- courseplay:register_button(self, nil, "close.dds", "close_hud", 1, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.infoBasePosY + 0.255, w24px, h24px);
-
- courseplay:register_button(self, nil, "disk.dds", "save_course", 1, courseplay.hud.infoBasePosX + 0.280, courseplay.hud.infoBasePosY + 0.056, w24px, h24px);
-
- --Page 0
- courseplay:register_button(self, 0, "blank.dds", "row1", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[1], 0.32, 0.015);
- courseplay:register_button(self, 0, "blank.dds", "row2", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[2], 0.32, 0.015);
- courseplay:register_button(self, 0, "blank.dds", "row3", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[3], 0.32, 0.015);
- courseplay:register_button(self, 0, "blank.dds", "row4", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[4], 0.32, 0.015);
-
- --Page 1
- courseplay:register_button(self, 1, "blank.dds", "row1", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[1], 0.32, 0.015);
- courseplay:register_button(self, 1, "blank.dds", "row2", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[2], 0.32, 0.015);
- courseplay:register_button(self, 1, "blank.dds", "row3", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[3], 0.32, 0.015);
- courseplay:register_button(self, 1, "blank.dds", "row4", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[4], 0.32, 0.015);
- courseplay:register_button(self, 1, "blank.dds", "row5", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[5], 0.32, 0.015);
- courseplay:register_button(self, 1, "blank.dds", "change_DriveDirection", 1, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[5], 0.32, 0.015);
-
- --Page 2
- courseplay:register_button(self, 2, "blank.dds", "row1", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[1], 0.32, 0.015);
- courseplay:register_button(self, 2, "blank.dds", "row2", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[2], 0.32, 0.015);
- courseplay:register_button(self, 2, "blank.dds", "row3", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[3], 0.32, 0.015);
-
- courseplay:register_button(self, 2, "navigate_up.dds", "change_selected_course", -5, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesPosY[1], w24px, h24px, nil, -10, "self.courseListPrev=true");
- courseplay:register_button(self, 2, "navigate_down.dds", "change_selected_course", 5, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesPosY[5], w24px, h24px, nil, 10, "self.courseListNext=true");
-
- for i = 1, 5, 1 do
- local posy = courseplay.hud.infoBasePosY + 0.205 - (i - 1) * 0.021
- courseplay:register_button(self, -2, "folder.dds", "load_course", i, courseplay.hud.infoBasePosX + 0.212, courseplay.hud.linesButtonPosY[i], w16px, h16px, i);
- courseplay:register_button(self, -2, "folder_into.dds", "add_course", i, courseplay.hud.infoBasePosX + 0.235, courseplay.hud.linesButtonPosY[i], w16px, h16px, i);
- if g_server ~= nil then
- courseplay:register_button(self, -2, "delete.dds", "clear_course", i, courseplay.hud.infoBasePosX + 0.258, courseplay.hud.linesButtonPosY[i], w16px, h16px, i);
- end
- end
-
- --Page 3
- courseplay:register_button(self, 3, "navigate_minus.dds", "change_combine_offset", -0.1, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[1], w16px, h16px, nil, -0.5);
- courseplay:register_button(self, 3, "navigate_plus.dds", "change_combine_offset", 0.1, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[1], w16px, h16px, nil, 0.5);
-
- courseplay:register_button(self, 3, "navigate_minus.dds", "change_tipper_offset", -0.1, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[2], w16px, h16px, nil, -0.5);
- courseplay:register_button(self, 3, "navigate_plus.dds", "change_tipper_offset", 0.1, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[2], w16px, h16px, nil, 0.5);
-
- courseplay:register_button(self, 3, "navigate_minus.dds", "change_turn_radius", -1, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[3], w16px, h16px, nil, -5);
- courseplay:register_button(self, 3, "navigate_plus.dds", "change_turn_radius", 1, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[3], w16px, h16px, nil, 5);
-
- courseplay:register_button(self, 3, "navigate_minus.dds", "change_required_fill_level", -5, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[4], w16px, h16px, nil, -10);
- courseplay:register_button(self, 3, "navigate_plus.dds", "change_required_fill_level", 5, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[4], w16px, h16px, nil, 10);
-
- courseplay:register_button(self, 3, "navigate_minus.dds", "change_required_fill_level_for_drive_on", -5, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[5], w16px, h16px, nil, -10);
- courseplay:register_button(self, 3, "navigate_plus.dds", "change_required_fill_level_for_drive_on", 5, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[5], w16px, h16px, nil, 10);
-
- --Page 4
- courseplay:register_button(self, 4, "navigate_up.dds", "switch_combine", -1, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[1], w16px, h16px);
- courseplay:register_button(self, 4, "navigate_down.dds", "switch_combine", 1, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[1], w16px, h16px);
-
- --courseplay:register_button(self, 4, "navigate_minus.dds", "change_num_ai_helpers", -1, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[4], w16px, h16px);
- --courseplay:register_button(self, 4, "navigate_plus.dds", "change_num_ai_helpers", 1, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[4], w16px, h16px);
-
- courseplay:register_button(self, 4, "blank.dds", "switch_search_combine", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[2], 0.32, 0.015);
-
- --Page 5
- courseplay:register_button(self, 5, "navigate_minus.dds", "change_turn_speed", -1, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[1], w16px, h16px, nil, -5);
- courseplay:register_button(self, 5, "navigate_plus.dds", "change_turn_speed", 1, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[1], w16px, h16px, nil, 5);
-
- courseplay:register_button(self, 5, "navigate_minus.dds", "change_field_speed", -1, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[2], w16px, h16px, nil, -5);
- courseplay:register_button(self, 5, "navigate_plus.dds", "change_field_speed", 1, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[2], w16px, h16px, nil, 5);
-
- courseplay:register_button(self, 5, "navigate_minus.dds", "change_max_speed", -1, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[3], w16px, h16px, nil, -5, "self.use_speed=false");
- courseplay:register_button(self, 5, "navigate_plus.dds", "change_max_speed", 1, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[3], w16px, h16px, nil, 5, "self.use_speed=false");
-
- courseplay:register_button(self, 5, "navigate_minus.dds", "change_unload_speed", -1, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[4], w16px, h16px, nil, -5);
- courseplay:register_button(self, 5, "navigate_plus.dds", "change_unload_speed", 1, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[4], w16px, h16px, nil, 5);
-
- courseplay:register_button(self, 5, "blank.dds", "change_use_speed", 1, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[5], 0.32, 0.015);
-
- --Page 6
- courseplay:register_button(self, 6, "blank.dds", "switch_realistic_driving", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[1], 0.32, 0.015);
- courseplay:register_button(self, 6, "blank.dds", "mouse_right_key", nil, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[2], 0.32, 0.015);
- courseplay:register_button(self, 6, "blank.dds", "change_WaypointMode", 1, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[3], 0.32, 0.015);
- courseplay:register_button(self, 6, "blank.dds", "change_RulMode", 1, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[4], 0.32, 0.015);
- courseplay:register_button(self, 6, "blank.dds", "change_DebugLevel", 1, courseplay.hud.infoBasePosX - 0.05, courseplay.hud.linesPosY[5], 0.32, 0.015);
-
- --Page 7: FAHR-Arbeitseinstellungen
- courseplay:register_button(self, 7, "navigate_minus.dds", "change_wait_time", -5, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[1], w16px, h16px, nil, -10);
- courseplay:register_button(self, 7, "navigate_plus.dds", "change_wait_time", 5, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[1], w16px, h16px, nil, 10);
-
- courseplay:register_button(self, 7, "navigate_minus.dds", "changeWpOffsetX", -0.5, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[2], w16px, h16px, nil, -1);
- courseplay:register_button(self, 7, "navigate_plus.dds", "changeWpOffsetX", 0.5, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[2], w16px, h16px, nil, 1);
-
- courseplay:register_button(self, 7, "navigate_minus.dds", "changeWpOffsetZ", -0.5, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[3], w16px, h16px, nil, -1);
- courseplay:register_button(self, 7, "navigate_plus.dds", "changeWpOffsetZ", 0.5, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[3], w16px, h16px, nil, 1);
-
- courseplay:register_button(self, 7, "navigate_minus.dds", "changeWorkWidth", -0.1, courseplay.hud.infoBasePosX + 0.285, courseplay.hud.linesButtonPosY[4], w16px, h16px, nil, -0.5);
- courseplay:register_button(self, 7, "navigate_plus.dds", "changeWorkWidth", 0.1, courseplay.hud.infoBasePosX + 0.300, courseplay.hud.linesButtonPosY[4], w16px, h16px, nil, 0.5);
-
-
-
-
-
- self.fold_move_direction = 1;
-
- register_courseplay();
-end
-
-
-function courseplay:onLeave()
- if self.mouse_enabled then
- InputBinding.setShowMouseCursor(false);
- end
-end
-
-function courseplay:onEnter()
- if self.mouse_enabled then
- InputBinding.setShowMouseCursor(true);
- end
-end
-
--- displays help text, user_input
-function courseplay:draw()
- courseplay:loadHud(self)
-
- if self.dcheck and table.getn(self.Waypoints) > 1 then
- courseplay:dcheck(self);
- end
-
- if self.workWidthChanged > self.timer then
- courseplay:show_work_witdh(self)
- elseif self.work_with_shown then
- --setVisibility(self.workMarkerRight, false)
- --setVisibility(self.workMarkerLeft, false)
- self.work_with_shown = false
- end
-
- if self.mouse_enabled then
- InputBinding.setShowMouseCursor(self.mouse_enabled)
- end
-
- courseplay:showHud(self)
-end
-
---[[
-function courseplay:show_work_witdh_OLD(self)
-
- local x, y, z = getWorldTranslation(self.rootNode)
- setTranslation(self.workMarkerRight, localToWorld(self.rootNode, self.toolWorkWidht / 2, 3, -4))
- setTranslation(self.workMarkerLeft, localToWorld(self.rootNode, self.toolWorkWidht * -1 / 2, 3, -4))
- setVisibility(self.workMarkerRight, true)
- setVisibility(self.workMarkerLeft, true)
- self.work_with_shown = true
-end
-]]
-
-function courseplay:show_work_witdh(self)
- local x, y, z = getWorldTranslation(self.rootNode)
- local pointLx, pointLy, pointLz = localToWorld(self.rootNode, self.toolWorkWidht * 0.5, 1, -6);
- local pointRx, pointRy, pointRz = localToWorld(self.rootNode, self.toolWorkWidht * -0.5, 1, -6);
- drawDebugPoint(pointLx, pointLy, pointLz, 1, 1, 0, 1);
- drawDebugPoint(pointRx, pointRy, pointRz, 1, 1, 0, 1);
- drawDebugLine(pointLx, pointLy, pointLz, 1, 0, 0, pointRx, pointRy, pointRz, 1, 0, 0);
- self.work_with_shown = true
-end
--- is been called everey frame
-function courseplay:update(dt)
- if self:getIsActive() then
- if InputBinding.isPressed(InputBinding.CP_Modifier_1) and not self.mouse_right_key_enabled then
- if self.show_hud then
- g_currentMission:addHelpButtonText(g_i18n:getText("CPHudClose"), InputBinding.CP_Hud)
- elseif not self.show_hud then
- g_currentMission:addHelpButtonText(g_i18n:getText("CPHudOpen"), InputBinding.CP_Hud)
- end
- end
-
- -- inspired by knagsted's 8400 MouseOverride
- if InputBinding.hasEvent(InputBinding.CP_Hud) and InputBinding.isPressed(InputBinding.CP_Modifier_1) and self.isEntered and not self.mouse_right_key_enabled then
- if self.mouse_enabled then
- self.mouse_enabled = false
- if self.show_hud then
- self.show_hud = false
- end
- else
- self.mouse_enabled = true
- if not self.show_hud then
- self.showHudInfoBase = self.min_hud_page
- self.show_hud = true
- end
- end
- InputBinding.setShowMouseCursor(self.mouse_enabled)
- end
-
- if InputBinding.hasEvent(InputBinding.CP_Hud) and InputBinding.isPressed(InputBinding.CP_Modifier_2) and self.isEntered then
- initialize_courseplay()
- end
- end
-
- if self.isEntered then
-
- if self.user_input_active == true then
- if self.currentGui == nil then
- g_gui:loadGui(Utils.getFilename("emptyGui.xml", self.cp_directory), self.input_gui);
- g_gui:showGui(self.input_gui);
- self.currentGui = self.input_gui
- end
-
- for unicode, isDown in pairs(Input.keyPressedState) do
- if isDown then
- self:setCourseplayFunc("key_input", unicode)
- end
- end
- Input.keyPressedState = {};
- else
- if self.currentGui == self.input_gui then
- g_gui:showGui("");
- self.currentGui = nil
- end
- end
-
- if self.user_input_message then
- courseplay:user_input(self);
- end
- end
-
-
- courseplay:infotext(self);
-
-
- -- we are in record mode
- if self.record then
- courseplay:record(self);
- end
-
- -- we are in drive mode
- if self.drive then
- courseplay:drive(self, dt);
- end
-end
-
-function courseplay:updateTick(dt)
- --attached or detached implement?
- if self.tools_dirty then
- courseplay:reset_tools(self)
- end
-
- -- show visual waypoints only when in vehicle
- if self.isEntered and self.waypointMode ~= 5 then
- courseplay:sign_visibility(self, true)
- else
- courseplay:sign_visibility(self, false);
- end
-
- self.timer = self.timer + dt
- --courseplay:debug(string.format("timer: %f", self.timer ), 2)
-end
-
-function courseplay:delete()
- if self.aiTrafficCollisionTrigger ~= nil then
- removeTrigger(self.aiTrafficCollisionTrigger);
- end
-end;
-
-function courseplay:set_timeout(self, interval)
- self.timeout = self.timer + interval
-end
-
-
-function courseplay:get_locale(self, key)
- if courseplay.locales[key] ~= nil then
- return courseplay.locales[key];
- else
- return key;
- end;
-end
-
-
-function courseplay:readStream(streamId, connection)
- courseplay:debug("reading stream", 4)
-
-
- self.abortWork = streamDebugReadInt32(streamId)
- self.ai_mode = streamDebugReadInt32(streamId)
- self.ai_state = streamDebugReadInt32(streamId)
- self.allow_following = streamDebugReadBool(streamId)
- self.autoTurnRadius = streamDebugReadFloat32(streamId)
- self.combine_offset = streamDebugReadFloat32(streamId)
- self.courseListPrev = streamDebugReadBool(streamId)
- self.courseListNext = streamDebugReadBool(streamId)
- self.courseplay_position = streamDebugReadInt32(streamId)
- self.CPnumCollidingVehicles = streamDebugReadInt32(streamId)
- self.cpTrafficBrake = streamDebugReadBool(streamId)
- self.cp.tipperHasCover = streamDebugReadBool(streamId);
- self.crossPoints = streamDebugReadInt32(streamId)
- self.drive = streamDebugReadBool(streamId)
- self.drive_slow_timer = streamDebugReadInt32(streamId)
- self.field_speed = streamDebugReadFloat32(streamId)
- self.fold_move_direction = streamDebugReadInt32(streamId)
- self.follow_mode = streamDebugReadInt32(streamId)
- self.forced_side = streamDebugReadString(streamId)
- self.forced_to_stop = streamDebugReadBool(streamId)
- self.global_info_text = streamDebugReadString(streamId)
- self.info_text = streamDebugReadString(streamId)
- self.lastTrailerToFillDistance = streamDebugReadFloat32(streamId)
- self.last_fill_level = streamDebugReadInt32(streamId)
- self.loopCounter = streamDebugReadInt32(streamId)
- self.max_speed = streamDebugReadFloat32(streamId)
- self.mouse_enabled = streamDebugReadBool(streamId)
- self.mouse_right_key_enabled = streamDebugReadBool(streamId)
- self.next_ai_state = streamDebugReadInt32(streamId)
- self.play = streamDebugReadBool(streamId)
- self.recordnumber = streamDebugReadInt32(streamId)
- self.required_fill_level_for_drive_on = streamDebugReadFloat32(streamId)
- self.required_fill_level_for_follow = streamDebugReadFloat32(streamId)
- self.runOnceStartCourse = streamDebugReadBool(streamId)
- self.save_name = streamDebugReadBool(streamId)
- self.search_combine = streamDebugReadBool(streamId)
- self.selected_combine_number = streamDebugReadInt32(streamId)
- self.selected_course_number = streamDebugReadInt32(streamId)
- self.shortest_dist = streamDebugReadFloat32(streamId) -- 20.
- self.showHudInfoBase = streamDebugReadInt32(streamId)
- self.show_hud = streamDebugReadBool(streamId)
- self.sl = streamDebugReadInt32(streamId)
- self.startWork = streamDebugReadInt32(streamId)
- self.stopWork = streamDebugReadInt32(streamId)
- self.target_x = streamDebugReadFloat32(streamId)
- self.target_y = streamDebugReadFloat32(streamId)
- self.target_z = streamDebugReadFloat32(streamId)
- self.timeout = streamDebugReadInt32(streamId)
- self.timer = streamDebugReadFloat32(streamId)
- self.tipper_attached = streamDebugReadBool(streamId)
- self.tipper_offset = streamDebugReadFloat32(streamId)
- self.tipRefOffset = streamDebugReadFloat32(streamId)
- self.tmr = streamDebugReadInt32(streamId)
- self.turnRadiusAutoMode = streamDebugReadBool(streamId);
- self.turn_radius = streamDebugReadFloat32(streamId)
- self.turn_speed = streamDebugReadFloat32(streamId)
- self.unloaded = streamDebugReadBool(streamId) -- 40.
- self.unload_speed = streamDebugReadFloat32(streamId)
- self.user_input = streamDebugReadString(streamId)
- self.user_input_active = streamDebugReadBool(streamId)
- self.user_input_message = streamDebugReadString(streamId)
- self.use_speed = streamDebugReadBool(streamId)
- self.wait = streamDebugReadBool(streamId)
- self.waitPoints = streamDebugReadInt32(streamId)
- self.waitTime = streamDebugReadInt32(streamId)
- self.waitTimer = streamDebugReadInt32(streamId)
- self.working_course_player_num = streamDebugReadInt32(streamId)
- self.WpOffsetX = streamDebugReadFloat32(streamId)
- self.WpOffsetZ = streamDebugReadFloat32(streamId)
-
- local saved_combine_id = streamDebugReadInt32(streamId)
- if saved_combine_id then
- self.saved_combine = networkGetObject(saved_combine_id)
- end
- if self.drive then
- self.orgRpm = {}
- self.orgRpm[1] = self.motor.maxRpm[1]
- self.orgRpm[2] = self.motor.maxRpm[2]
- self.orgRpm[3] = self.motor.maxRpm[3]
- end
- local active_combine_id = streamDebugReadInt32(streamId)
- if active_combine_id then
- self.active_combine = networkGetObject(active_combine_id)
- end
-
- local current_trailer_id = streamDebugReadInt32(streamId)
- if current_trailer_id then
- self.currentTrailerToFill = networkGetObject(current_trailer_id)
- end
-
- local unloading_tipper_id = streamDebugReadInt32(streamId)
- if unloading_tipper_id then
- self.unloading_tipper = networkGetObject(unloading_tipper_id)
- end
-
- courseplay:reinit_courses(self)
-
-
- -- kurs daten
- local courses = streamDebugReadString(streamId) -- 60.
-
-
-
- if courses ~= nil then
- self.loaded_courses = courses:split(",")
- courseplay:reload_courses(self, true)
- end
-end
-
-function courseplay:writeStream(streamId, connection)
- courseplay:debug("writing stream", 4)
-
- streamDebugWriteInt32(streamId,self.abortWork)
- streamDebugWriteInt32(streamId,self.ai_mode)
- streamDebugWriteInt32(streamId,self.ai_state)
- streamDebugWriteBool(streamId, self.allow_following)
- streamDebugWriteFloat32(streamId,self.autoTurnRadius)
- streamDebugWriteFloat32(streamId,self.combine_offset)
- streamDebugWriteBool(streamId, self.courseListPrev)
- streamDebugWriteBool(streamId, self.courseListNext)
- streamDebugWriteInt32(streamId,self.courseplay_position)
- streamDebugWriteInt32(streamId,self.CPnumCollidingVehicles)
- streamDebugWriteBool(streamId, self.cpTrafficBrake)
- streamDebugWriteBool(streamId, self.cp.tipperHasCover);
- streamDebugWriteInt32(streamId, self.crossPoints);
- streamDebugWriteBool(streamId,self.drive)
- streamDebugWriteInt32(streamId,self.drive_slow_timer)
- streamDebugWriteFloat32(streamId,self.field_speed)
- streamDebugWriteInt32(streamId,self.fold_move_direction)
- streamDebugWriteInt32(streamId,self.follow_mode)
- streamDebugWriteString(streamId,self.forced_side)
- streamDebugWriteBool(streamId,self.forced_to_stop)
- streamDebugWriteString(streamId,self.global_info_text)
- streamDebugWriteString(streamId,self.info_text)
- streamDebugWriteInt32(streamId,self.last_fill_level)
- streamDebugWriteFloat32(streamId,self.lastTrailerToFillDistance)
- streamDebugWriteBool(streamId,self.loaded)
- streamDebugWriteFloat32(streamId,self.max_speed)
- streamDebugWriteBool(streamId,self.mouse_enabled)
- streamDebugWriteBool(streamId,self.mouse_right_key_enabled)
- streamDebugWriteInt32(streamId,self.next_ai_state)
- streamDebugWriteBool(streamId,self.play)
- streamDebugWriteInt32(streamId,self.recordnumber)
- streamDebugWriteFloat32(streamId,self.required_fill_level_for_drive_on)
- streamDebugWriteFloat32(streamId,self.required_fill_level_for_follow)
- streamDebugWriteBool(streamId, self.runOnceStartCourse)
- streamDebugWriteBool(streamId,self.save_name)
- streamDebugWriteBool(streamId,self.search_combine)
- streamDebugWriteInt32(streamId,self.selected_combine_number)
- streamDebugWriteInt32(streamId,self.selected_course_number)
- streamDebugWriteFloat32(streamId,self.shortest_dist)
- streamDebugWriteBool(streamId,self.show_hud)
- streamDebugWriteInt32(streamId,self.showHudInfoBase)
- streamDebugWriteInt32(streamId,self.sl)
- streamDebugWriteInt32(streamId,self.startWork)
- streamDebugWriteInt32(streamId,self.stopWork)
- streamDebugWriteFloat32(streamId,self.target_x)
- streamDebugWriteFloat32(streamId,self.target_y)
- streamDebugWriteFloat32(streamId,self.target_z)
- streamDebugWriteInt32(streamId,self.timeout)
- streamDebugWriteFloat32(streamId,self.timer)
- streamDebugWriteBool(streamId,self.tipper_attached)
- streamDebugWriteFloat32(streamId,self.tipper_offset)
- streamDebugWriteFloat32(streamId,self.tipRefOffset)
- streamDebugWriteInt32(streamId,self.tmr)
- streamDebugWriteFloat32(streamId,self.turn_radius)
- streamDebugWriteFloat32(streamId,self.turn_speed)
- streamDebugWriteBool(streamId,self.turnRadiusAutoMode)
- streamDebugWriteFloat32(streamId,self.unload_speed)
- streamDebugWriteBool(streamId,self.unloaded)
- streamDebugWriteBool(streamId,self.use_speed)
- streamDebugWriteString(streamId,self.user_input)
- streamDebugWriteBool(streamId,self.user_input_active)
- streamDebugWriteString(streamId,self.user_input_message)
- streamDebugWriteBool(streamId,self.wait)
- streamDebugWriteInt32(streamId,self.waitPoints)
- streamDebugWriteInt32(streamId,self.waitTime)
- streamDebugWriteInt32(streamId,self.waitTimer)
- streamDebugWriteInt32(streamId,self.working_course_player_num)
- streamDebugWriteFloat32(streamId,self.WpOffsetX)
- streamDebugWriteFloat32(streamId,self.WpOffsetZ)
-
- local saved_combine_id = nil
- if self.saved_combine ~= nil then
- saved_combine_id = networkGetObject(self.saved_combine)
- end
- streamDebugWriteInt32(streamId, saved_combine_id)
-
- local active_combine_id = nil
- if self.active_combine ~= nil then
- active_combine_id = networkGetObject(self.active_combine)
- end
- streamDebugWriteInt32(streamId, active_combine_id)
-
- local current_trailer_id = nil
- if self.currentTrailerToFill ~= nil then
- current_trailer_id = networkGetObject(self.currentTrailerToFill)
- end
- streamDebugWriteInt32(streamId, current_trailer_id)
-
- local unloading_tipper_id = nil
- if self.unloading_tipper ~= nil then
- unloading_tipper_id = networkGetObject(self.unloading_tipper)
- end
- streamDebugWriteInt32(streamId, unloading_tipper_id)
-
- local loaded_courses = nil
- if table.getn(self.loaded_courses) then
- loaded_courses = table.concat(self.loaded_courses, ",")
- end
- streamDebugWriteString(streamId, loaded_courses) -- 60.
-end
-
-
-function courseplay:loadFromAttributesAndNodes(xmlFile, key, resetVehicles)
- if not resetVehicles and g_server ~= nil then
- self.max_speed = Utils.getNoNil(getXMLFloat(xmlFile, key .. string.format("#max_speed")), 50 / 3600);
- self.use_speed = Utils.getNoNil(getXMLBool(xmlFile, key .. string.format("#use_speed")), false);
- self.turn_speed = Utils.getNoNil(getXMLFloat(xmlFile, key .. string.format("#turn_speed")), 10 / 3600);
- self.field_speed = Utils.getNoNil(getXMLFloat(xmlFile, key .. string.format("#field_speed")), 24 / 3600);
- self.unload_speed = Utils.getNoNil(getXMLFloat(xmlFile, key .. string.format("#unload_speed")), 6 / 3600);
- self.realistic_driving = Utils.getNoNil(getXMLBool(xmlFile, key .. string.format("#realistic_driving")), true);
- self.tipper_offset = Utils.getNoNil(getXMLFloat(xmlFile, key .. string.format("#tipper_offset")), 0);
- self.combine_offset = Utils.getNoNil(getXMLFloat(xmlFile, key .. string.format("#combine_offset")), 0);
-
- self.required_fill_level_for_follow = Utils.getNoNil(getXMLInt(xmlFile, key .. string.format("#fill_follow")), 50);
- self.required_fill_level_for_drive_on = Utils.getNoNil(getXMLInt(xmlFile, key .. string.format("#fill_drive")), 90);
- self.WpOffsetX = Utils.getNoNil(getXMLFloat(xmlFile, key .. string.format("#OffsetX")), 0);
- self.mouse_right_key_enabled = Utils.getNoNil(getXMLFloat(xmlFile, key .. string.format("#mouse_right_key_enabled")), true);
- self.WpOffsetZ = Utils.getNoNil(getXMLFloat(xmlFile, key .. string.format("#OffsetZ")), 0);
- self.waitTime = Utils.getNoNil(getXMLFloat(xmlFile, key .. string.format("#waitTime")), 0);
- self.abortWork = Utils.getNoNil(getXMLInt(xmlFile, key .. string.format("#AbortWork")), nil);
- self.turn_radius = Utils.getNoNil(getXMLInt(xmlFile, key .. string.format("#turn_radius")), 10);
- self.RulMode = Utils.getNoNil(getXMLInt(xmlFile, key .. string.format("#rul_mode")), 1);
- local courses = Utils.getNoNil(getXMLString(xmlFile, key .. string.format("#courses")), "");
- self.toolWorkWidht = Utils.getNoNil(getXMLFloat(xmlFile, key .. string.format("#toolWorkWidht")), 3);
- self.loaded_courses = courses:split(",")
- self.selected_course_number = 0
-
- courseplay:reload_courses(self, true)
-
- self.ai_mode = Utils.getNoNil(getXMLInt(xmlFile, key .. string.format("#ai_mode")), 1);
-
- if self.abortWork == 0 then
- self.abortWork = nil
- end
- end
- return BaseMission.VEHICLE_LOAD_OK;
-end
-
-
-function courseplay:getSaveAttributesAndNodes(nodeIdent)
-
- local attributes =
- ' max_speed="' .. tostring(self.max_speed) .. '"' ..
- ' use_speed="' .. tostring(self.use_speed) .. '"' ..
- ' turn_speed="' .. tostring(self.turn_speed) .. '"' ..
- ' field_speed="' .. tostring(self.field_speed) .. '"' ..
- ' unload_speed="' .. tostring(self.unload_speed) .. '"' ..
- ' tipper_offset="' .. tostring(self.tipper_offset) .. '"' ..
- ' combine_offset="' .. tostring(self.combine_offset) .. '"' ..
- ' fill_follow="' .. tostring(self.required_fill_level_for_follow) .. '"' ..
- ' fill_drive="' .. tostring(self.required_fill_level_for_drive_on) .. '"' ..
- ' OffsetX="' .. tostring(self.WpOffsetX) .. '"' ..
- ' OffsetZ="' .. tostring(self.WpOffsetZ) .. '"' ..
- ' AbortWork="' .. tostring(self.abortWork) .. '"' ..
- ' turn_radius="' .. tostring(self.turn_radius) .. '"' ..
- ' waitTime="' .. tostring(self.waitTime) .. '"' ..
- ' courses="' .. tostring(table.concat(self.loaded_courses, ",")) .. '"' ..
- ' mouse_right_key_enabled="' .. tostring(self.mouse_right_key_enabled) .. '"' ..
- ' rul_mode="'..tostring(self.RulMode) .. '"' ..
- ' toolWorkWidht="'..tostring(self.toolWorkWidht) .. '"' ..
- ' realistic_driving="'..tostring(self.realistic_driving) .. '"' ..
- ' ai_mode="' .. tostring(self.ai_mode) .. '"';
- return attributes, nil;
-end
-
-
-function string:split(sep)
- local sep, fields = sep or ":", {}
- local pattern = string.format("([^%s]+)", sep)
- self:gsub(pattern, function(c) fields[#fields + 1] = c end)
- return fields
-end
-
-function roundCustom(number, numDecimals)
- local positiveNegative = 1
- if number < 0 then positiveNegative = -1 end
-
- local mult = 10^(numDecimals or 0)
- --local mult = math.pow(10, numDecimals or 0)
- return math.floor(number*positiveNegative * mult + 0.5) / mult * positiveNegative
-end
-
diff --git a/button.lua b/button.lua
deleted file mode 100644
index 2485e7dc7..000000000
--- a/button.lua
+++ /dev/null
@@ -1,62 +0,0 @@
-function courseplay:register_button(self, hud_page, img, function_to_call, parameter, x, y, width, height, hud_row, modifiedParameter, showHideVariable)
- local overlay_path = Utils.getFilename("img/" .. img, self.cp_directory);
- local overlay = Overlay:new(img, overlay_path, x, y, width, height);
-
- button = {
- page = hud_page,
- overlay = overlay,
- function_to_call = function_to_call,
- parameter = parameter,
- x = x,
- x2 = (x + width),
- y = y,
- y2 = (y + height),
- row = hud_row
- };
- if modifiedParameter then
- button.modifiedParameter = modifiedParameter;
- end
-
- --NOTE: showHideVariable MUST be in self namespace, since self isn't global (can't be called as _G[self] or _G["self"])
- if showHideVariable then
- --button.conditionalDisplay = showHideVariable;
- button.showWhat = Utils.splitString("=", showHideVariable)[1];
- button.showIs = Utils.splitString("=", showHideVariable)[2];
- end;
-
- table.insert(self.buttons, button)
-end
-
-function courseplay:render_buttons(self, page)
- for _, button in pairs(self.buttons) do
- if button.page == page or button.page == nil then
- if button.showWhat ~= nil and button.showIs ~= nil then
- local what = Utils.splitString(".", button.showWhat);
- if what[1] == "self" then
- table.remove(what, 1);
- end;
- local whatObj;
- for i=1,#what do
- local key = what[i];
- --print(string.format("button %s: what[%d]=%s", button.function_to_call, i, tostring(what[i])));
- if i == 1 then
- whatObj = self[key];
- --print(string.format("whatObj = self[%s]", tostring(key)));
- end;
- if i > 1 then
- whatObj = whatObj[key];
- --print(string.format("whatObj = prevWhatObj[%s]", tostring(key)));
- end;
- end;
-
- button.show = tostring(whatObj) == button.showIs;
-
- --print(string.format("%s = %s", button.showWhat, tostring(whatObj)));
- end;
-
- if (button.show ~= nil and button.show) or button.show == nil then
- button.overlay:render();
- end;
- end
- end
-end
\ No newline at end of file
diff --git a/combines.lua b/combines.lua
deleted file mode 100644
index 8a243b1f0..000000000
--- a/combines.lua
+++ /dev/null
@@ -1,317 +0,0 @@
-function courseplay:find_combines(self)
- -- reseting reachable combines
- local found_combines = {}
- -- go through all vehicles and find filter all combines
- local all_vehicles = g_currentMission.vehicles
- for k, vehicle in pairs(all_vehicles) do
- -- combines should have this trigger
-
- -- trying to identify combines
- if courseplay:is_a_combine(vehicle) then
- table.insert(found_combines, vehicle)
- end
- end
-
- return found_combines
-end
-
-
-function courseplay:is_a_combine(vehicle)
- if vehicle.grainTankCapacity ~= nil then
- return true
- else
- return false
- end
-end
-
-function courseplay:combine_allows_tractor(self, combine)
- local num_allowed_courseplayers = 1
- if combine.courseplayers == nil then
- combine.courseplayers = {}
- end
-
- if combine.grainTankCapacity == 0 then
- num_allowed_courseplayers = 2
- else
- if self.realistic_driving then
- if combine.wants_courseplayer == true then
- return true
- end
- -- force unload when combine is full
- if combine.grainTankFillLevel == combine.grainTankCapacity then
- return true
- end
- -- is the pipe on the correct side?
- if combine.turnStage == 1 or combine.turnStage == 2 then
- return false
- end
- local left_fruit, right_fruit = courseplay:side_to_drive(self, combine, -10)
- if left_fruit > right_fruit then
- return false
- end
- end
- end
-
- if table.getn(combine.courseplayers) >= num_allowed_courseplayers then
- return false
- end
-
- if table.getn(combine.courseplayers) == 1 and not combine.courseplayers[1].allow_following then
- return false
- end
-
- return true
-end
-
--- find combines on the same field (texture)
-function courseplay:update_combines(self)
-
- self.reachable_combines = {}
-
- if not self.search_combine and self.saved_combine then
- table.insert(self.reachable_combines, self.saved_combine)
- return
- end
-
- courseplay:debug(string.format("combines total: %d ", table.getn(self.reachable_combines)), 4)
-
- local x, y, z = getWorldTranslation(self.aiTractorDirectionNode)
- local hx, hy, hz = localToWorld(self.aiTractorDirectionNode, -2, 0, 0)
- local lx, ly, lz = nil, nil, nil
- local terrain = g_currentMission.terrainDetailId
-
- local found_combines = courseplay:find_combines(self)
-
- courseplay:debug(string.format("combines found: %d ", table.getn(found_combines)), 4)
- -- go throuh found
- for k, combine in pairs(found_combines) do
- lx, ly, lz = getWorldTranslation(combine.rootNode)
- local dlx, dly, dlz = worldToLocal(self.aiTractorDirectionNode, lx, y, lz)
- local dnx = dlz * -1
- local dnz = dlx
- local angle = math.atan(dnz / dnx)
- dnx = math.cos(angle) * -2
- dnz = math.sin(angle) * -2
- hx, hy, hz = localToWorld(self.aiTractorDirectionNode, dnx, 0, dnz)
- local area1, area2 = Utils.getDensity(terrain, 2, x, z, lx, lz, hx, hz)
- area1 = area1 + Utils.getDensity(terrain, 0, x, z, lx, lz, hx, hz)
- area1 = area1 + Utils.getDensity(terrain, 1, x, z, lx, lz, hx, hz)
- if area2 * 0.999 <= area1 and courseplay:combine_allows_tractor(self, combine) then
- table.insert(self.reachable_combines, combine)
- end
- end
-
- courseplay:debug(string.format("%s: combines reachable: %d ", self.name, table.getn(self.reachable_combines)), 4)
-end
-
-
-function courseplay:register_at_combine(self, combine)
- local curFile = "combines.lua"
- courseplay:debug(string.format("%s(%i): %s: registering at combine %s", curFile, debug.getinfo(1).currentline, self.name, combine.name), 2)
- courseplay:debug(table.show(combine), 4)
- local num_allowed_courseplayers = 1
- self.calculated_course = false
- if combine.courseplayers == nil then
- combine.courseplayers = {}
- end
-
- if combine.grainTankCapacity == 0 then
- num_allowed_courseplayers = 2
- combine.isCornchopper = true
- else
- combine.isCornchopper = false
-
- if self.realistic_driving then
- if combine.wants_courseplayer == true or combine.grainTankFillLevel == combine.grainTankCapacity then
-
- else
- -- force unload when combine is full
- -- is the pipe on the correct side?
- if combine.turnStage == 1 or combine.turnStage == 2 then
- return false
- end
- local left_fruit, right_fruit = courseplay:side_to_drive(self, combine, -10)
- if left_fruit > right_fruit then
- return false
- end
- end
- end
- end
-
- if table.getn(combine.courseplayers) == num_allowed_courseplayers then
- return false
- end
-
- --THOMAS' best_combine START
- if combine.grainTankCapacity > 0 then
- local distance = 9999999
- local vehicle_ID = 0
- for k, vehicle in pairs(g_currentMission.vehicles) do --TODO: Liste einengen, nur Courseplayers
- if vehicle.combineID ~= nil then
- if vehicle.combineID == combine.id then
- courseplay:debug(tostring(vehicle.id).." : distanceToCombine:"..tostring(vehicle.distanceToCombine).." for combine.id:"..tostring(combine.id), 1)
- if distance > vehicle.distanceToCombine then
- distance = vehicle.distanceToCombine
- vehicle_ID = vehicle.id
- end
- end
- end
- end
- if vehicle_ID ~= self.id then
- courseplay:debug(tostring(self.id)..": es gibt einen naeheren trecker, der auch will. Es ist :"..tostring(vehicle_ID),1)
- return false
- else
- courseplay:debug((tostring(self.id).." : ich bin dran"),1)
- end
- end
- --THOMAS' best_combine END
-
-
- if table.getn(combine.courseplayers) == 1 and not combine.courseplayers[1].allow_following then
- return false
- end
-
- -- you got a courseplayer, so stop yellin....
- if combine.wants_courseplayer ~= nil and combine.wants_courseplayer == true then
- combine.wants_courseplayer = false
- end
-
- courseplay:debug(string.format("%s(%i): %s is being checked in with %s", curFile, debug.getinfo(1).currentline, self.name, combine.name), 1)
- combine.isCheckedIn = 1;
- self.distanceToCombine = nil
- self.combineID = nil
- table.insert(combine.courseplayers, self)
- self.courseplay_position = table.getn(combine.courseplayers)
- self.active_combine = combine
-
- --if math.floor(self.combine_offset) == 0 then
- if self.auto_combine_offset == true or self.combine_offset == 0 then
- --courseplay:debug(string.format("%s(%i): self.auto_combine_offset = true / self.combine_offset: %f", curFile, debug.getinfo(1).currentline, self.combine_offset), 2)
-
- local leftMarker = nil
- local currentCutter = nil
-
- for cutter, implement in pairs(combine.attachedCutters) do
- if cutter.aiLeftMarker ~= nil then
- if leftMarker == nil then
- leftMarker = cutter.aiLeftMarker;
- rightMarker = cutter.aiRightMarker;
- currentCutter = cutter
- local x, y, z = getWorldTranslation(currentCutter.rootNode)
- combine.lmX, lmY, lmZ = worldToLocal(leftMarker, x, y, z)
- combine.rmX, rmY, rmZ = worldToLocal(rightMarker, x, y, z)
-
- --self.combine_offset = lmX + 2.5;
- end;
- end;
- end;
-
- local prnX, prnY, prnZ = getTranslation(combine.pipeRaycastNode)
- local prnwX, prnwY, prnwZ = getWorldTranslation(combine.pipeRaycastNode)
- local combineToPrnX, combineToPrnY, combineToPrnZ = worldToLocal(combine.rootNode, prnwX, prnwY, prnwZ)
- --NOTE by Jakob: after a shitload of testing and failing, it seems combineToPrnX is what we're looking for (instead of prnToCombineX). Always results in correct x-distance from combine.rn to prn.
-
- if not combine.isCornchopper and combine.currentPipeState == 2 then -- pipe is extended
- self.combine_offset = combineToPrnX
- courseplay:debug(string.format("%s(%i): %s @ %s: using combineToPrnX=%f, self.combine_offset=%f", curFile, debug.getinfo(1).currentline, self.name, combine.name, combineToPrnX, self.combine_offset), 2)
- elseif not combine.isCornchopper then --pipe is closed
- if getParent(combine.pipeRaycastNode) == combine.rootNode then -- pipeRaycastNode is direct child of combine.root
- self.combine_offset = prnX
- courseplay:debug(string.format("%s(%i): %s @ %s: combine.root > pipeRaycastNode / self.combine_offset=prnX=%f", curFile, debug.getinfo(1).currentline, self.name, combine.name, self.combine_offset), 2)
- elseif getParent(getParent(combine.pipeRaycastNode)) == combine.rootNode then --pipeRaycastNode is direct child of pipe is direct child of combine.root
- local pipeX, pipeY, pipeZ = getTranslation(getParent(combine.pipeRaycastNode))
- self.combine_offset = pipeX - prnZ
-
- if prnZ == 0 or combine.name == "Grimme Rootster 604" then
- self.combine_offset = pipeX - prnY
- end
- courseplay:debug(string.format("%s(%i): %s @ %s: combine.root > pipe > pipeRaycastNode / self.combine_offset=pipeX-prnX=%f", curFile, debug.getinfo(1).currentline, self.name, combine.name, self.combine_offset), 2)
- elseif combineToPrnX > combine.lmX then
- if combineToPrnX >= 0 then
- self.combine_offset = combineToPrnX + 5
- else
- self.combine_offset = combineToPrnX - 5
- end
- courseplay:debug(string.format("%s(%i): %s @ %s: using combineToPrnX=%f, self.combine_offset=%f", curFile, debug.getinfo(1).currentline, self.name, combine.name, combineToPrnX, self.combine_offset), 2)
- elseif combine.lmX > 0 then --use leftMarker
- self.combine_offset = combine.lmX + 2.5
- courseplay:debug(string.format("%s(%i): %s @ %s: using leftMarker+2.5, self.combine_offset=%f", curFile, debug.getinfo(1).currentline, self.name, combine.name, self.combine_offset), 2)
- end
- elseif combine.isCornchopper then
- print(string.format("%s(%i): %s @ %s: combine.forced_side=%s", curFile, debug.getinfo(1).currentline, self.name, combine.name, tostring(combine.forced_side)));
- if combine.forced_side ~= nil then
- print(string.format("%s(%i): %s @ %s: combine.forced_side=%s, going by forced_side", curFile, debug.getinfo(1).currentline, self.name, combine.name, combine.forced_side));
- if combine.forced_side == "left" then
- self.sideToDrive = "left";
- self.combine_offset = combine.lmX + 2.5
- elseif combine.forced_side == "right" then
- self.sideToDrive = "right";
- self.combine_offset = (combine.lmX + 2.5) * -1
- end
- else
- print(string.format("%s(%i): %s @ %s: combine.forced_side=%s, going by fruit", curFile, debug.getinfo(1).currentline, self.name, combine.name, tostring(combine.forced_side)));
- local left_fruit, right_fruit = courseplay:side_to_drive(self, combine, -10);
- if left_fruit < right_fruit then
- self.sideToDrive = "left";
- self.combine_offset = combine.lmX + 2.5
- elseif left_fruit > right_fruit then
- self.sideToDrive = "right";
- self.combine_offset = (combine.lmX + 2.5) * -1
- else
- self.sideToDrive = nil;
- self.combine_offset = combine.lmX + 2.5
- end
- courseplay:debug(string.format("%s(%i): %s @ %s: left_fruit=%f, right_fruit=%f, sideToDrive=%s", curFile, debug.getinfo(1).currentline, self.name, combine.name, left_fruit, right_fruit, tostring(self.sideToDrive)), 2)
- end
- end
- end
- courseplay:add_to_combines_ignore_list(self, combine)
- return true
-end
-
-
-
-
-
-function courseplay:unregister_at_combine(self, combine)
- if self.active_combine == nil or combine == nil then
- return true
- end
-
- self.calculated_course = false;
- courseplay:remove_from_combines_ignore_list(self, combine)
- combine.isCheckedIn = nil;
- table.remove(combine.courseplayers, self.courseplay_position)
-
- -- updating positions of tractors
- for k, tractor in pairs(combine.courseplayers) do
- tractor.courseplay_position = k
- end
-
- self.allow_follwing = false
- self.courseplay_position = nil
- self.active_combine = nil
- self.ai_state = 1
-
- if self.trafficCollisionIgnoreList[combine.rootNode] == true then
- self.trafficCollisionIgnoreList[combine.rootNode] = nil
- end
-
- return true
-end
-
-function courseplay:add_to_combines_ignore_list(self, combine)
- if combine.trafficCollisionIgnoreList[self.rootNode] == nil then
- combine.trafficCollisionIgnoreList[self.rootNode] = true
- end
-end
-
-
-function courseplay:remove_from_combines_ignore_list(self, combine)
- if combine == nil then
- return
- end
- if combine.trafficCollisionIgnoreList[self.rootNode] == true then
- combine.trafficCollisionIgnoreList[self.rootNode] = nil
- end
-end
\ No newline at end of file
diff --git a/course_management.lua b/course_management.lua
deleted file mode 100644
index 6ba1e56c7..000000000
--- a/course_management.lua
+++ /dev/null
@@ -1,355 +0,0 @@
--- saving // loading coures
-
-
--- enables input for course name
-function courseplay:input_course_name(self)
- if table.getn(self.Waypoints) > 0 then
- self.user_input = ""
- self.user_input_active = true
- self.steeringEnabled = false -- test
- self.save_name = true
- self.user_input_message = courseplay:get_locale(self, "CPCourseName")
- end
-end
-
-function courseplay:reload_courses(self, use_real_id)
- for k, v in pairs(self.loaded_courses) do
-
- courseplay:load_course(self, v, use_real_id)
- end
-end
-
-function courseplay:add_course(self, id, use_real_id)
- courseplay:load_course(self, id, use_real_id, true)
-end
-
-function courseplay:reinit_courses(self)
- if g_currentMission.courseplay_courses == nil then
- if self.courseplay_courses ~= nil then
- g_currentMission.courseplay_courses = self.courseplay_courses
- else
- courseplay:debug("courseplay_courses is empty", 1)
- if g_server ~= nil then
- courseplay_manager:load_courses();
- end
- return
- end
- end
-end
-
-function courseplay:load_course(self, id, use_real_id, add_course_at_end)
- -- global array for courses, no refreshing needed any more
- courseplay:reinit_courses(self);
-
- if id ~= nil and id ~= "" then
- local searchID = id * 1
- if not use_real_id then
- id = self.selected_course_number + id
- else
- for i = 1, table.getn(g_currentMission.courseplay_courses) do
- if g_currentMission.courseplay_courses[i].id ~= nil then
- if g_currentMission.courseplay_courses[i].id == searchID then
- id = i
- break
- end
- end
- end
- end
- id = id * 1 -- ?? Why ??
-
- -- negative values mean that add_course_end is true
- if id < 1 then
- id = id * -1
- add_course_at_end = true
- end
-
-
-
-
-
- local course = g_currentMission.courseplay_courses[id]
- if course == nil then
- courseplay:debug("no course found", 1)
- return
- end
- if not use_real_id then
-
- if add_course_at_end == true then
- table.insert(self.loaded_courses, g_currentMission.courseplay_courses[id].id * -1)
- else
- table.insert(self.loaded_courses, g_currentMission.courseplay_courses[id].id)
- end
- end
- -- courseplay:reset_course(self)
- if table.getn(self.Waypoints) == 0 then
- self.numCourses = 1;
- self.Waypoints = course.waypoints
- self.current_course_name = course.name
- else -- Add new course to old course
- local course1_waypoints = self.Waypoints
- local course2_waypoints = course.waypoints
-
- local old_distance = 51
- local lastWP = table.getn(self.Waypoints)
- local wp_found = false
- local new_wp = 1
- -- go through all waypoints and try to find a waypoint of the next course near a crossing
-
- if add_course_at_end ~= true then
- for number, course1_wp in pairs(course1_waypoints) do
- --courseplay:debug(number, 3)
- if course1_wp.crossing == true and course1_wp.merged == nil and wp_found == false and number > self.startlastload then
- -- go through the second course from behind!!
- for number_2 = 1, table.getn(course2_waypoints) do
- local course2_wp = course2_waypoints[number_2]
- if course2_wp.crossing == true and course2_wp.merged == nil and wp_found == false then
- local distance_between_waypoints = courseplay:distance(course1_wp.cx, course1_wp.cz, course2_wp.cx, course2_wp.cz)
- if distance_between_waypoints < 50 and distance_between_waypoints ~= 0 then
- if distance_between_waypoints < old_distance then
- old_distance = distance_between_waypoints
- lastWP = number
- course1_waypoints[lastWP].merged = true
- new_wp = number_2
- wp_found = true
- end
- end
- end
- end
- end
- end
- end
-
- if wp_found == false then
- courseplay:debug("no waypoint found", 2)
- end
-
- self.Waypoints = {}
-
- for i = 1, lastWP do
- table.insert(self.Waypoints, course1_waypoints[i])
- end
- self.startlastload = lastWP
-
- local lastNewWP = table.getn(course.waypoints)
- for i = new_wp, lastNewWP do
- table.insert(self.Waypoints, course.waypoints[i])
- end
- self.Waypoints[lastWP + 1].merged = true
- self.numCourses = self.numCourses + 1;
- self.current_course_name = string.format("%d %s", self.numCourses, courseplay.locales.CPCourseAdded)
- end
- if table.getn(self.Waypoints) == 4 then
- self.createCourse = true
- else
- self.play = true
- end
- self.recordnumber = 1
- courseplay:RefreshSigns(self) -- this adds the signs to the course
- end
-end
-
-function courseplay:reset_merged(self)
- for i = 1, table.getn(g_currentMission.courseplay_courses) do
- for num, wp in pairs(g_currentMission.courseplay_courses[i].waypoints) do
- wp.merged = nil
- end
- end
-end
-
-function courseplay:clear_course(self, id)
- if id ~= nil then
- id = self.selected_course_number + id
- local course = g_currentMission.courseplay_courses[id]
- if course == nil then
- return
- end
- table.remove(g_currentMission.courseplay_courses, id)
- courseplay:save_courses(self)
- courseplay:RefreshGlobalSigns(self)
- end
-end
-
--- saves coures to xml-file
-function courseplay:save_courses(self)
- local path = getUserProfileAppPath() .. "savegame" .. g_careerScreen.selectedIndex .. "/"
- local File = io.open(path .. "courseplay.xml", "w")
- local tab = " "
-
- cpFile = createXMLFile("courseplay", path .. "courseplay2.xml", "xml");
-
-
- if File ~= nil then
- File:write("\n\n\n")
- for _, course in pairs(g_currentMission.courseplay_courses) do
- if course ~= nil then
- local name = course.name
- local id = course.id
- local x = course.waypoints
- File:write(tab .. "\n")
- for i = 1, table.getn(x) do
- local v = x[i]
- local wait = 0
- local crossing = 0
- local rev = 0
- local speed = v.speed
-
- if v.crossing then
- crossing = "1"
- else
- crossing = "0"
- end
-
- if v.wait then
- wait = "1"
- else
- wait = "0"
- end
- if v.rev then
- rev = "1"
- else
- rev = "0"
- end
- if speed == nil then
- speed = 0
- end
- File:write(tab .. tab .. "\n")
- end
- File:write(tab .. "\n")
- end
- end
- File:write("\n")
-
-
- File:write("\n\n")
- File:close()
- end
-end
-
-
-function courseplay:load_courses()
- courseplay:debug("try to load courses with old courseplay-function", 1);
- if true then
- return false;
- end
-
- courseplay:debug('loaded courses', 1)
- local finish_all = false
- courseplay_coursesUnsort = {}
- local path = getUserProfileAppPath() .. "savegame" .. g_careerScreen.selectedIndex .. "/"
- local existDir = io.open(path .. "courseplay.xml", "r")
- if existDir == nil then
- return
- end
-
- local File = io.open(path .. "courseplay.xml", "r")
- File:close()
- File = loadXMLFile("courseFile", path .. "courseplay.xml")
- local i = 0
- repeat
-
- local baseName = string.format("XML.courses.course(%d)", i)
- local name = getXMLString(File, baseName .. "#name")
- if name == nil then
- finish_all = true
- break
- end
- local id = getXMLInt(File, baseName .. "#id")
- if id == nil then
- id = 0
- end
- local tempCourse = {}
-
- local s = 1
-
- local finish_wp = false
- repeat
- local key = baseName .. ".waypoint" .. s
- local x, z = Utils.getVectorFromString(getXMLString(File, key .. "#pos"))
- if x ~= nil then
- if z == nil then
- finish_wp = true
- break
- end
- local dangle = Utils.getVectorFromString(getXMLString(File, key .. "#angle"))
- local wait = Utils.getVectorFromString(getXMLString(File, key .. "#wait"))
- local speed = Utils.getVectorFromString(getXMLString(File, key .. "#speed"))
- local rev = Utils.getVectorFromString(getXMLString(File, key .. "#rev"))
- local crossing = Utils.getVectorFromString(getXMLString(File, key .. "#crossing"))
-
- if crossing == 1 or s == 1 then
- crossing = true
- else
- crossing = false
- end
-
- if wait == 1 then
- wait = true
- else
- wait = false
- end
- if rev == 1 then
- rev = true
- else
- rev = false
- end
-
- if speed == 0 then
- speed = nil
- end
-
- tempCourse[s] = { cx = x, cz = z, angle = dangle, rev = rev, wait = wait, crossing = crossing, speed = speed }
- s = s + 1
- else
- local course = { name = name, id = id, waypoints = tempCourse }
- table.insert(courseplay_coursesUnsort, course)
- i = i + 1
- finish_wp = true
- break
- end
- until finish_wp == true
- until finish_all == true
-
- g_currentMission.courseplay_courses = {}
-
- for i = 1, table.getn(courseplay_coursesUnsort) do
- local name = courseplay_coursesUnsort[i].name
- table.insert(g_currentMission.courseplay_courses, name)
- end
-
- table.sort(g_currentMission.courseplay_courses)
-
- for i = 1, table.getn(g_currentMission.courseplay_courses) do
- for k, v in pairs(courseplay_coursesUnsort) do
- if g_currentMission.courseplay_courses[i] == courseplay_coursesUnsort[k].name then
- local waypoints = courseplay_coursesUnsort[k].waypoints
- local name = g_currentMission.courseplay_courses[i]
- local id = courseplay_coursesUnsort[k].id
- local course = { name = name, id = id, waypoints = waypoints }
- g_currentMission.courseplay_courses[i] = course
- break
- end
- end
- end
- -- search highest ID
- local maxID = 0
- for i = 1, table.getn(g_currentMission.courseplay_courses) do
- if g_currentMission.courseplay_courses[i].id ~= nil then
- if g_currentMission.courseplay_courses[i].id > maxID then
- maxID = g_currentMission.courseplay_courses[i].id
- end
- end
- end
- self.courseID = maxID
- -- define for old courses
- for i = 1, table.getn(g_currentMission.courseplay_courses) do
- if g_currentMission.courseplay_courses[i].id == nil or g_currentMission.courseplay_courses[i].id == 0 then
- self.courseID = self.courseID + 1
- g_currentMission.courseplay_courses[i].id = self.courseID
- end
- end
-
- courseplay_coursesUnsort = nil
- return g_currentMission.courseplay_courses
-end
-
-
diff --git a/courseplay.lua b/courseplay.lua
deleted file mode 100644
index a8d753129..000000000
--- a/courseplay.lua
+++ /dev/null
@@ -1,70 +0,0 @@
---
--- Courseplay v3.0
--- Specialization for Courseplay
---
--- @author Lautschreier / Hummel / Wolverin0815 / Bastian82
--- @version: v3.0 30.12.2011
--- @testing: bullgore80
-
-courseplay = {};
-courseplay_path = g_modsDirectory .. "/ZZZ_courseplay/"
-CPDebugLevel = 0
-
--- working tractors saved in this
-working_course_players = {};
-
-function initialize_courseplay()
- print("inizialized courseplay files")
- source(courseplay_path .. "helpers.lua")
-
- -- starting & stopping of courseplay
- print(courseplay_path .. "start_stop.lua")
- source(courseplay_path .. "start_stop.lua")
-
- -- course recording & resetting
- source(courseplay_path .. "recording.lua")
-
- -- drive Modes
- source(courseplay_path .. "mode1.lua")
- source(courseplay_path .. "mode2.lua")
- source(courseplay_path .. "mode4.lua")
- source(courseplay_path .. "mode6.lua")
-
- -- course recording & resetting
- source(courseplay_path .. "drive.lua")
-
- -- Mouse/Key Managment
- source(courseplay_path .. "input.lua")
-
- -- Infotext
- source(courseplay_path .. "global.lua")
-
- -- Distance Check
- source(courseplay_path .. "distance.lua")
-
- -- Visual Waypoints
- source(courseplay_path .. "signs.lua")
-
- -- Loading/Saving Courses
- source(courseplay_path .. "course_management.lua")
-
- -- loading/unloading tippers
- source(courseplay_path .. "tippers.lua")
-
- -- triggers
- source(courseplay_path .. "triggers.lua")
-
- -- triggers
- source(courseplay_path .. "combines.lua")
-
- source(courseplay_path .. "debug.lua")
-
- source(courseplay_path .. "button.lua")
- source(courseplay_path .. "hud.lua")
- source(courseplay_path .. "settings.lua")
- source(courseplay_path .. "courseplay_event.lua")
- source(courseplay_path .. "astar.lua")
- source(courseplay_path .. "fruit.lua")
-end
-
-initialize_courseplay()
diff --git a/courseplay_event.lua b/courseplay_event.lua
deleted file mode 100644
index 23855df33..000000000
--- a/courseplay_event.lua
+++ /dev/null
@@ -1,50 +0,0 @@
-CourseplayEvent = {};
-CourseplayEvent_mt = Class(CourseplayEvent, Event);
-
-InitEventClass(CourseplayEvent, "CourseplayEvent");
-
-function CourseplayEvent:emptyNew()
- local self = Event:new(CourseplayEvent_mt);
- self.className = "CourseplayEvent";
- return self;
-end
-
-function CourseplayEvent:new(vehicle, func, value)
- self.vehicle = vehicle;
- self.func = func
- self.value = value;
- return self;
-end
-
-function CourseplayEvent:readStream(streamId, connection)
- local id = streamReadInt32(streamId);
- self.vehicle = networkGetObject(id);
- self.func = streamReadString(streamId);
- self.value = streamReadFloat32(streamId);
-
- self:run(connection);
-end
-
-function CourseplayEvent:writeStream(streamId, connection)
- streamWriteInt32(streamId, networkGetObjectId(self.vehicle));
- streamWriteString(streamId, self.func);
- streamWriteFloat32(streamId, self.value);
-end
-
-function CourseplayEvent:run(connection)
- self.vehicle:setCourseplayFunc(self.func, self.value, true);
- if not connection:getIsServer() then
- g_server:broadcastEvent(CourseplayEvent:new(self.vehicle, self.func, self.value), nil, connection, self.object);
- end;
-end
-
-function CourseplayEvent.sendEvent(vehicle, func, value, noEventSend)
- if noEventSend == nil or noEventSend == false then
- if g_server ~= nil then
- g_server:broadcastEvent(CourseplayEvent:new(vehicle, func, value), nil, nil, vehicle);
- else
- g_client:getServerConnection():sendEvent(CourseplayEvent:new(vehicle, func, value));
- end;
- end;
-end
-
diff --git a/courseplay_manager.lua b/courseplay_manager.lua
deleted file mode 100644
index 4dae96510..000000000
--- a/courseplay_manager.lua
+++ /dev/null
@@ -1,348 +0,0 @@
-courseplay_manager = {};
-local courseplay_manager_mt = Class(courseplay_manager);
-
-function courseplay_manager:loadMap(name)
- if g_currentMission.courseplay_courses == nil then
- --courseplay:debug("courseplay courses was nil and initialized", 2);
- g_currentMission.courseplay_courses = {};
-
- courseplay_coursesUnsort = {}
- if g_server ~= nil and table.getn(g_currentMission.courseplay_courses) == 0 then
- g_currentMission.courseplay_courses = courseplay_manager:load_courses()
- courseplay:debug("debugging g_currentMission.courseplay_coures", 4)
- courseplay:debug(table.show(g_currentMission.courseplay_courses), 4)
- end
- end
-end
-
-function courseplay_manager:deleteMap()
- g_currentMission.courseplay_courses = nil
-end
-
-
-function courseplay_manager:draw()
-end
-
-function courseplay_manager:update()
- --courseplay:debug(table.getn(g_currentMission.courseplay_courses), 4);
-end
-
-function courseplay_manager:keyEvent()
-end
-
-function courseplay_manager:load_courses()
- courseplay:debug('loading courses by courseplay manager', 3)
- local finish_all = false
- local path = getUserProfileAppPath() .. "savegame" .. g_careerScreen.selectedIndex .. "/"
-
-
- File = loadXMLFile("courseFile", path .. "courseplay.xml")
- local i = 0
- repeat
-
- local baseName = string.format("XML.courses.course(%d)", i)
- local name = getXMLString(File, baseName .. "#name")
- if name == nil then
- finish_all = true
- break
- end
- local id = getXMLInt(File, baseName .. "#id")
- if id == nil then
- id = 0
- end
- local tempCourse = {}
-
- local s = 1
-
- local finish_wp = false
- repeat
- local key = baseName .. ".waypoint" .. s
- local x, z = Utils.getVectorFromString(getXMLString(File, key .. "#pos"))
- if x ~= nil then
- if z == nil then
- finish_wp = true
- break
- end
- local dangle = Utils.getVectorFromString(getXMLString(File, key .. "#angle"))
- local wait = Utils.getVectorFromString(getXMLString(File, key .. "#wait"))
- local speed = Utils.getVectorFromString(getXMLString(File, key .. "#speed"))
- local rev = Utils.getVectorFromString(getXMLString(File, key .. "#rev"))
- local crossing = Utils.getVectorFromString(getXMLString(File, key .. "#crossing"))
-
- if crossing == 1 or s == 1 then
- crossing = true
- else
- crossing = false
- end
-
- if wait == 1 then
- wait = true
- else
- wait = false
- end
- if rev == 1 then
- rev = true
- else
- rev = false
- end
-
- if speed == 0 then
- speed = nil
- end
-
- tempCourse[s] = { cx = x, cz = z, angle = dangle, rev = rev, wait = wait, crossing = crossing, speed = speed }
- s = s + 1
- else
- local course = { name = name, id = id, waypoints = tempCourse }
- table.insert(courseplay_coursesUnsort, course)
- i = i + 1
- finish_wp = true
- break
- end
- until finish_wp == true
- until finish_all == true
-
- g_currentMission.courseplay_courses = {}
-
- for i = 1, table.getn(courseplay_coursesUnsort) do
- local name = courseplay_coursesUnsort[i].name
- table.insert(g_currentMission.courseplay_courses, name)
- end
-
- table.sort(g_currentMission.courseplay_courses)
-
- for i = 1, table.getn(g_currentMission.courseplay_courses) do
- for k, v in pairs(courseplay_coursesUnsort) do
- if g_currentMission.courseplay_courses[i] == courseplay_coursesUnsort[k].name then
- local waypoints = courseplay_coursesUnsort[k].waypoints
- local name = g_currentMission.courseplay_courses[i]
- local id = courseplay_coursesUnsort[k].id
- local course = { name = name, id = id, waypoints = waypoints }
- g_currentMission.courseplay_courses[i] = course
- break
- end
- end
- end
- -- search highest ID
- local maxID = 0
- for i = 1, table.getn(g_currentMission.courseplay_courses) do
- if g_currentMission.courseplay_courses[i].id ~= nil then
- if g_currentMission.courseplay_courses[i].id > maxID then
- maxID = g_currentMission.courseplay_courses[i].id
- end
- end
- end
-
- courseplay:debug(table.show(courseplay_courses), 4);
-
- courseplay_coursesUnsort = nil
- return g_currentMission.courseplay_courses
-end
-
-
-function courseplay_manager:mouseEvent(posX, posY, isDown, isUp, button)
-end
-
-
-
-stream_debug_counter = 0
-
-function streamDebugWriteFloat32(streamId, value)
- value = Utils.getNoNil(value, 0.0)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- --courseplay:debug("float: ")
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- streamWriteFloat32(streamId, value)
-end
-
-function streamDebugWriteBool(streamId, value)
- value = Utils.getNoNil(value, false)
- if value == 1 then
- value = true
- end
-
- if value == 0 then
- value = false
- end
-
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- --courseplay:debug("Bool: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- streamWriteBool(streamId, value)
-end
-
-function streamDebugWriteInt32(streamId, value)
- value = Utils.getNoNil(value, 0)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- --courseplay:debug("Int32: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- streamWriteInt32(streamId, value)
-end
-
-function streamDebugWriteString(streamId, value)
- value = Utils.getNoNil(value, "")
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- --courseplay:debug("String: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- streamWriteString(streamId, value)
-end
-
-
-function streamDebugReadFloat32(streamId)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- local value = streamReadFloat32(streamId)
- --courseplay:debug("Float32: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- return value
-end
-
-
-function streamDebugReadInt32(streamId)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- local value = streamReadInt32(streamId)
- --courseplay:debug("Int32: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- return value
-end
-
-function streamDebugReadBool(streamId)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- local value = streamReadBool(streamId)
- --courseplay:debug("Bool: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- return value
-end
-
-function streamDebugReadString(streamId)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- local value = streamReadString(streamId)
- --courseplay:debug("String: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- return value
-end
-
-addModEventListener(courseplay_manager);
-
---
--- based on PlayerJoinFix
---
--- SFM-Modding
--- @author Manuel Leithner
--- @date: 01/08/11
--- @version: v1.0
--- @history: v1.0 - initial implementation 1.1 adaption to courseplay
---
-
-local modName = g_currentModName;
-local Server_sendObjects_old = Server.sendObjects;
-
-function Server:sendObjects(connection, x, y, z, viewDistanceCoeff)
- connection:sendEvent(CourseplayJoinFixEvent:new());
-
- Server_sendObjects_old(self, connection, x, y, z, viewDistanceCoeff);
-end
-
-
-CourseplayJoinFixEvent = {};
-CourseplayJoinFixEvent_mt = Class(CourseplayJoinFixEvent, Event);
-
-InitEventClass(CourseplayJoinFixEvent, "CourseplayJoinFixEvent");
-
-function CourseplayJoinFixEvent:emptyNew()
- local self = Event:new(CourseplayJoinFixEvent_mt);
- self.className = modName .. ".CourseplayJoinFixEvent";
- return self;
-end
-
-function CourseplayJoinFixEvent:new()
- local self = CourseplayJoinFixEvent:emptyNew()
- return self;
-end
-
-function CourseplayJoinFixEvent:writeStream(streamId, connection)
-
-
- if not connection:getIsServer() then
- --courseplay:debug("manager transfering courses", 4);
- --transfer courses
- local course_count = table.getn(g_currentMission.courseplay_courses)
-
- streamDebugWriteInt32(streamId, course_count)
- for i = 1, course_count do
- streamDebugWriteString(streamId, g_currentMission.courseplay_courses[i].name)
- streamDebugWriteInt32(streamId, g_currentMission.courseplay_courses[i].id)
- streamDebugWriteInt32(streamId, table.getn(g_currentMission.courseplay_courses[i].waypoints))
- for w = 1, table.getn(g_currentMission.courseplay_courses[i].waypoints) do
- streamDebugWriteFloat32(streamId, g_currentMission.courseplay_courses[i].waypoints[w].cx)
- streamDebugWriteFloat32(streamId, g_currentMission.courseplay_courses[i].waypoints[w].cz)
- streamDebugWriteFloat32(streamId, g_currentMission.courseplay_courses[i].waypoints[w].angle)
- streamDebugWriteBool(streamId, g_currentMission.courseplay_courses[i].waypoints[w].wait)
- streamDebugWriteBool(streamId, g_currentMission.courseplay_courses[i].waypoints[w].rev)
- streamDebugWriteBool(streamId, g_currentMission.courseplay_courses[i].waypoints[w].crossing)
- streamDebugWriteInt32(streamId, g_currentMission.courseplay_courses[i].waypoints[w].speed)
- end
- end
- end;
-end
-
-function CourseplayJoinFixEvent:readStream(streamId, connection)
- if connection:getIsServer() then
- --courseplay:debug("manager receiving courses", 4);
- -- course count
- local course_count = streamDebugReadInt32(streamId)
- --courseplay:debug("manager reading stream", 4);
- --courseplay:debug(course_count, 4);
- g_currentMission.courseplay_courses = {}
- for i = 1, course_count do
- --courseplay:debug("got course", 4);
- local course_name = streamDebugReadString(streamId)
- local course_id = streamDebugReadInt32(streamId)
- local wp_count = streamDebugReadInt32(streamId)
- local waypoints = {}
- for w = 1, wp_count do
- --courseplay:debug("got waypoint", 4);
- local cx = streamDebugReadFloat32(streamId)
- local cz = streamDebugReadFloat32(streamId)
- local angle = streamDebugReadFloat32(streamId)
- local wait = streamDebugReadBool(streamId)
- local rev = streamDebugReadBool(streamId)
- local crossing = streamDebugReadBool(streamId)
- local speeed = streamDebugReadInt32(streamId)
- local wp = { cx = cx, cz = cz, angle = angle, wait = wait, rev = rev, crossing = crossing, speed = speed }
- table.insert(waypoints, wp)
- end
- local course = { name = course_name, waypoints = waypoints, id = course_id }
- table.insert(g_currentMission.courseplay_courses, course)
- end
- end;
-end
-
-function CourseplayJoinFixEvent:run(connection)
- --courseplay:debug("CourseplayJoinFixEvent Run function should never be called", 4);
-end
-
-;
diff --git a/debug.lua b/debug.lua
deleted file mode 100644
index 74b70d7b5..000000000
--- a/debug.lua
+++ /dev/null
@@ -1,204 +0,0 @@
---[[ DEBUG LEVELS
- 0 = nothing
- 1 = important, not detailled
- 2 = mildly important
- 3 = important
- 4 = everything, most detailled
-]]
-function courseplay:debug(string, level)
- if level ~= nil then
- level = 1 --when in doubt, print
- if level <= CPDebugLevel then
- --print('Global CPDebugLevel: '..CPDebugLevel..' / this Lvl: '..level)
- print(string)
- end
- end
-end
-
--- debugging data dumper
--- just for development and debugging
-function table.show(t, name, indent)
- --only execute table.show if lvl == 4
- if CPDebugLevel < 4 then
- return
- end
-
- local cart -- a container
- local autoref -- for self references
-
- --[[ counts the number of elements in a table
-local function tablecount(t)
- local n = 0
- for _, _ in pairs(t) do n = n+1 end
- return n
-end
-]]
- -- (RiciLake) returns true if the table is empty
- local function isemptytable(t) return next(t) == nil end
-
- local function basicSerialize(o)
- local so = tostring(o)
- if type(o) == "function" then
- local info = debug.getinfo(o, "S")
- -- info.name is nil because o is not a calling level
- if info.what == "C" then
- return string.format("%q", so .. ", C function")
- else
- -- the information is defined through lines
- return string.format("%q", so .. ", defined in (" ..
- info.linedefined .. "-" .. info.lastlinedefined ..
- ")" .. info.source)
- end
- elseif type(o) == "number" then
- return so
- else
- return string.format("%q", so)
- end
- end
-
- local function addtocart(value, name, indent, saved, field)
- indent = indent or ""
- saved = saved or {}
- field = field or name
-
- cart = cart .. indent .. field
-
- if type(value) ~= "table" then
- cart = cart .. " = " .. basicSerialize(value) .. ";\n"
- else
- if saved[value] then
- cart = cart .. " = {}; -- " .. saved[value]
- .. " (self reference)\n"
- autoref = autoref .. name .. " = " .. saved[value] .. ";\n"
- else
- saved[value] = name
- --if tablecount(value) == 0 then
- if isemptytable(value) then
- cart = cart .. " = {};\n"
- else
- cart = cart .. " = {\n"
- for k, v in pairs(value) do
- k = basicSerialize(k)
- local fname = string.format("%s[%s]", name, k)
- field = string.format("[%s]", k)
- -- three spaces between levels
- addtocart(v, fname, indent .. " ", saved, field)
- end
- cart = cart .. indent .. "};\n"
- end
- end
- end
- end
-
- name = name or "__unnamed__"
- if type(t) ~= "table" then
- return name .. " = " .. basicSerialize(t)
- end
- cart, autoref = "", ""
- addtocart(t, name, indent)
- return cart .. autoref
-end
-
-function eval(str)
- return assert(loadstring(str))()
-end
-
-stream_debug_counter = 0
-
-function streamDebugWriteFloat32(streamId, value)
- value = Utils.getNoNil(value, 0.0)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- --courseplay:debug("float: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- streamWriteFloat32(streamId, value)
-end
-
-function streamDebugWriteBool(streamId, value)
- value = Utils.getNoNil(value, false)
- if value == 1 then
- value = true
- end
-
- if value == 0 then
- value = false
- end
-
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- --courseplay:debug("Bool: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- streamWriteBool(streamId, value)
-end
-
-function streamDebugWriteInt32(streamId, value)
- value = Utils.getNoNil(value, 0)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- --courseplay:debug("Int32: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- streamWriteInt32(streamId, value)
-end
-
-function streamDebugWriteString(streamId, value)
- value = Utils.getNoNil(value, "")
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- --courseplay:debug("String: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- streamWriteString(streamId, value)
-end
-
-
-function streamDebugReadFloat32(streamId)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- local value = streamReadFloat32(streamId)
- --courseplay:debug("Float32: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- return value
-end
-
-
-function streamDebugReadInt32(streamId)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- local value = streamReadInt32(streamId)
- --courseplay:debug("Int32: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- return value
-end
-
-function streamDebugReadBool(streamId)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- local value = streamReadBool(streamId, 4)
- --courseplay:debug("Bool: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- return value
-end
-
-function streamDebugReadString(streamId)
- stream_debug_counter = stream_debug_counter + 1
- --courseplay:debug("++++++++++++++++", 4)
- --courseplay:debug(stream_debug_counter, 4)
- local value = streamReadString(streamId)
- --courseplay:debug("String: ", 4)
- --courseplay:debug(value, 4)
- --courseplay:debug("-----------------", 4)
- return value
-end
diff --git a/distance.lua b/distance.lua
deleted file mode 100644
index 52f1a15e8..000000000
--- a/distance.lua
+++ /dev/null
@@ -1,63 +0,0 @@
--- distance between two coordinates
-function courseplay:distance(x1, z1, x2, z2)
- if x1 == nil or x2 == nil or z1 == nil or z2 == nil then
- return 1000
- end
- xd = (x1 - x2) * (x1 - x2)
- zd = (z1 - z2) * (z1 - z2)
- dist = math.sqrt(math.abs(xd + zd))
- return dist
-end
-
--- displays arrow and distance to start point
-function courseplay:dcheck(self)
- local ctx, cty, ctz = getWorldTranslation(self.rootNode);
- if self.back then
- number = self.maxnumber - 2
- else
- number = 1
- end
-
- if self.record_pause then
- number = self.recordnumber - 1
- end
-
- local arrowUV = {}
- local lx, ly, lz = worldToLocal(self.rootNode, self.Waypoints[number].cx, 0, self.Waypoints[number].cz)
- local arrowRotation = Utils.getYRotationFromDirection(lx, lz)
-
- arrowUV[1] = -0.5 * math.cos(-arrowRotation) + 0.5 * math.sin(-arrowRotation) + 0.5
- arrowUV[2] = -0.5 * math.sin(-arrowRotation) - 0.5 * math.cos(-arrowRotation) + 0.5
- arrowUV[3] = -0.5 * math.cos(-arrowRotation) - 0.5 * math.sin(-arrowRotation) + 0.5
- arrowUV[4] = -0.5 * math.sin(-arrowRotation) + 0.5 * math.cos(-arrowRotation) + 0.5
- arrowUV[5] = 0.5 * math.cos(-arrowRotation) + 0.5 * math.sin(-arrowRotation) + 0.5
- arrowUV[6] = 0.5 * math.sin(-arrowRotation) - 0.5 * math.cos(-arrowRotation) + 0.5
- arrowUV[7] = 0.5 * math.cos(-arrowRotation) - 0.5 * math.sin(-arrowRotation) + 0.5
- arrowUV[8] = 0.5 * math.sin(-arrowRotation) + 0.5 * math.cos(-arrowRotation) + 0.5
-
- setOverlayUVs(self.ArrowOverlay.overlayId, arrowUV[1], arrowUV[2], arrowUV[3], arrowUV[4], arrowUV[5], arrowUV[6], arrowUV[7], arrowUV[8])
- self.ArrowOverlay:render()
- local ctx, cty, ctz = getWorldTranslation(self.rootNode);
- if self.record or self.record_pause then
- return
- end
-
- local cx, cz = self.Waypoints[self.recordnumber].cx, self.Waypoints[self.recordnumber].cz
- dist = courseplay:distance(ctx, ctz, cx, cz)
-
- self.info_text = string.format(courseplay:get_locale(self, "CPDistance") .. ": %d ", dist)
-end
-
-
-function courseplay:distance_to_object(self, object)
- local x, y, z = getWorldTranslation(self.rootNode)
- local ox, oy, oz = worldToLocal(object.rootNode, x, y, z)
-
- return Utils.vector2Length(ox, oz)
-end
-
-
-function courseplay:distance_to_point(self, x, y, z)
- local ox, oy, oz = worldToLocal(self.aiTractorDirectionNode, x, y, z)
- return Utils.vector2Length(ox, oz)
-end
\ No newline at end of file
diff --git a/drive.lua b/drive.lua
deleted file mode 100644
index f1dbf3cef..000000000
--- a/drive.lua
+++ /dev/null
@@ -1,840 +0,0 @@
--- drives recored course
-function courseplay:drive(self, dt)
- local refSpeed = 0
-
- -- combine self unloading
- if self.ai_mode == 7 then
- local state = self.ai_state
- if state == 5 and self.target_x ~= nil and self.target_z ~= nil then
- self.info_text = string.format(courseplay:get_locale(self, "CPDriveToWP"), self.target_x, self.target_z)
- cx = self.target_x
- cy = self.target_y
- cz = self.target_z
- self.sl = 2
- refSpeed = self.field_speed
- distance_to_wp = courseplay:distance_to_point(self, cx, y, cz)
- if table.getn(self.next_targets) == 0 then
- if distance_to_wp < 10 then
- refSpeed = self.turn_speed -- 3/3600
- self.sl = 1
- end
- end
- -- avoid circling
- local distToChange = 2
- if self.shortest_dist == nil or self.shortest_dist > distance_to_wp then
- self.shortest_dist = distance_to_wp
- end
- if distance_to_wp > self.shortest_dist and distance_to_wp < 10 then
- distToChange = distance_to_wp + 1
- end
- if distance_to_wp < distToChange then
- self.shortest_dist = nil
- if table.getn(self.next_targets) > 0 then
- -- mode = 5
- self.target_x = self.next_targets[1].x
- self.target_y = self.next_targets[1].y
- self.target_z = self.next_targets[1].z
- table.remove(self.next_targets, 1)
- else
- allowedToDrive = false
- if self.next_ai_state ~= 2 then
- self.calculated_course = false
- end
- mode = self.next_ai_state
- self.next_ai_state = 0
- end
- end
- end
- if self.isAIThreshing then
- local cx, cy, cz = getWorldTranslation(self.rootNode);
- local oldcx, oldcz = self.Waypoints[self.recordnumber].cx, self.Waypoints[self.recordnumber].cz
- self.dist = courseplay:distance(cx, cz, oldcx, oldcz)
- if (self.grainTankFillLevel * 100 / self.grainTankCapacity) >= self.required_fill_level_for_drive_on then
- self.lastaiThreshingDirectionX = self.aiThreshingDirectionX
- self.lastaiThreshingDirectionZ = self.aiThreshingDirectionZ
- self:stopAIThreshing()
- self.abortWork = 3
- cx, cy, cz = localToWorld(self.rootNode, 0, 0, -25)
- self.Waypoints[self.maxnumber + 1] = { cx = cx, cz = cz, angle = 0, wait = false, rev = false, crossing = false }
- cx, cy, cz = localToWorld(self.rootNode, 0, 0, -12)
- self.Waypoints[self.maxnumber + 2] = { cx = cx, cz = cz, angle = 0, wait = false, rev = false, crossing = false }
- cx, cy, cz = localToWorld(self.rootNode, 0, 0, 5)
- self.Waypoints[self.maxnumber + 3] = { cx = cx, cz = cz, angle = 0, wait = false, rev = false, crossing = false }
- self.maxnumber = table.getn(self.Waypoints)
- courseplay:start(self)
- self.recordnumber = 2
- --if courseplay:calculate_course_to(self, self.Waypoints[2].cx, self.Waypoints[2].cz) then
- self.ai_state = 5
- --else -- fallback if no course could be calculated
- -- self.ai_state = 5
- -- end
- self.maxnumber = table.getn(self.Waypoints)
- else
- return
- end
- end
- end
- -- unregister at combine, if there is one
- if self.loaded == true and courseplay_position ~= nil then
- courseplay:unregister_at_combine(self, self.active_combine)
- end
-
- -- switch lights on!
- if not self.isControlled then
- -- we want to hear our courseplayers
- setVisibility(self.aiMotorSound, true)
- if g_currentMission.environment.needsLights then
- self:setLightsVisibility(true);
- else
- self:setLightsVisibility(false);
- end;
- end;
- -- actual position
- local ctx, cty, ctz = getWorldTranslation(self.rootNode);
- -- coordinates of next waypoint
- --if self.recordnumber > self.maxnumber then
- -- this should never happen
- -- self.recordnumber = self.maxnumber
- -- end
- local last_recordnumber = nil
- if self.recordnumber > 1 then
- last_recordnumber = self.recordnumber - 1
- else
- last_recordnumber = 1
- end
- if self.recordnumber > self.maxnumber then
- couseplay:debug(string.format("drive %i: %s: self.recordnumber (%s) > self.maxnumber (%s)", debug.getinfo(1).currentline, self.name, tostring(self.recordnumber), tostring(self.maxnumber)), 3); --this should never happen
- self.recordnumber = self.maxnumber
- end
- cx, cz = self.Waypoints[self.recordnumber].cx, self.Waypoints[self.recordnumber].cz
- -- offset - endlich lohnt sich der mathe-lk von vor 1000 Jahren ;)
- if self.ai_mode == 6 then
- if self.recordnumber > self.startWork and self.recordnumber < self.stopWork and self.recordnumber > 1 and self.WpOffsetX ~= nil and self.WpOffsetZ ~= nil and (self.WpOffsetX ~= 0 or self.WpOffsetZ ~= 0) then
- --courseplay:addsign(self, cx, 10, cz)
- --courseplay:debug(string.format("old WP: %d x %d ", cx, cz ), 2)
-
- -- direction vector
- local vcx, vcz
- if self.recordnumber == 1 then
- vcx = self.Waypoints[2].cx - cx
- vcz = self.Waypoints[2].cz - cz
- else
- if self.Waypoints[last_recordnumber].rev then
- vcx = self.Waypoints[last_recordnumber].cx - cx
- vcz = self.Waypoints[last_recordnumber].cz - cz
- else
- vcx = cx - self.Waypoints[last_recordnumber].cx
- vcz = cz - self.Waypoints[last_recordnumber].cz
- end
- end
- -- length of vector
- local vl = Utils.vector2Length(vcx, vcz)
- -- if not too short: normalize and add offsets
- if vl ~= nil and vl > 0.01 then
- vcx = vcx / vl
- vcz = vcz / vl
- cx = cx - vcz * self.WpOffsetX + vcx * self.WpOffsetZ
- cz = cz + vcx * self.WpOffsetX + vcz * self.WpOffsetZ
- end
- end
- --courseplay:debug(string.format("new WP: %d x %d (angle) %d ", cx, cz, angle ), 2)
- --courseplay:addsign(self, cx, 10, cz)
- end
-
- self.dist = courseplay:distance(cx, cz, ctx, ctz)
- --courseplay:debug(string.format("Tx: %f2 Tz: %f2 WPcx: %f2 WPcz: %f2 dist: %f2 ", ctx, ctz, cx, cz, self.dist ), 2)
- -- what about our tippers?
- local tipper_fill_level, tipper_capacity = self:getAttachedTrailersFillLevelAndCapacity()
- local fill_level = nil
- if tipper_fill_level ~= nil then
- fill_level = tipper_fill_level * 100 / tipper_capacity
- end
-
- if self.ai_mode == 4 or self.ai_mode == 8 then
- self.implementIsFull = (fill_level ~= nil and fill_level == 100);
- end;
-
- -- may i drive or should i hold position for some reason?
- local allowedToDrive = true
- -- in a traffic yam?
-
- self.max_speed_level = nil
-
- -- coordinates of coli
- local tx, ty, tz = getWorldTranslation(self.aiTrafficCollisionTrigger)
- -- direction of tractor
- local DirectionNode = nil;
- if self.aiTractorDirectionNode ~= nil then
- DirectionNode = self.aiTractorDirectionNode;
- elseif self.aiTreshingDirectionNode ~= nil then
- DirectionNode = self.aiTreshingDirectionNode;
- end;
- local nx, ny, nz = localDirectionToWorld(DirectionNode, 0, 0, 1)
-
- -- the tipper that is currently loaded/unloaded
- local active_tipper = nil
-
- if self.Waypoints[last_recordnumber].wait and self.wait then
- if self.waitTimer == nil and self.waitTime > 0 then
- self.waitTimer = self.timer + self.waitTime * 1000
- end
- if self.ai_mode == 3 then
- self.global_info_text = courseplay:get_locale(self, "CPReachedOverloadPoint") --'hat Überladepunkt erreicht.'
- if self.tipper_attached then
- -- drive on if fill_level doesn't change and fill level is < 100-self.required_fill_level_for_follow
- local drive_on = false
- if self.timeout < self.timer or self.last_fill_level == nil then
- if self.last_fill_level ~= nil and fill_level == self.last_fill_level and fill_level < 100 - self.required_fill_level_for_follow then
- drive_on = true
- end
- self.last_fill_level = fill_level
- courseplay:set_timeout(self, 7000)
- end
-
- if fill_level == 0 or drive_on then
- self.wait = false
- self.last_fill_level = nil
- self.unloaded = true
- end
- end
- elseif self.ai_mode == 4 then
- if last_recordnumber == self.startWork and fill_level ~= 0 then
- self.wait = false
- elseif last_recordnumber == self.stopWork and self.abortWork ~= nil then
- self.wait = false
- elseif last_recordnumber == self.stopWork and self.abortWork == nil then
- self.global_info_text = courseplay:get_locale(self, "CPWorkEnd") --'hat Arbeit beendet.'
- else
- self.global_info_text = courseplay:get_locale(self, "CPUnloadBale") -- "Ballen werden entladen"
- if fill_level == 0 or drive_on then
- self.wait = false
- end
- end
- elseif self.ai_mode == 6 then
- if last_recordnumber == self.startWork then
- self.wait = false
- elseif last_recordnumber == self.stopWork and self.abortWork ~= nil then
- self.wait = false
- elseif last_recordnumber == self.stopWork and self.abortWork == nil then
- self.global_info_text = courseplay:get_locale(self, "CPWorkEnd") --'hat Arbeit beendet.'
- elseif last_recordnumber ~= self.startWork and last_recordnumber ~= self.stopWork then
- self.global_info_text = courseplay:get_locale(self, "CPUnloadBale") -- "Ballen werden entladen"
- if fill_level == 0 or drive_on then
- self.wait = false
- end;
- end;
- elseif self.ai_mode == 7 then
- if last_recordnumber == self.startWork then
- if self.grainTankFillLevel > 0 then
- --courtesy of Thomas Gärtner
- self.setPipeState(self, 2)
- -- TODO: self:setPipeState(2);
- self.global_info_text = courseplay:get_locale(self, "CPReachedOverloadPoint") --'hat Überladepunkt erreicht.'
- else
- --courtesy of Thomas Gärtner
- self.setPipeState(self, 1)
- -- TODO: self:setPipeState(1);
- self.wait = false
- self.unloaded = true
- end
- end
- elseif self.ai_mode == 8 then
- self.global_info_text = courseplay:get_locale(self, "CPReachedOverloadPoint") --'hat �berladepunkt erreicht.'
- if self.tipper_attached then
- -- drive on if fill_level doesn't change and fill level is < 100-self.required_fill_level_for_follow
- courseplay:handle_mode8(self)
- local drive_on = false
- if self.timeout < self.timer or self.last_fill_level == nil then
- if self.last_fill_level ~= nil and fill_level == self.last_fill_level and fill_level < 100 - self.required_fill_level_for_follow then
- drive_on = true
- end
- self.last_fill_level = fill_level
- courseplay:set_timeout(self, 7000)
- end
- if fill_level == 0 or drive_on then
- self.wait = false
- self.last_fill_level = nil
- self.unloaded = true
- end
- end
- else
- self.global_info_text = courseplay:get_locale(self, "CPReachedWaitPoint")
- end
- -- wait untli a specific time
- if self.waitTimer and self.timer > self.waitTimer then
- self.waitTimer = nil
- self.wait = false
- end
- allowedToDrive = false
- else -- ende wartepunkt
- -- abfahrer-mode
- if (self.ai_mode == 1 and self.tipper_attached and tipper_fill_level ~= nil) or (self.loaded and self.ai_mode == 2) then
- -- is there a tipTrigger within 10 meters?
- raycastAll(tx, ty, tz, nx, ny, nz, "findTipTriggerCallback", 10, self)
- if self.currentTipTrigger == nil then
- raycastAll(tx+self.tipRefOffset, ty, tz, nx, ny, nz, "findTipTriggerCallback", 10, self)
- end
- if self.currentTipTrigger == nil then
- raycastAll(tx-self.tipRefOffset, ty, tz, nx, ny, nz, "findTipTriggerCallback", 10, self)
- end
- -- handle mode
- allowedToDrive = courseplay:handle_mode1(self)
- end
- -- combi-mode
- if (((self.ai_mode == 2 or self.ai_mode == 3) and self.recordnumber < 2) or self.active_combine) and self.tipper_attached then
- return courseplay:handle_mode2(self, dt)
- else
- self.ai_state = 0
- end
- -- Fertilice loading --only for one Implement !
- if self.ai_mode == 4 then
- if self.tipper_attached and self.startWork ~= nil and self.stopWork ~= nil then
- if self.tippers ~= nil then
- for i = 1, table.getn(self.tippers) do
- local activeTool = self.tippers[i]
-
- if not courseplay:is_sowingMachine(activeTool) then --sprayer
- if fill_level < 100 and activeTool.sprayerFillTriggers ~= nil and table.getn(activeTool.sprayerFillTriggers) > 0 then
- allowedToDrive = false
- self.info_text = string.format(courseplay:get_locale(self, "CPloading"), tipper_fill_level, tipper_capacity)
- local sprayer = activeTool.sprayerFillTriggers[1]
- activeTool:setIsSprayerFilling(true, sprayer.fillType, sprayer.isSiloTrigger, false)
- if sprayer.trailerInTrigger == activeTool then ----- feldrant container gülle bomber
- sprayer.fill = true
- end
- end
-
- if MapBGA ~= nil then
- for i = 1, table.getn(MapBGA.ModEvent.bunkers) do --support Heady�s BGA
- if fill_level < 100 and MapBGA.ModEvent.bunkers[i].manure.trailerInTrigger == activeTool then
- self.info_text = "BGA LADEN"
- allowedToDrive = false
- MapBGA.ModEvent.bunkers[i].manure.fill = true
- end
- end
- end
- end;
-
- if courseplay:is_sowingMachine(activeTool) then --sowing machine
- if fill_level < 100 and activeTool.sowingMachineFillTriggers[1] ~= nil then
- activeTool:setIsSowingMachineFilling(true, activeTool.sowingMachineFillTriggers[1].isEnabled, false);
- allowedToDrive = false;
- end;
- if activeTool.fillLevel == activeTool.capacity then
- allowedToDrive = true;
- end;
- end;
- end
- end
- end
- elseif self.ai_mode == 4 and (self.startWork == nil or self.stopWork == nil) then
- allowedToDrive = false
- self.info_text = courseplay.locales.CPNoWorkArea
- end
-
- if self.ai_mode ~= 5 and self.ai_mode ~= 6 and self.ai_mode ~= 7 and not self.tipper_attached then
- self.info_text = courseplay.locales.CPWrongTrailer
- allowedToDrive = false
- end
-
-
- if self.ai_mode == 7 then
- if self.recordnumber == 1 then --self.maxnumber then
- self.recordnumber = self.maxnumber
- allowedToDrive = false
- self.motor:setSpeedLevel(0, false);
- self.motor.maxRpmOverride = nil;
-
- if g_server ~= nil then
- AIVehicleUtil.driveInDirection(self, 0, self.steering_angle, 0, 0, 28, false, moveForwards, 0, 1)
- end
- self:startAIThreshing(true)
- self.sl = 1
- self:setBeaconLightsVisibility(false);
- if self.lastaiThreshingDirectionX ~= nil then
- self.aiThreshingDirectionX = self.lastaiThreshingDirectionX
- self.aiThreshingDirectionZ = self.lastaiThreshingDirectionZ
- end
- if self.abortWork ~= nil then
- for i = 0, (self.abortWork) do
- table.remove(self.Waypoints, self.maxnumber - i)
- end
- self.maxnumber = table.getn(self.Waypoints)
- self.orig_maxnumber = self.maxnumber
- self.recordnumber = self.maxnumber
- self.abortWork = nil
- end
- end
- end
- if self.ai_mode == 8 then
- if self.tipper_attached and self.startWork ~= nil and self.stopWork ~= nil then
- if self.tippers ~= nil then
- for i = 1, table.getn(self.tippers) do
- local activeTool = self.tippers[i]
- if fill_level < self.required_fill_level_for_drive_on and activeTool.sprayerFillTriggers ~= nil and table.getn(activeTool.sprayerFillTriggers) > 0 then
- allowedToDrive = false
- self.info_text = string.format(courseplay:get_locale(self, "CPloading"), tipper_fill_level, tipper_capacity)
- local sprayer = activeTool.sprayerFillTriggers[1]
- activeTool:setIsSprayerFilling(true, sprayer.fillType, sprayer.isSiloTrigger, false)
- if sprayer.trailerInTrigger == activeTool then ----- feldrant container gülle bomber
- sprayer.fill = true
- end
- end
- if MapBGA ~= nil then
- for i = 1, table.getn(MapBGA.ModEvent.bunkers) do --support Heady�s BGA
- if fill_level < self.required_fill_level_for_drive_on and MapBGA.ModEvent.bunkers[i].manure.trailerInTrigger == activeTool then
- self.info_text = "BGA LADEN"
- allowedToDrive = false
- MapBGA.ModEvent.bunkers[i].manure.fill = true
- end
- end
- end
- end
- end
- end
- end
-
- if self.fuelCapacity > 0 then
- local currentFuelPercentage = (self.fuelFillLevel / self.fuelCapacity + 0.0001) * 100;
- if currentFuelPercentage < 5 then
- allowedToDrive = false;
- self.global_info_text = courseplay.locales.CPNoFuelStop;
- elseif currentFuelPercentage < 20 and not self.isFuelFilling then
- self.global_info_text = courseplay.locales.CPFuelWarning;
- if self.fuelFillTriggers[1] then
- allowedToDrive = false;
- self:setIsFuelFilling(true, self.fuelFillTriggers[1].isEnabled, false);
- end
- elseif self.isFuelFilling and currentFuelPercentage < 99.9 then
- allowedToDrive = false;
- self.global_info_text = courseplay.locales.CPRefueling;
- end;
- end;
-
- if self.showWaterWarning then
- allowedToDrive = false
- self.global_info_text = courseplay.locales.CPWaterDrive
- end
-
- if self.StopEnd and (self.recordnumber == self.maxnumber or self.currentTipTrigger ~= nil) then
- allowedToDrive = false
- self.global_info_text = courseplay.locales.CPReachedEndPoint
- end
- end
-
- -- ai_mode 4 = fertilize
- local workArea = false
- local workSpeed = false
-
- if self.ai_mode == 4 and self.tipper_attached and self.startWork ~= nil and self.stopWork ~= nil then
- allowedToDrive, workArea, workSpeed = courseplay:handle_mode4(self, allowedToDrive, workArea, workSpeed, fill_level, last_recordnumber)
- end
-
- -- Mode 6 Fieldwork for balers and foragewagon
- if self.ai_mode == 6 and self.startWork ~= nil and self.stopWork ~= nil then
- if not workArea and self.aiTrafficCollisionTrigger ~= nil and self.grainTankCapacity == nil then
- -- is there a tipTrigger within 10 meters?
- raycastAll(tx, ty, tz, nx, ny, nz, "findTipTriggerCallback", 10, self)
- if self.currentTipTrigger == nil then
- raycastAll(tx+self.tipRefOffset, ty, tz, nx, ny, nz, "findTipTriggerCallback", 10, self)
- end
- if self.currentTipTrigger == nil then
- raycastAll(tx-self.tipRefOffset, ty, tz, nx, ny, nz, "findTipTriggerCallback", 10, self)
- end
- end;
- allowedToDrive, workArea, workSpeed, active_tipper = courseplay:handle_mode6(self, allowedToDrive, workArea, workSpeed, fill_level, last_recordnumber)
- end
-
-
- --Open/close cover
- courseplay:openCloseCover(self);
-
- allowedToDrive = courseplay:check_traffic(self, true, allowedToDrive)
-
- -- stop or hold position
- if not allowedToDrive then
- --self.motor:setSpeedLevel(0, false);
- AIVehicleUtil.driveInDirection(self, dt, 30, 0, 0, 28, false, moveForwards, nil, nil)
- if g_server ~= nil then
- AIVehicleUtil.driveInDirection(self, dt, self.steering_angle, 0.5, 0.5, 28, false, moveForwards, 0, 1)
- end
-
- -- unload active tipper if given
- return;
- end
-
-
-
- -- which speed?
- local slowEnd = self.ai_mode == 2 and self.recordnumber > self.maxnumber - 3;
- local slowStart_lvl2 = (self.ai_mode == 2 or self.ai_mode == 3) and self.recordnumber < 3;
- local slowStartEnd = self.ai_mode ~= 2 and self.ai_mode ~= 3 and self.ai_mode ~= 4 and self.ai_mode ~= 6 and (self.recordnumber > self.maxnumber - 3 or self.recordnumber < 3)
- local slowDownWP = false
- local slowDownRev = false
- local real_speed = self.lastSpeedReal
- local maxRpm = self.motor.maxRpm[self.sl]
-
- if self.recordnumber < (self.maxnumber - 3) then
- slowDownWP = (self.Waypoints[self.recordnumber + 2].wait or self.Waypoints[self.recordnumber + 1].wait or self.Waypoints[self.recordnumber].wait) --if mode4 or 6: last 3 points before stop or before start
- slowDownRev = (self.Waypoints[self.recordnumber + 2].rev or self.Waypoints[self.recordnumber + 1].rev or self.Waypoints[self.recordnumber].rev)
- else
- slowDownWP = self.Waypoints[self.recordnumber].wait
- slowDownRev = self.Waypoints[self.recordnumber].rev
- end
-
- if (slowDownWP and not workArea) or slowDownRev or self.max_speed_level == 1 or slowStartEnd or slowEnd then
- self.sl = 1
- refSpeed = self.turn_speed
- elseif (workSpeed and self.ai_mode ~= 7) or slowStart_lvl2 then
- self.sl = 2
- refSpeed = self.field_speed
- else
- self.sl = 3
- refSpeed = self.max_speed
- end
-
-
- if self.Waypoints[self.recordnumber].speed ~= nil and self.use_speed and self.recordnumber > 3 then
- refSpeed = self.Waypoints[self.recordnumber].speed
- end
-
- if slowDownRev and refSpeed > self.turn_speed then
- refSpeed = self.turn_speed
- end
-
-
- self.cpTrafficBrake = false
- if self.traffic_vehicle_in_front ~= nil then
- local vehicle_in_front = g_currentMission.nodeToVehicle[self.traffic_vehicle_in_front];
- local vehicleBehind = false
- if vehicle_in_front == nil then
- self.traffic_vehicle_in_front = nil
- self.CPnumCollidingVehicles = math.max(self.CPnumCollidingVehicles-1, 0);
- return
- end --!!!
- local x, y, z = getWorldTranslation(self.traffic_vehicle_in_front)
- local x1, y1, z1 = worldToLocal(self.rootNode, x, y, z)
- if z1 < 0 or math.abs(x1) > 4 then -- vehicle behind tractor
- vehicleBehind = true
- end
- if vehicle_in_front.rootNode == nil or vehicle_in_front.lastSpeedReal == nil or (vehicle_in_front.rootNode ~= nil and courseplay:distance_to_object(self, vehicle_in_front) > 40) or vehicleBehind then --!!!
- self.traffic_vehicle_in_front = nil
- else
- if allowedToDrive then
- if (self.lastSpeed*3600) - (vehicle_in_front.lastSpeedReal*3600) > 15 then
- self.cpTrafficBrake = true
- elseif vehicle_in_front.rootNode ~= nil and vehicle_in_front.lastSpeed ~= nil and courseplay:distance_to_object(self, vehicle_in_front) < 3 then
- refSpeed = math.min(vehicle_in_front.lastSpeedReal -(3*3600),refSpeed)
- else
- refSpeed = math.min(vehicle_in_front.lastSpeedReal,refSpeed)
- end
- end
- end
- end
-
- --bunkerSilo speed by Thomas Gärtner
- if self.currentTipTrigger ~= nil then
- if self.currentTipTrigger.bunkerSilo ~= nil then
- if self.unload_speed ~= nil then
- refSpeed = self.unload_speed;
- else
- refSpeed = 6 / 3600;
- end;
- else
- refSpeed = 9 / 3600;
- end
- else
- if self.runonce ~= nil then
- self.runonce = nil;
- end
- end
-
-
- if self.RulMode == 1 then
- if (self.sl == 3 and not self.beaconLightsActive) or (self.sl ~= 3 and self.beaconLightsActive) then
- self:setBeaconLightsVisibility(not self.beaconLightsActive);
- end
- elseif self.RulMode == 2 then
- if (self.drive and not self.beaconLightsActive) or (not self.drive and self.beaconLightsActive) then
- self:setBeaconLightsVisibility(not self.beaconLightsActive);
- end
- elseif self.RulMode == 3 then
- if self.beaconLightsActive then
- self:setBeaconLightsVisibility(false);
- end
- end
-
- -- Speed Control
-
- courseplay:setSpeed(self, refSpeed, self.sl)
-
- if self.ESLimiter ~= nil and self.ESLimiter.maxRPM[5] == nil then
- self.info_text = courseplay:get_locale(self, "CPWrongESLversion")
- end
-
- -- where to drive?
- local fwd = nil
- local distToChange = nil
- local lx, lz = AIVehicleUtil.getDriveDirection(self.rootNode, cx, cty, cz);
-
- if self.Waypoints[self.recordnumber].rev then
- lz = lz * -1
- lx = lx * -1
- fwd = false
- else
- fwd = true
- end
-
- if self.cpTrafficBrake then
- fwd = false
- end
-
- -- go, go, go!
- if self.recordnumber == 1 then --courtesy of Thomas Gärtner
- distToChange = 0.5
- elseif self.recordnumber + 1 <= self.maxnumber then
- local beforeReverse = (self.Waypoints[self.recordnumber + 1].rev and (self.Waypoints[self.recordnumber].rev == false))
- local afterReverse = (not self.Waypoints[self.recordnumber + 1].rev and self.Waypoints[last_recordnumber].rev)
- if (self.Waypoints[self.recordnumber].wait or beforeReverse) and self.Waypoints[self.recordnumber].rev == false then -- or afterReverse or self.recordnumber == 1
- distToChange = 1
- elseif self.Waypoints[self.recordnumber].rev and self.Waypoints[self.recordnumber].wait or afterReverse then
- distToChange = 2
- elseif self.Waypoints[self.recordnumber].rev then
- distToChange = 6
- -- elseif self.ai_mode == 7 and (self.recordnumber > (self.maxnumber-3)) then
- -- distToChange = 2
-
- else
- distToChange = 5
- end
- else
- distToChange = 5
- end
-
-
- -- record shortest distance to the next waypoint
- if self.shortest_dist == nil or self.shortest_dist > self.dist then
- self.shortest_dist = self.dist
- end
-
- if beforeReverse then
- self.shortest_dist = nil
- end
-
- -- if distance grows i must be circling
- if self.dist > self.shortest_dist and self.recordnumber > 3 and self.dist < 15 and self.Waypoints[self.recordnumber].rev ~= true then
- distToChange = self.dist + 1
- end
-
- if self.dist > distToChange then
- if g_server ~= nil then
- AIVehicleUtil.driveInDirection(self, dt, self.steering_angle, 0.5, 0.5, 8, true, fwd, lx, lz, self.sl, 0.5);
- courseplay:set_traffc_collision(self, lx, lz)
- end
- else
- -- reset distance to waypoint
- self.shortest_dist = nil
- if self.recordnumber < self.maxnumber then -- = New
- if not self.wait then
- self.wait = true
- end
- self.recordnumber = self.recordnumber + 1
- -- ignore reverse Waypoints for mode 6
- local in_work_area = false
- if self.startWork ~= nil and self.stopWork ~= nil and self.recordnumber >= self.startWork and self.recordnumber <= self.stopWork then
- in_work_area = true
- end
- while self.ai_mode == 6 and self.recordnumber < self.maxnumber and in_work_area and self.Waypoints[self.recordnumber].rev do
- self.recordnumber = self.recordnumber + 1
- end
- else -- reset some variables
- self.recordnumber = 1
- self.unloaded = false
- self.StopEnd = false
- self.loaded = false
- self.record = false
- self.play = true
- end
- end
-end
-
-
-function courseplay:set_traffc_collision(self, lx, lz)
- local maxlx = 0.5; --math.sin(maxAngle); --sin30° old was : 0.7071067 sin 45°
- local colDirX = lx;
- local colDirZ = lz;
- if colDirX > maxlx then
- colDirX = maxlx;
- elseif colDirX < -maxlx then
- colDirX = -maxlx;
- end;
- if colDirZ < -0.4 then
- colDirZ = 0.4;
- end;
- --courseplay:debug(string.format("colDirX: %f colDirZ %f ",colDirX,colDirZ ), 2)
-
- if CPDebugLevel > 0 then
- local x,y,z = getWorldTranslation(self.aiTrafficCollisionTrigger)
- local x1,y1,z1 = localToWorld(self.aiTrafficCollisionTrigger, colDirX*5, 0, colDirZ*5 )
- local x2,y2,z2 = localToWorld(self.aiTrafficCollisionTrigger, (colDirX*5)+ 1.5 , 0, colDirZ*5 )
- local x3,y3,z3 = localToWorld(self.aiTrafficCollisionTrigger, (colDirX*5)-1.5 , 0, colDirZ*5 )
- drawDebugPoint(x2, y, z2, 1, 1, 0, 1);
- drawDebugPoint(x3, y, z3, 1, 1, 0, 1);
- drawDebugLine(x, y, z, 1, 0, 0, x1, y, z1, 1, 0, 0);
- end;
-
-
-
- if self.aiTrafficCollisionTrigger ~= nil and g_server ~= nil then
- local DirectionNode = nil;
- if self.aiTractorDirectionNode ~= nil then
- DirectionNode = self.aiTractorDirectionNode;
- elseif self.aiTreshingDirectionNode ~= nil then
- DirectionNode = self.aiTreshingDirectionNode;
- end;
- AIVehicleUtil.setCollisionDirection(DirectionNode, self.aiTrafficCollisionTrigger, colDirX, colDirZ);
- end
-end
-
-
-function courseplay:check_traffic(self, display_warnings, allowedToDrive)
- local in_traffic = false;
- local ahead = false
- local vehicle_in_front = g_currentMission.nodeToVehicle[self.traffic_vehicle_in_front]
- local x, y, z = getWorldTranslation(self.aiTractorDirectionNode)
- local x1, y1, z1 = 0,0,0
-
- --courseplay:debug(table.show(self), 4)
- if self.CPnumCollidingVehicles ~= nil and self.CPnumCollidingVehicles > 0 then
- if vehicle_in_front ~= nil then
- x1, y1, z1 = worldToLocal(self.traffic_vehicle_in_front, x, y, z)
- if z1 > 0 then -- tractor in front of vehicle face2face
- ahead = true
- end
- if vehicle_in_front.lastSpeedReal == nil or vehicle_in_front.lastSpeedReal*3600 < 5 or ahead then
- --courseplay:debug("colliding", 2)
- allowedToDrive = false;
- in_traffic = true
- end
- end
- end
-
- if display_warnings and in_traffic then
- self.global_info_text = courseplay:get_locale(self, "CPInTraffic") --' steckt im Verkehr fest'
- end
-
- return allowedToDrive
-end
-
-function courseplay:setSpeed(self, refSpeed, sl)
- if self.lastSpeedSave ~= self.lastSpeedReal*3600 then
- if refSpeed*3600 == 1 then
- refSpeed = 1.6 / 3600
- end
- local trueRpm = self.motor.lastMotorRpm*100/self.orgRpm[3]
- local targetRpm = self.motor.maxRpm[self.sl]*100/self.orgRpm[3]
- local newLimit = 0
- local oldLimit = 0
- if self.ESLimiter ~= nil then
- oldLimit = self.ESLimiter.percentage[self.sl+1]
- else
- oldLimit = targetRpm
- end
-
- if refSpeed*3600 - self.lastSpeed*3600 > 15 then
- if sl == 2 then
- newLimit = 75
- else
- newLimit = 100
- end
- elseif refSpeed*3600 - self.lastSpeed*3600 > 4 then
- newLimit = oldLimit + 1
- elseif refSpeed*3600 - self.lastSpeed*3600 > 0.5 then
- newLimit = oldLimit + 0.1
- elseif refSpeed*3600 - self.lastSpeed*3600 > 0 then
- newLimit = oldLimit
- end
- if oldLimit - trueRpm > 10 then
- if refSpeed*3600 - self.lastSpeed*3600 < 1 then
- newLimit = trueRpm
-
- end
- end
- if self.lastSpeed*3600 - refSpeed*3600 > 8 then
- if sl == 1 then
- newLimit = 20
- else
- newLimit = oldLimit - 3
- end
- elseif self.lastSpeed*3600 - refSpeed*3600 > 3 then
- newLimit = oldLimit -1
- elseif self.lastSpeed*3600 - refSpeed*3600 > 1 then
- newLimit = oldLimit -0.75
- elseif self.lastSpeed*3600 - refSpeed*3600 > 0.5 then
- newLimit = oldLimit -0.25
- elseif self.lastSpeed*3600 - refSpeed*3600 > 0 then
- newLimit = oldLimit
- end
-
- if newLimit > 100 then
- newLimit = 100
- elseif newLimit < 0 then
- newLimit = 0
- end
-
- if self.ESLimiter ~= nil and self.ESLimiter.maxRPM[5] ~= nil then
- self:setNewLimit(self.sl+1, newLimit , false, true)
- elseif self.ESLimiter ~= nil and self.ESLimiter.maxRPM[5] == nil then
- --ESlimiter < V3
- else
- local maxRpm = newLimit * self.orgRpm[3]/100
-
- -- don't drive faster/slower than you can!
- if maxRpm > self.orgRpm[3] then
- maxRpm = self.orgRpm[3]
- elseif maxRpm < self.motor.minRpm then
- maxRpm = self.motor.minRpm
- end
- self.motor.maxRpm[self.sl]= maxRpm
- end
-
-
-
- self.lastSpeedSave = self.lastSpeedReal*3600
- end
-end;
-
-function courseplay:openCloseCover(self)
- --courseplay:debug("self.cp.tipperHasCover = " .. tostring(self.cp.tipperHasCover), 3);
- if self.cp.tipperHasCover then
- for i=1, table.getn(self.cp.tippersWithCovers) do
- local tIdx = self.cp.tippersWithCovers[i];
- local tipper = self.tippers[tIdx];
-
- --courseplay:debug(self.name .. ": tipper w/ cover = " .. tostring(tipper.name), 3);
-
- if tipper.plane.bOpen ~= nil and (self.ai_mode == 1 or self.ai_mode == 2 or self.ai_mode == 5) then
- --courseplay:debug(string.format("recordnumber=%s, maxnumber=%s, currentTipTrigger=%s, plane.bOpen=%s", tostring(self.recordnumber), tostring(self.maxnumber), tostring(self.currentTipTrigger ~= nil), tostring(tipper.plane.bOpen)), 3);
- local minCoverWaypoint = 3;
- if self.ai_mode == 2 then
- minCoverWaypoint = 2;
- end;
- if self.recordnumber >= minCoverWaypoint
- and self.recordnumber < self.maxnumber
- and self.currentTipTrigger == nil
- and tipper.plane.bOpen then
- tipper:setPlane(false);
- elseif ((self.recordnumber == nil or (self.recordnumber ~= nil and (self.recordnumber == 1 or self.recordnumber == self.maxnumber))) or self.currentTipTrigger ~= nil)
- and not tipper.plane.bOpen then
- tipper:setPlane(true);
- end;
- elseif tipper.plane.bOpen ~= nil and self.ai_mode == 6 then
- if not workArea and self.currentTipTrigger == nil and tipper.plane.bOpen then
- tipper:setPlane(false);
- elseif (workArea or self.currentTipTriger ~= nil) and not tipper.plane.bOpen then
- tipper:setPlane(true);
- end;
- end;
- end; --END for
- end;
-end;
\ No newline at end of file
diff --git a/emptyGui.xml b/emptyGui.xml
deleted file mode 100644
index 95cc8f864..000000000
--- a/emptyGui.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/fruit.lua b/fruit.lua
deleted file mode 100644
index 78fe0b792..000000000
--- a/fruit.lua
+++ /dev/null
@@ -1,159 +0,0 @@
--- inspired by fieldstatus of Alan R. (ls-uk.info: thebadtouch)
-function courseplay:area_has_fruit(x, z, fruit_type)
- if not courseplay:is_field(x, z) then
- return false
- end
- local numFruits = table.getn(g_currentMission.fruits);
- local getdenFunc = Utils.getDensity;
- local getfruitFunc = Utils.getFruitArea;
- local chnum = 0;
- local density = 0
- local startX, startZ, endX, endZ, widthX, widthZ, heightX, heightZ;
-
- local widthX = 0.5;
- local widthZ = 0.5;
-
- --x = x - 2.5
- --z = z - 2.5
- if fruit_type ~= nil then
- density = Utils.getFruitArea(fruit_type, x, z, x - widthX, z - widthZ, x + widthX, z + widthZ);
-
- if density > 0 then
- --courseplay:debug(string.format("checking x: %d z %d - density: %d", x, z, density ), 3)
- return true
- end
- else
- for i = 1, FruitUtil.NUM_FRUITTYPES do
- if i ~= FruitUtil.FRUITTYPE_GRASS then
-
- density = Utils.getFruitArea(i, x, z, x - widthX, z - widthZ, x + widthX, z + widthZ);
-
- if density > 0 then
- --courseplay:debug(string.format("checking x: %d z %d - density: %d", x, z, density ), 3)
- return true
- end
- end
- end
- end
-
- --courseplay:debug(string.format(" x: %d z %d - is really cut!", x, z ), 3)
- return false
-end
-
-function courseplay:is_field(x, z)
- local widthX = 0.5;
- local widthZ = 0.5;
- if Utils.getDensity(g_currentMission.terrainDetailId, 2, x, z, x - widthX, z - widthZ, x + widthX, z + widthZ) > 0 then
- return true
- else
- return false
- end
-end
-
-function courseplay:check_for_fruit(self, distance)
-
- local x, y, z = localToWorld(self.aiTractorDirectionNode, 0, 0, distance) --getWorldTranslation(combine.aiTreshingDirectionNode);
-
- local length = Utils.vector2Length(x, z);
- local aiThreshingDirectionX = x / length;
- local aiThreshingDirectionZ = z / length;
-
- local dirX, dirZ = aiThreshingDirectionX, aiThreshingDirectionZ;
- if dirX == nil or x == nil or dirZ == nil then
- return 0, 0
- end
- local sideX, sideZ = -dirZ, dirX;
-
- local threshWidth = 3
-
- local sideWatchDirOffset = -8
- local sideWatchDirSize = 3
-
-
- local lWidthX = x - sideX * 0.5 * threshWidth + dirX * sideWatchDirOffset;
- local lWidthZ = z - sideZ * 0.5 * threshWidth + dirZ * sideWatchDirOffset;
- local lStartX = lWidthX - sideX * 0.7 * threshWidth;
- local lStartZ = lWidthZ - sideZ * 0.7 * threshWidth;
- local lHeightX = lStartX + dirX * sideWatchDirSize;
- local lHeightZ = lStartZ + dirZ * sideWatchDirSize;
-
- local rWidthX = x + sideX * 0.5 * threshWidth + dirX * sideWatchDirOffset;
- local rWidthZ = z + sideZ * 0.5 * threshWidth + dirZ * sideWatchDirOffset;
- local rStartX = rWidthX + sideX * 0.7 * threshWidth;
- local rStartZ = rWidthZ + sideZ * 0.7 * threshWidth;
- local rHeightX = rStartX + dirX * sideWatchDirSize;
- local rHeightZ = rStartZ + dirZ * sideWatchDirSize;
- local leftFruit = 0
- local rightFruit = 0
-
- for i = 1, FruitUtil.NUM_FRUITTYPES do
- if i ~= FruitUtil.FRUITTYPE_GRASS then
- leftFruit = leftFruit + Utils.getFruitArea(i, lStartX, lStartZ, lWidthX, lWidthZ, lHeightX, lHeightZ)
-
- rightFruit = rightFruit + Utils.getFruitArea(i, rStartX, rStartZ, rWidthX, rWidthZ, rHeightX, rHeightZ)
- end
- end
-
- return leftFruit, rightFruit;
-end
-
-
-function courseplay:side_to_drive(self, combine, distance)
- -- if there is a forced side to drive return this
- --[[if combine.forced_side ~= nil then
- if combine.forced_side == "left" then
- print("fruit 105 l:1000 r:0")
- return 1000, 0
- else
- print("fruit 108 l:0 r:1000")
- return 0, 1000
-
-
- end
- end]]
- -- with autopilot combine, choose search area side
- if combine.apCombinePresent ~= nil and combine.apCombinePresent then
- if combine.autoPilotEnabled then
- if combine.autoPilotAreaLeft.available and combine.autoPilotAreaLeft.active then
- return 0, 1000
- end
- if combine.autoPilotAreaRight.available and combine.autoPilotAreaRight.active then
- return 1000, 0
- end
- end
- end
-
- local x, y, z = localToWorld(combine.aiTreshingDirectionNode, 0, 0, distance) --getWorldTranslation(combine.aiTreshingDirectionNode);
-
- local dirX, dirZ = combine.aiThreshingDirectionX, combine.aiThreshingDirectionZ;
- if dirX == nil or x == nil or dirZ == nil then
- return 0, 0
- end
- local sideX, sideZ = -dirZ, dirX;
-
- local threshWidth = 10
-
- local lWidthX = x - sideX * 0.5 * threshWidth + dirX * combine.sideWatchDirOffset;
- local lWidthZ = z - sideZ * 0.5 * threshWidth + dirZ * combine.sideWatchDirOffset;
- local lStartX = lWidthX - sideX * 0.7 * threshWidth;
- local lStartZ = lWidthZ - sideZ * 0.7 * threshWidth;
- local lHeightX = lStartX + dirX * combine.sideWatchDirSize;
- local lHeightZ = lStartZ + dirZ * combine.sideWatchDirSize;
-
- local rWidthX = x + sideX * 0.5 * threshWidth + dirX * combine.sideWatchDirOffset;
- local rWidthZ = z + sideZ * 0.5 * threshWidth + dirZ * combine.sideWatchDirOffset;
- local rStartX = rWidthX + sideX * 0.7 * threshWidth;
- local rStartZ = rWidthZ + sideZ * 0.7 * threshWidth;
- local rHeightX = rStartX + dirX * self.sideWatchDirSize;
- local rHeightZ = rStartZ + dirZ * self.sideWatchDirSize;
- local leftFruit = 0
- local rightFruit = 0
-
- leftFruit = leftFruit + Utils.getFruitArea(combine.lastValidInputFruitType, lStartX, lStartZ, lWidthX, lWidthZ, lHeightX, lHeightZ,true)
-
- rightFruit = rightFruit + Utils.getFruitArea(combine.lastValidInputFruitType, rStartX, rStartZ, rWidthX, rWidthZ, rHeightX, rHeightZ,true)
-
- courseplay:debug(string.format("%s: fruit: left %f right %f", combine.name, leftFruit, rightFruit), 3)
-
- return leftFruit, rightFruit
-end
\ No newline at end of file
diff --git a/global.lua b/global.lua
deleted file mode 100644
index 705705315..000000000
--- a/global.lua
+++ /dev/null
@@ -1,25 +0,0 @@
--- adds courseplayer to global table, so that the system knows all of them
-function courseplay:add_working_player(self)
- table.insert(working_course_players, self)
- return table.getn(working_course_players)
-end
-
--- renders info_text and global text for courseplaying tractors
-function courseplay:infotext(self)
- if self.isEntered then
- if self.info_text ~= nil then
- renderText(courseplay.hud.infoBasePosX + 0.005, courseplay.hud.infoBasePosY + 0.0035, 0.02, self.info_text); --ORIG: +0.002
- end
- end
-
- if self.global_info_text ~= nil then
- local yspace = self.working_course_player_num * 0.022
- local show_name = ""
- if self.name ~= nil then
- show_name = self.name
- end
- renderText(0.1, yspace, 0.02, show_name .. " " .. self.global_info_text);
- end
- self.info_text = nil
- self.global_info_text = nil
-end
diff --git a/helpers.lua b/helpers.lua
deleted file mode 100644
index a58270399..000000000
--- a/helpers.lua
+++ /dev/null
@@ -1,113 +0,0 @@
-function courseplay:isEven(n)
- return tonumber(n) % 2 == 0;
-end;
-
-function courseplay:isOdd(n)
- return tonumber(n) % 2 == 1;
-end;
-
-function courseplay:isFolding(workTool)
- if SpecializationUtil.hasSpecialization(Foldable, workTool.specializations) or SpecializationUtil.hasSpecialization(foldable, workTool.specializations) then
- for k, foldingPart in pairs(workTool.foldingParts) do
- local charSet = foldingPart.animCharSet;
- local animTime = nil
- if charSet ~= 0 then
- animTime = getAnimTrackTime(charSet, 0);
- else
- animTime = workTool:getRealAnimationTime(foldingPart.animationName);
- end;
-
- if animTime ~= nil then
- if workTool.foldMoveDirection > 0 then
- if animTime < foldingPart.animDuration then
- return true;
- end
- elseif workTool.foldMoveDirection < 0 then
- if animTime > 0 then
- return true;
- end
- end
- end
- end;
- return false;
- else
- return false;
- end;
-end;
-
-function tableShow(t, name, indent)
- local cart -- a container
- local autoref -- for self references
-
- --[[ counts the number of elements in a table
-local function tablecount(t)
- local n = 0
- for _, _ in pairs(t) do n = n+1 end
- return n
-end
-]]
- -- (RiciLake) returns true if the table is empty
- local function isemptytable(t) return next(t) == nil end
-
- local function basicSerialize(o)
- local so = tostring(o)
- if type(o) == "function" then
- local info = debug.getinfo(o, "S")
- -- info.name is nil because o is not a calling level
- if info.what == "C" then
- return string.format("%q", so .. ", C function")
- else
- -- the information is defined through lines
- return string.format("%q", so .. ", defined in (" ..
- info.linedefined .. "-" .. info.lastlinedefined ..
- ")" .. info.source)
- end
- elseif type(o) == "number" then
- return so
- else
- return string.format("%q", so)
- end
- end
-
- local function addtocart(value, name, indent, saved, field)
- indent = indent or ""
- saved = saved or {}
- field = field or name
-
- cart = cart .. indent .. field
-
- if type(value) ~= "table" then
- cart = cart .. " = " .. basicSerialize(value) .. ";\n"
- else
- if saved[value] then
- cart = cart .. " = {}; -- " .. saved[value]
- .. " (self reference)\n"
- autoref = autoref .. name .. " = " .. saved[value] .. ";\n"
- else
- saved[value] = name
- --if tablecount(value) == 0 then
- if isemptytable(value) then
- cart = cart .. " = {};\n"
- else
- cart = cart .. " = {\n"
- for k, v in pairs(value) do
- k = basicSerialize(k)
- local fname = string.format("%s[%s]", name, k)
- field = string.format("[%s]", k)
- -- three spaces between levels
- addtocart(v, fname, indent .. " ", saved, field)
- end
- cart = cart .. indent .. "};\n"
- end
- end
- end
- end
-
- name = name or "__unnamed__"
- if type(t) ~= "table" then
- return name .. " = " .. basicSerialize(t)
- end
- cart, autoref = "", ""
- addtocart(t, name, indent)
- return cart .. autoref
-end;
diff --git a/hud.lua b/hud.lua
deleted file mode 100644
index dab327b28..000000000
--- a/hud.lua
+++ /dev/null
@@ -1,470 +0,0 @@
--- Load Lines for Hud
-function courseplay:HudPage(self)
- local Page = self.showHudInfoBase
- local i = 0
- --local c = 1
- setTextBold(false)
- for c = 1, 2, 1 do
- for v, name in pairs(self.hudpage[Page][c]) do
- if c == 1 then
- --local yspace = courseplay.hud.infoBasePosY + 0.210 - ((v - 1) * 0.021) --ORIG: + 0.200 - NEW: + 0.210 ?
- renderText(courseplay.hud.infoBasePosX + 0.005, courseplay.hud.linesPosY[v], 0.019, name);
- elseif c == 2 then
- --local yspace = courseplay.hud.infoBasePosY + 0.210 - ((v - 1) * 0.021) --ORIG: + 0.200 - NEW: + 0.210 ?
- if Page == 6 then
- renderText(courseplay.hud.infoBasePosX + 0.182, courseplay.hud.linesPosY[v], 0.017, name);
- else
- renderText(courseplay.hud.infoBasePosX + 0.122, courseplay.hud.linesPosY[v], 0.017, name);
- end
- end
- i = i + 1
- end
- i = 0
- end
-end
-
-function courseplay:loadHud(self)
- self.hudpage[0][1] = {}
- self.hudpage[0][2] = {}
- self.hudpage[0][3] = {}
- self.hudpage[0][4] = {}
- self.hudpage[1][1] = {}
- self.hudpage[1][2] = {}
-
- if self.show_hud then
- --setOverlayUVs(self.hudInfoBaseOverlay, 0,0, 0,0.95, 0.95,0, 0.95,0.95);
- self.hudInfoBaseOverlay:render();
- if self.showHudInfoBase == 0 then
- -- no courseplayer!
- if self.courseplayers == nil or table.getn(self.courseplayers) == 0 then
- if self.wants_courseplayer then
- self.hudpage[0][1][1] = courseplay:get_locale(self, "CoursePlayCalledPlayer")
- else
- self.hudpage[0][1][1] = courseplay:get_locale(self, "CoursePlayCallPlayer")
- end
- else
- self.hudpage[0][1][1] = courseplay:get_locale(self, "CoursePlayPlayer")
- local tractor = self.courseplayers[1]
- self.hudpage[0][2][1] = tractor.name
-
- if tractor.forced_to_stop then
- self.hudpage[0][1][2] = courseplay:get_locale(self, "CoursePlayPlayerStart")
- else
- self.hudpage[0][1][2] = courseplay:get_locale(self, "CoursePlayPlayerStop")
- end
- self.hudpage[0][1][3] = courseplay:get_locale(self, "CoursePlayPlayerSendHome")
- if self.grainTankCapacity == 0 then
- local tractor = self.courseplayers[1]
- if tractor ~= nil then
- self.hudpage[0][1][4] = courseplay:get_locale(self, "CoursePlayPlayerSwitchSide")
- if self.forced_side == "left" then
- self.hudpage[0][2][4] = courseplay:get_locale(self, "CoursePlayPlayerSideLeft")
- elseif self.forced_side == "right" then
- self.hudpage[0][2][4] = courseplay:get_locale(self, "CoursePlayPlayerSideRight")
- else
- self.hudpage[0][2][4] = courseplay:get_locale(self, "CoursePlayPlayerSideNone")
- end
- end
- end
- end
- elseif self.showHudInfoBase == 1 then
- if self.play then
- if not self.drive then
- self.hudpage[1][1][3] = courseplay:get_locale(self, "CourseReset")
-
- self.hudpage[1][1][1] = courseplay:get_locale(self, "CoursePlayStart")
-
-
- if (table.getn(self.Waypoints) >= 4) and not self.createCourse then
- self.hudpage[1][1][4] = courseplay:get_locale(self, "CourseGenerate") -- Kurs erzeugen
- end
-
-
- else
- local last_recordnumber = nil
-
- if self.recordnumber > 1 then
- last_recordnumber = self.recordnumber - 1
- else
- last_recordnumber = 1
- end
-
- if (self.Waypoints[last_recordnumber].wait and self.wait) or (self.StopEnd and (self.recordnumber == self.maxnumber or self.currentTipTrigger ~= nil)) then
- self.hudpage[1][1][2] = courseplay:get_locale(self, "CourseWaitpointStart")
- end
-
- self.hudpage[1][1][1] = courseplay:get_locale(self, "CoursePlayStop")
-
-
- if not self.loaded and self.ai_mode ~= 5 then
- self.hudpage[1][1][3] = courseplay:get_locale(self, "NoWaitforfill")
- end
-
- if not self.StopEnd then
- self.hudpage[1][1][4] = courseplay:get_locale(self, "CoursePlayStopEnd")
- end
-
- if InputBinding.hasEvent(InputBinding.AHInput3) and InputBinding.isPressed(InputBinding.CP_Modifier_1) then
- self.loaded = true
- end
- end
- end
- if not self.drive then
- if (not self.record and not self.record_pause) and not self.play then --and (table.getn(self.Waypoints) == 0) and not self.createCourse
- if (table.getn(self.Waypoints) == 0) and not self.createCourse then
- self.hudpage[1][1][1] = courseplay:get_locale(self, "PointRecordStart")
- end
-
- elseif (not self.record and not self.record_pause) and (table.getn(self.Waypoints) ~= 0) then
- self.hudpage[1][1][2] = courseplay:get_locale(self, "ModusSet")
-
- else
- self.hudpage[1][1][1] = courseplay:get_locale(self, "PointRecordStop")
-
- if not self.record_pause then
- if self.recordnumber > 1 then
- self.hudpage[1][1][2] = courseplay:get_locale(self, "CourseWaitpointSet")
-
- self.hudpage[1][1][3] = courseplay:get_locale(self, "PointRecordInterrupt")
-
- self.hudpage[1][1][4] = courseplay:get_locale(self, "CourseCrossingSet")
- self.hudpage[1][1][5] = courseplay:get_locale(self, "CourseDriveDirection") .. " "
- if not self.direction then
- self.hudpage[1][1][5] = self.hudpage[1][1][5] .. courseplay:get_locale(self, "CourseDriveDirectionFor")
- else
- self.hudpage[1][1][5] = self.hudpage[1][1][5] .. courseplay:get_locale(self, "CourseDriveDirectionBac")
- end
- end
- else
- if self.recordnumber > 4 then
- self.hudpage[1][1][2] = courseplay:get_locale(self, "PointRecordDelete")
- end
-
- self.hudpage[1][1][3] = courseplay:get_locale(self, "PointRecordContinue")
- end
- end
- end
-
-
-
- --Page 2 (course list)
- elseif self.showHudInfoBase == 2 then
- local number_of_courses = 0
- if g_currentMission.courseplay_courses ~= nil then
- for k, course in pairs(g_currentMission.courseplay_courses) do --TODO: table.getn ?
- number_of_courses = number_of_courses + 1
- end
- end
- local start_course_num = self.selected_course_number
- local end_course_num = start_course_num + 4
-
- if end_course_num >= number_of_courses then
- end_course_num = number_of_courses - 1
- end
-
- for i = 0, 10, 1 do
- self.hudpage[2][1][i] = nil
- end
-
-
- local row = 1
- for i = start_course_num, end_course_num, 1 do
- for _, button in pairs(self.buttons) do
- if button.page == -2 and button.row == row then
- button.overlay:render()
- end
- end
- local course_name = g_currentMission.courseplay_courses[i + 1].name
-
- if course_name == nil or course_name == "" then
- course_name = "-"
- end
-
- self.hudpage[2][1][row] = course_name
- row = row + 1
- end
-
-
-
- --Page 3
- elseif self.showHudInfoBase == 3 then
- self.hudpage[3][1][1] = courseplay:get_locale(self, "CPCombineOffset") --"seitl. Abstand:"
- self.hudpage[3][1][2] = courseplay:get_locale(self, "CPPipeOffset") --"Pipe Abstand:"
- self.hudpage[3][1][3] = courseplay:get_locale(self, "CPTurnRadius") --"Wenderadius:"
- self.hudpage[3][1][4] = courseplay:get_locale(self, "CPRequiredFillLevel") --"Start bei%:"
- self.hudpage[3][1][5] = courseplay:get_locale(self, "NoWaitforfillAt") --"abfahren bei%:"
-
- if self.ai_state ~= nil then
- if self.combine_offset ~= 0 then
- local combine_offset_mode = ''
- if self.auto_combine_offset then
- combine_offset_mode = "(auto)"
- else
- combine_offset_mode = "(mnl)"
- end
- self.hudpage[3][2][1] = string.format("%s %.1f", combine_offset_mode, self.combine_offset)
- else
- self.hudpage[3][2][1] = "auto"
- end
- else
- self.hudpage[3][2][1] = "---"
- end
-
- if self.tipper_offset ~= nil then
- local tipperOffsetStr = ''
- if self.tipper_offset == 0 then
- tipperOffsetStr = "auto"
- elseif self.tipper_offset > 0 then
- tipperOffsetStr = string.format("auto+%.1f", self.tipper_offset)
- elseif self.tipper_offset < 0 then
- tipperOffsetStr = string.format("auto%.1f", self.tipper_offset)
- end
- self.hudpage[3][2][2] = tipperOffsetStr
- else
- self.hudpage[3][2][2] = "---"
- end
-
- if self.autoTurnRadius ~= nil or self.turn_radius ~= nil then
- local turnRadiusMode = ''
- if self.turnRadiusAutoMode then
- turnRadiusMode = "(auto)"
- else
- turnRadiusMode = "(mnl)"
- end
- self.hudpage[3][2][3] = string.format("%s %d", turnRadiusMode, self.turn_radius)
- else
- self.hudpage[3][2][3] = "---"
- end
-
- if self.required_fill_level_for_follow ~= nil then
- self.hudpage[3][2][4] = string.format("%d", self.required_fill_level_for_follow)
- else
- self.hudpage[3][2][4] = "---"
- end
-
- if self.required_fill_level_for_drive_on ~= nil then
- self.hudpage[3][2][5] = string.format("%.1f", self.required_fill_level_for_drive_on)
- else
- self.hudpage[3][2][5] = "---"
- end
-
-
-
- --Page 4
- elseif self.showHudInfoBase == 4 then
-
- self.hudpage[4][1][1] = courseplay:get_locale(self, "CPSelectCombine") -- "Drescher wählen:"
- self.hudpage[4][1][2] = courseplay:get_locale(self, "CPCombineSearch") -- "Dreschersuche:"
- self.hudpage[4][1][3] = courseplay:get_locale(self, "CPActual") -- "Aktuell:"
- --self.hudpage[4][1][4]= courseplay:get_locale(self, "CPMaxHireables") -- "Aktuell:"
- --self.hudpage[4][2][4] = string.format("%d", g_currentMission.maxNumHirables)
-
- if self.active_combine ~= nil then
- self.hudpage[4][2][3] = self.active_combine.name
- else
- self.hudpage[4][2][3] = courseplay:get_locale(self, "CPNone") -- "keiner"
- end
-
- if self.saved_combine ~= nil then
- local combine_name = self.saved_combine.name
- if combine_name == nil then
- combine_name = courseplay:get_locale(self, "CPCombine");
- end
- self.hudpage[4][2][1] = combine_name .. " (" .. string.format("%d", courseplay:distance_to_object(self, self.saved_combine)) .. "m)"
- else
- self.hudpage[4][2][1] = courseplay:get_locale(self, "CPNone") -- "keiner"
- end
-
- if self.search_combine then
- self.hudpage[4][2][2] = courseplay:get_locale(self, "CPFindAuto") -- "automatisch finden"
- else
- self.hudpage[4][2][2] = courseplay:get_locale(self, "CPFindManual") -- "manuell zuweisen"
- end;
-
-
-
- --Page 5
- elseif self.showHudInfoBase == 5 then
- self.hudpage[5][1][1] = courseplay:get_locale(self, "CPTurnSpeed") -- "Wendemanöver:"
- self.hudpage[5][1][2] = courseplay:get_locale(self, "CPFieldSpeed") -- "Auf dem Feld:"
- self.hudpage[5][1][3] = courseplay:get_locale(self, "CPMaxSpeed") -- "Auf Straße:"
- self.hudpage[5][1][4] = courseplay:get_locale(self, "CPUnloadSpeed") -- "Abladen (BGA):"
- self.hudpage[5][1][5] = courseplay:get_locale(self, "CPuseSpeed") -- "Geschwindigkeit:"
-
- local localeSpeedMulti = 1; --kph
- if g_languageShort == "en" then
- localeSpeedMulti = 0.621371; --mph
- end;
-
- self.hudpage[5][2][1] = string.format("%d %s", self.turn_speed * 3600 * localeSpeedMulti, courseplay.locales.CPspeedUnit);
- self.hudpage[5][2][2] = string.format("%d %s", self.field_speed * 3600 * localeSpeedMulti, courseplay.locales.CPspeedUnit);
- self.hudpage[5][2][4] = string.format("%d %s", self.unload_speed * 3600 * localeSpeedMulti, courseplay.locales.CPspeedUnit);
-
- if self.use_speed then
- self.hudpage[5][2][3] = courseplay:get_locale(self, "CPautomaticSpeed");
- self.hudpage[5][2][5] = courseplay:get_locale(self, "CPuseSpeed1") -- "wie beim einfahren"
- else
- self.hudpage[5][2][3] = string.format("%d %s", self.max_speed * 3600 * localeSpeedMulti, courseplay.locales.CPspeedUnit);
- self.hudpage[5][2][5] = courseplay:get_locale(self, "CPuseSpeed2") -- "maximale Geschwindigkeit"
- end;
-
-
-
- --Page 6
- elseif self.showHudInfoBase == 6 then
-
- self.hudpage[6][1][1] = courseplay:get_locale(self, "CPaStar") -- Z-Offset:
-
- self.hudpage[6][1][2] = courseplay:get_locale(self, "CPopenHud") -- Z-Offset:
- self.hudpage[6][1][3] = courseplay:get_locale(self, "CPWPs") -- Z-Offset:
-
- if self.realistic_driving then
- self.hudpage[6][2][1] = courseplay:get_locale(self, "CPastarOn")
- else
- self.hudpage[6][2][1] = courseplay:get_locale(self, "CPastarOff") -- "keiner"
- end
-
- if self.mouse_right_key_enabled then
- self.hudpage[6][2][2] = courseplay:get_locale(self, "CPopenHudMouse")
- else
- local hudMod = string.lower(tostring(InputBinding.getKeyNamesOfDigitalAction(InputBinding.CP_Modifier_1)):split(" ")[2])
- local hudKey = string.lower(tostring(InputBinding.getKeyNamesOfDigitalAction(InputBinding.CP_Hud)):split(" ")[2])
- self.hudpage[6][2][2] = hudMod:gsub("^%l", string.upper) .. " + " .. hudKey:gsub("^%l", string.upper)
- end
-
- self.hudpage[6][1][4] = courseplay:get_locale(self, "Rul")
- self.hudpage[6][1][5] = courseplay:get_locale(self, "CPDebugLevel")
-
- self.hudpage[6][2][3] = courseplay:get_locale(self, "WaypointMode" .. string.format("%d", self.waypointMode));
- self.hudpage[6][2][4] = courseplay:get_locale(self, "RulMode" .. string.format("%d", self.RulMode));
- self.hudpage[6][2][5] = courseplay:get_locale(self, "CPDebugLevel" .. string.format("%d", CPDebugLevel))
-
- --Page 7
- elseif self.showHudInfoBase == 7 then
- self.hudpage[7][1][1] = courseplay:get_locale(self, "CPWaitTime") -- Wartezeit am Haltepunkt
- self.hudpage[7][2][1] = string.format("%.1f", self.waitTime) .. "sec"
-
- self.hudpage[7][1][2] = courseplay:get_locale(self, "CPWpOffsetX") -- X-Offset
- if self.WpOffsetX ~= nil then
- self.hudpage[7][2][2] = string.format("%.1f", self.WpOffsetX) .. "m (l/r)"
- else
- self.hudpage[7][2][2] = "---"
- end
-
- local direction = ""
- self.hudpage[7][1][3] = courseplay:get_locale(self, "CPWpOffsetZ") -- X-Offset
- if self.WpOffsetZ ~= nil then
- self.hudpage[7][2][3] = string.format("%.1f", self.WpOffsetZ) .. "m (h/v)"
- else
- self.hudpage[7][2][3] = "---"
- end
-
- self.hudpage[7][1][4] = courseplay:get_locale(self, "CPWorkingWidht") -- Arbeitsbreite
- if self.toolWorkWidht ~= nil then
- self.hudpage[7][2][4] = string.format("%.1f", self.toolWorkWidht) .. "m"
- else
- self.hudpage[7][2][4] = "---"
- end
- end
- end -- end if show_hud
-end
-
-
-function courseplay:showHud(self)
- -- HUD
- if self.show_hud and self.isEntered then
-
- courseplay:render_buttons(self, self.showHudInfoBase)
-
- if self.ai_mode > 0 and self.ai_mode < 9 then
- self.hudinfo[1] = courseplay:get_locale(self, "CourseMode" .. string.format("%d", self.ai_mode))
- else
- self.hudinfo[1] = "---"
- end
-
- if self.current_course_name ~= nil then
- self.hudinfo[2] = courseplay:get_locale(self, "CPCourse") .. " " .. self.current_course_name
- else
- self.hudinfo[2] = courseplay:get_locale(self, "CPNoCourseLoaded") -- "Kurs: kein Kurs geladen"
- end
-
- if self.Waypoints[self.recordnumber] ~= nil then
- self.hudinfo[3] = courseplay:get_locale(self, "CPWaypoint") .. self.recordnumber .. "/" .. self.maxnumber .. " " .. courseplay.locales.WaitPoints .. self.waitPoints .. " " .. courseplay.locales.CrossPoints .. self.crossPoints
- elseif self.record or self.record_pause or self.createCourse then
- self.hudinfo[3] = courseplay:get_locale(self, "CPWaypoint") .. self.recordnumber .. " " .. courseplay.locales.WaitPoints .. self.waitPoints .. " " .. courseplay.locales.CrossPoints .. self.crossPoints
- else
- self.hudinfo[3] = courseplay:get_locale(self, "CPNoWaypoint") -- "Keine Wegpunkte geladen"
- end
- setTextBold(false)
- local i = 0
- for v, name in pairs(self.hudinfo) do
- --local yspace = courseplay.hud.infoBasePosY + 0.077 - (i * 0.021); --ORIG: +0.077
- renderText(courseplay.hud.infoBasePosX + 0.006, courseplay.hud.linesBottomPosY[v], 0.017, name); --ORIG: +0.003
- i = i + 1
- end
-
-
- setTextBold(true)
- local hud_headline = nil
-
- if self.showHudInfoBase == 0 then
- hud_headline = courseplay:get_locale(self, "CPCombineMangament") -- "Kurse verwalten"
- elseif self.showHudInfoBase == 1 then
- hud_headline = courseplay:get_locale(self, "CPSteering") -- "Abfahrhelfer Steuerung"
- elseif self.showHudInfoBase == 2 then
- hud_headline = courseplay:get_locale(self, "CPManageCourses") -- "Kurse verwalten"
- elseif self.showHudInfoBase == 3 then
- hud_headline = courseplay:get_locale(self, "CPCombiSettings") -- "Einstellungen Combi Modus"
- elseif self.showHudInfoBase == 4 then
- hud_headline = courseplay:get_locale(self, "CPManageCombines") -- "Drescher verwalten";
- elseif self.showHudInfoBase == 5 then
- hud_headline = courseplay:get_locale(self, "CPSpeedLimit") -- "Geschwindigkeiten"
- elseif self.showHudInfoBase == 6 then
- hud_headline = courseplay:get_locale(self, "CPSettings") -- "Allgemein"
- elseif self.showHudInfoBase == 7 then
- hud_headline = courseplay:get_locale(self, "CPHud7") -- "Allgemein"
- end
-
- renderText(courseplay.hud.infoBasePosX + 0.060, courseplay.hud.infoBasePosY + 0.240, 0.021, hud_headline);
- courseplay:HudPage(self);
- end
-
- if self.play then
- --local helpButtonModifier = " (+ " .. tostring(InputBinding.getKeyNamesOfDigitalAction(InputBinding.CP_Modifier_1)):split(" ")[2] .. ")"
- -- hud not displayed - display start stop
- if self.drive then
- if InputBinding.isPressed(InputBinding.CP_Modifier_1) then
- g_currentMission:addHelpButtonText(courseplay:get_locale(self, "CoursePlayStop"), InputBinding.AHInput1)
- if InputBinding.hasEvent(InputBinding.AHInput1) then
- self:setCourseplayFunc("stop", nil)
- end
- end
-
- local last_recordnumber = nil
-
- if self.recordnumber > 1 then
- last_recordnumber = self.recordnumber - 1
- else
- last_recordnumber = 1
- end
-
- if self.Waypoints[last_recordnumber].wait and self.wait then
- if InputBinding.isPressed(InputBinding.CP_Modifier_1) then
- g_currentMission:addHelpButtonText(courseplay:get_locale(self, "CourseWaitpointStart"), InputBinding.AHInput2)
-
- if InputBinding.hasEvent(InputBinding.AHInput2) then
- self:setCourseplayFunc("drive_on", nil)
- end
- end
- end
-
- else
- if InputBinding.isPressed(InputBinding.CP_Modifier_1) then
- g_currentMission:addHelpButtonText(courseplay:get_locale(self, "CoursePlayStart"), InputBinding.AHInput1)
- if InputBinding.hasEvent(InputBinding.AHInput1) then
- self:setCourseplayFunc("start", nil)
- end
- end
- end
- end
-end
diff --git a/img/NurGerade/NurGerade.i3d b/img/NurGerade/NurGerade.i3d
deleted file mode 100644
index 646531b78..000000000
--- a/img/NurGerade/NurGerade.i3d
+++ /dev/null
@@ -1,131 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/img/NurGerade/texture0.dds b/img/NurGerade/texture0.dds
deleted file mode 100644
index fe145a202..000000000
Binary files a/img/NurGerade/texture0.dds and /dev/null differ
diff --git a/img/Parkplatz/Parkplatz.i3d b/img/Parkplatz/Parkplatz.i3d
deleted file mode 100644
index 970b57573..000000000
--- a/img/Parkplatz/Parkplatz.i3d
+++ /dev/null
@@ -1,239 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/img/Parkplatz/texture0.dds b/img/Parkplatz/texture0.dds
deleted file mode 100644
index 65d2a7b64..000000000
Binary files a/img/Parkplatz/texture0.dds and /dev/null differ
diff --git a/img/STOP/STOP.i3d b/img/STOP/STOP.i3d
deleted file mode 100644
index 9b4b3f3e4..000000000
--- a/img/STOP/STOP.i3d
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/img/STOP/texture0.dds b/img/STOP/texture0.dds
deleted file mode 100644
index 6a55e0f6f..000000000
Binary files a/img/STOP/texture0.dds and /dev/null differ
diff --git a/img/VorfahrtAnDieserKreuzung/VorfahrtAnDieserKreuzung.i3d b/img/VorfahrtAnDieserKreuzung/VorfahrtAnDieserKreuzung.i3d
deleted file mode 100644
index 05ec2c796..000000000
--- a/img/VorfahrtAnDieserKreuzung/VorfahrtAnDieserKreuzung.i3d
+++ /dev/null
@@ -1,191 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/img/VorfahrtAnDieserKreuzung/texture0.dds b/img/VorfahrtAnDieserKreuzung/texture0.dds
deleted file mode 100644
index a69c7b536..000000000
Binary files a/img/VorfahrtAnDieserKreuzung/texture0.dds and /dev/null differ
diff --git a/img/arrow.dds b/img/arrow.dds
deleted file mode 100644
index d1846e9ac..000000000
Binary files a/img/arrow.dds and /dev/null differ
diff --git a/img/blank.dds b/img/blank.dds
deleted file mode 100644
index 0a732639c..000000000
Binary files a/img/blank.dds and /dev/null differ
diff --git a/img/blank_hover.dds b/img/blank_hover.dds
deleted file mode 100644
index 00daeaed3..000000000
Binary files a/img/blank_hover.dds and /dev/null differ
diff --git a/img/close.dds b/img/close.dds
deleted file mode 100644
index 9d9b0ee5f..000000000
Binary files a/img/close.dds and /dev/null differ
diff --git a/img/copy3.dds b/img/copy3.dds
deleted file mode 100644
index feb8b198b..000000000
Binary files a/img/copy3.dds and /dev/null differ
diff --git a/img/delete.dds b/img/delete.dds
deleted file mode 100644
index 83d6f2c05..000000000
Binary files a/img/delete.dds and /dev/null differ
diff --git a/img/disk.dds b/img/disk.dds
deleted file mode 100644
index c9775b9d0..000000000
Binary files a/img/disk.dds and /dev/null differ
diff --git a/img/disk_blue.dds b/img/disk_blue.dds
deleted file mode 100644
index c2450d217..000000000
Binary files a/img/disk_blue.dds and /dev/null differ
diff --git a/img/document_delete.dds b/img/document_delete.dds
deleted file mode 100644
index c9c780f78..000000000
Binary files a/img/document_delete.dds and /dev/null differ
diff --git a/img/folder.dds b/img/folder.dds
deleted file mode 100644
index 133513dac..000000000
Binary files a/img/folder.dds and /dev/null differ
diff --git a/img/folder_into.dds b/img/folder_into.dds
deleted file mode 100644
index c5c4ab53e..000000000
Binary files a/img/folder_into.dds and /dev/null differ
diff --git a/img/folder_ok.dds b/img/folder_ok.dds
deleted file mode 100644
index 6ab69ab5b..000000000
Binary files a/img/folder_ok.dds and /dev/null differ
diff --git a/img/hud_bg.dds b/img/hud_bg.dds
deleted file mode 100644
index 5dba39d5b..000000000
Binary files a/img/hud_bg.dds and /dev/null differ
diff --git a/img/navigate_down.dds b/img/navigate_down.dds
deleted file mode 100644
index 400eeffa2..000000000
Binary files a/img/navigate_down.dds and /dev/null differ
diff --git a/img/navigate_left.dds b/img/navigate_left.dds
deleted file mode 100644
index 143a0b33d..000000000
Binary files a/img/navigate_left.dds and /dev/null differ
diff --git a/img/navigate_minus.dds b/img/navigate_minus.dds
deleted file mode 100644
index 50ebef77f..000000000
Binary files a/img/navigate_minus.dds and /dev/null differ
diff --git a/img/navigate_plus.dds b/img/navigate_plus.dds
deleted file mode 100644
index 11c2e6c5c..000000000
Binary files a/img/navigate_plus.dds and /dev/null differ
diff --git a/img/navigate_right.dds b/img/navigate_right.dds
deleted file mode 100644
index 28182fc17..000000000
Binary files a/img/navigate_right.dds and /dev/null differ
diff --git a/img/navigate_up.dds b/img/navigate_up.dds
deleted file mode 100644
index 7ff973dc3..000000000
Binary files a/img/navigate_up.dds and /dev/null differ
diff --git a/img/refresh.dds b/img/refresh.dds
deleted file mode 100644
index e6139977b..000000000
Binary files a/img/refresh.dds and /dev/null differ
diff --git a/input.lua b/input.lua
deleted file mode 100644
index d12d83797..000000000
--- a/input.lua
+++ /dev/null
@@ -1,376 +0,0 @@
-function courseplay:mouseEvent(posX, posY, isDown, isUp, button)
- if isDown and button == 3 and self.isEntered and self.mouse_right_key_enabled then
- if self.mouse_enabled then
- self.mouse_enabled = false
- else
- self.mouse_enabled = true
- if not self.show_hud then
- self.showHudInfoBase = self.min_hud_page
- self.show_hud = true
- end
- end
- InputBinding.setShowMouseCursor(self.mouse_enabled)
- end
- if isDown and button == 1 and self.show_hud and self.isEntered then
- --courseplay:debug(string.format("posX: %f posY: %f",posX,posY), 4)
-
- for _, button in pairs(self.buttons) do
- if button.page == self.showHudInfoBase or button.page == nil or button.page == self.showHudInfoBase * -1 then
-
- if posX > button.x and posX < button.x2 and posY > button.y and posY < button.y2 then
- if InputBinding.isPressed(InputBinding.CP_Modifier_1) then --for some reason InputBinding works in :mouseEvent
- courseplay:debug("CP_Modifier_1 is pressed", 3)
- if button.modifiedParameter ~= nil then
- courseplay:debug("button.modifiedParameter = " .. tostring(button.modifiedParameter), 3)
- self:setCourseplayFunc(button.function_to_call, button.modifiedParameter)
- end
- else
- self:setCourseplayFunc(button.function_to_call, button.parameter)
- end
- end
- end
- end
- end
-end
-
-
-function courseplay:setCourseplayFunc(func, value, noEventSend)
- if noEventSend ~= true then
- CourseplayEvent.sendEvent(self, func, value); -- Die Funktion ruft sendEvent auf und übergibt 3 Werte (self "also mein ID", action, "Ist eine Zahl an der ich festmache welches Fenster ich aufmachen will", state "Ist der eigentliche Wert also true oder false"
- end;
- courseplay:deal_with_mouse_input(self, func, value)
-end
-
-function courseplay:deal_with_mouse_input(self, func, value)
- -- TODO überhaupt nicht DRY das geht bestimmt irgendwie schöner
- if func == "switch_hud_page" then
- courseplay:switch_hud_page(self, value)
- end
-
- if func == "change_combine_offset" then
- courseplay:change_combine_offset(self, value)
- end
-
- if func == "add_course" then
- courseplay:add_course(self, value, false)
- end
-
- if func == "mouse_right_key" then
- courseplay:switch_mouse_right_key_enabled(self)
- end
-
- if func == "key_input" then
- courseplay:key_input(self, value)
- end
-
- if func == "load_course" then
- courseplay:load_course(self, value, false)
- end
-
- if func == "save_course" then
- courseplay:input_course_name(self)
- end
-
- if func == "start" then
- courseplay:start(self, value)
- end
-
- if func == "stop" then
- courseplay:stop(self, value)
- end
-
- if func == "drive_on" then
- self.wait = false
- end
-
- if func == "clear_course" then
- courseplay:clear_course(self, value)
- end
-
- if func == "change_turn_radius" then
- courseplay:change_turn_radius(self, value)
- end
-
- if func == "change_tipper_offset" then
- courseplay:change_tipper_offset(self, value)
- end
-
- if func == "change_required_fill_level" then
- courseplay:change_required_fill_level(self, value)
- end
-
- if func == "change_required_fill_level_for_drive_on" then
- courseplay:change_required_fill_level_for_drive_on(self, value)
- end
-
- if func == "change_turn_speed" then
- courseplay:change_turn_speed(self, value)
- end
-
- if func == "switch_realistic_driving" then
- courseplay:switch_realistic_driving(self, value)
- end
-
-
-
- if func == "change_wait_time" then
- courseplay:change_wait_time(self, value)
- end
-
- if func == "change_num_ai_helpers" then
- --courseplay:change_num_ai_helpers(self, value)
- end
-
- if func == "change_field_speed" then
- courseplay:change_field_speed(self, value)
- end
-
- if func == "change_max_speed" then
- courseplay:change_max_speed(self, value)
- end
-
- if func == "change_unload_speed" then
- courseplay:change_unload_speed(self, value)
- end
-
- if func == "change_RulMode" then
- courseplay:change_RulMode(self, value)
- end
-
- if func == "change_DriveDirection" then
- courseplay:set_direction(self)
- end
-
- if func == "change_DebugLevel" then
- courseplay:change_DebugLevel(value)
- end
-
- if func == "change_use_speed" then
- courseplay:switch_use_speed(self)
- end
-
- if func == "switch_search_combine" then
- courseplay:switch_search_combine(self)
- end
-
- if func == "change_selected_course" then
- courseplay:change_selected_course(self, value)
- end
-
-
- if func == "switch_combine" then
- courseplay:switch_combine(self, value)
- end
-
- if func == "changeWpOffsetX" then
- courseplay:changeCPWpOffsetX(self, value)
- end
-
- if func == "changeWpOffsetZ" then
- courseplay:changeCPWpOffsetZ(self, value)
- end
-
- if func == "changeWorkWidth" then
- courseplay:changeWorkWidth(self, value)
- end
-
- if func == "change_WaypointMode" then
- courseplay:change_WaypointMode(self, value)
- end
-
- if func == "close_hud" then
- self.mouse_enabled = false
- self.show_hud = false
- InputBinding.setShowMouseCursor(self.mouse_enabled)
- end
-
-
- if func == "row1" or func == "row2" or func == "row3" or func == "row4" then
- if self.showHudInfoBase == 0 then
- if self.courseplayers == nil or table.getn(self.courseplayers) == 0 then
- if func == "row1" then
- courseplay:call_player(self)
- end
- else
- if func == "row2" then
- courseplay:start_stop_player(self)
- end
-
- if func == "row3" then
- courseplay:send_player_home(self)
- end
-
- if func == "row4" then
- courseplay:switch_player_side(self)
- end
- end
- end
- if self.showHudInfoBase == 1 then
- if self.play then
- if not self.drive then
- if func == "row3" then
- courseplay:reset_course(self)
- end
-
- if func == "row1" then
- courseplay:start(self)
- end
-
- if (table.getn(self.Waypoints) >= 4) and not self.createCourse then
- if func == "row4" then
- courseplay:set_FieldPoint(self)
- end
- end
-
-
-
- else -- not drving
- local last_recordnumber = nil
-
- if self.recordnumber > 1 then
- last_recordnumber = self.recordnumber - 1
- else
- last_recordnumber = 1
- end
-
- if last_recordnumber ~= nil and self.Waypoints[last_recordnumber].wait and self.wait and func == "row2" then
- self.wait = false
- end
-
- if func == "row2" and self.StopEnd and (self.recordnumber == self.maxnumber or self.currentTipTrigger ~= nil) then
- self.StopEnd = false
- end
-
- if func == "row1" then
- courseplay:stop(self)
- end
-
- if not self.loaded and func == "row3" then
- self.loaded = true
- end
-
- if not self.StopEnd and func == "row4" then
- self.StopEnd = true
- end
-
-
- end -- end not driving
- end -- not playing
-
-
- if not self.drive then
- if (not self.record and not self.record_pause) and not self.play then --- - and (table.getn(self.Waypoints) == 0) then
- if (table.getn(self.Waypoints) == 0) and not self.createCourse then
- if func == "row1" then
- courseplay:start_record(self)
- end
- end
-
-
-
- elseif (not self.record and not self.record_pause) and (table.getn(self.Waypoints) ~= 0) and self.play then
- if func == "row2" then
- courseplay:change_ai_state(self, 1)
- end
- else
- if func == "row1" then
- courseplay:stop_record(self)
- end
-
-
- if not self.record_pause then
- if func == "row2" then --and self.recordnumber > 3
- courseplay:set_waitpoint(self)
- end
-
- if func == "row4" then --and self.recordnumber > 3
- courseplay:set_crossing(self)
- end
-
- if func == "row3" then --and self.recordnumber > 3
- courseplay:interrupt_record(self)
- end
-
- else
- if func == "row2" then --and self.recordnumber > 4
- courseplay:delete_waypoint(self)
- end
- if func == "row3" then
- courseplay:continue_record(self)
- end
- end
- end
- end
- end
- end
-end
-
-
-function courseplay:key_input(self, unicode)
- if 31 < unicode and unicode < 127 then
- if self.user_input ~= nil then
- if self.user_input:len() <= 20 then
- self.user_input = self.user_input .. string.char(unicode)
- end
- end
- end
-
- -- backspace
- if unicode == 8 then
- if self.user_input ~= nil then
- if self.user_input:len() >= 1 then
- self.user_input = self.user_input:sub(1, self.user_input:len() - 1)
- end
- end
- end
-
- -- enter
- if unicode == 13 then
- courseplay:handle_user_input(self)
- end
-end
-
-
--- deals with keyEvents
-function courseplay:keyEvent(unicode, sym, modifier, isDown)
- -- user input fu
- if isDown and self.user_input_active then
- self:setCourseplayFunc("key_input", unicode)
- end
-end
-
-
-
--- does something with the user input
-function courseplay:handle_user_input(self)
- -- name for current_course
- if self.save_name then
- --courseplay:load_courses(self)
- self.user_input_active = false
- self.current_course_name = self.user_input
- local maxID = 0
- for i = 1, table.getn(g_currentMission.courseplay_courses) do
- if g_currentMission.courseplay_courses[i].id ~= nil then
- if g_currentMission.courseplay_courses[i].id > maxID then
- maxID = g_currentMission.courseplay_courses[i].id
- end
- end
- end
- self.courseID = maxID + 1
- course = { name = self.current_course_name, id = self.courseID, waypoints = self.Waypoints }
- if g_currentMission.courseplay_courses == nil then
- g_currentMission.courseplay_courses = {}
- end
- table.insert(g_currentMission.courseplay_courses, course)
-
- self.user_input = ""
- self.user_input_message = nil
- self.steeringEnabled = true --test
- courseplay:save_courses(self)
- end
-end
-
--- renders input form
-function courseplay:user_input(self)
- renderText(0.4, 0.9, 0.02, self.user_input_message .. self.user_input);
-end
diff --git a/modDesc.xml b/modDesc.xml
deleted file mode 100644
index cc00c5bf9..000000000
--- a/modDesc.xml
+++ /dev/null
@@ -1,818 +0,0 @@
-
-
- Hummel (modhoster.de) /Lautschreier/Wolverin0815/Bastian82
-
- Courseplay - Abfahrhelfer
- Courseplay - Abfahrhelfer
-
-
-
-
-
-
-
-
-
-
-
- store.dds
-
- 3.2
-
-
-
- Start course recording
- Kursaufzeichnung beginnen
- Commencer l'enregistrement de la course
-
-
- Fahrtrichtung
- Direction
- Direction
-
-
- vorwärts
- forwards
- avant
-
-
- rückwärts
- reverse
- arriére
-
-
- Stop course recording
- Kursaufzeichnung beenden
- Arreter l'enregistrement de la course
-
-
- Pause course recording
- Kursaufzeichnung anhalten
- Interrompre l'enregistrement de la course
-
-
- Continue course recording
- Kursaufzeichnung fortsetzen
- Reprendre l'enregistrement de la course
-
-
- Delete last waypoint
- Letzten Wegpunkt löschen
- Supprimer le dernier point
-
-
- Driver
- Abfahrer
- Chauffeur
-
-
- Start driver
- Abfahrer starten
- Demarrer le chauffeur
-
-
- Stop driver
- Abfahrer stoppen
- Arrêter le chauffeur
-
-
- Stop at last point or at next trigger
- Warten am letzten Wegpunkt oder Trigger
- Arrêter au prochain point ou trigger
-
-
- Driver side
- Abfahrerseite
- Coté du chauffeur
-
-
- automatic
- automatisch
- automatique
-
-
- left
- links
- gauche
-
-
- right
- rechts
- droite
-
-
- Send driver home
- Abfahrer wegschicken
- Renvoyer le chauffeur au début
-
-
- Request driver
- Abfahrer rufen
- Appeler un chauffeur
-
-
- Driver requested
- Abfahrer gerufen
- Chauffeur appelé
-
-
- Drive Course
- Abfahrer einstellen
- Démarrer la course
-
-
- Drive stop
- Abfahrer entlassen
- Arrêter la course
-
-
- Type: Drivinghelper (Load at start)
- Typ: Abfahrer (Beladung am Startpunkt)
- Type: Aide à la conduite (Chargement au démarrage)
-
-
- Type: Combi (empty combine and offload)
- Typ: kombiniert (Drescher abtanken und abfahren)
- Type: Batteuse (La remorque suit la Batteuse)
-
-
- Type: Overloader (empty combine and offload to trailer)
- Typ: Überladewagen (Drescher abtanken)
- Type: Transbordeur (Dechargement de la Batteuse)
-
-
- Type: fertilice and seeding
- Typ: Düngen und Säen
- Type: Fertiliser et semer
-
-
- Type: Target (drive from start to finish)
- Typ: Überführung (Route abfahren)
- Type: Route (voyage du début jusqu'a la fin de la course)
-
-
- Type: Fieldwork for balers, forage wagons, baleloaders
- Typ: Feldarbeit, Ballen pressen, Heu und Ballen sammeln
- Type: Travail des champs: Presse, chargeur à ballots...
-
-
- Type: Combine drives to trailer and unloads
- Typ: Drescher fährt selbst abtanken
- Type: Batteuse va à la remorque pour vider
-
-
- Type: Manure transporter
- Typ: Güllezubringer
- Type: Transport de fumier
-
-
- Set waitpoint
- Hier Wartepunkt setzen
- Placer un point d'attente
-
-
- Set crossing
- Hier Kreuzungspunkt setzen
- Placer un point de croisement
-
-
- Set fieldpoint
- Feldgrenze festlegen
- Placer un point de champs
-
-
- start
- weiterfahren
- Début
-
-
- Save course
- Kurs speichern
- Sauvegarder la course
-
-
- Load course
- Kurs laden
- Charger une course
-
-
- Delete course
- Kurs aus Datei löschen
- Supprimer la course
-
-
- Reset course
- Wegpunkte löschen
- Réinitialiser la course
-
-
- Generate course
- Kurs generieren
- Générer la course
-
-
- Courseplay HUD
- Courseplay HUD
- Courseplay HUD
-
-
- Switch Mousecontrol
- Maussteuerung aktivieren
- Passer au contrôle à la souris
-
-
- Change mode
- Abfahrer-Typ wechseln
- Changer de mode
-
-
- Drive now
- Sofort abfahren
- Démarrer maintenant
-
-
- Drive on at %
- Abfahren bei %
- Partir à %
-
-
- CP Input 1
- AH Taste 1
- CP entrée 1
-
-
- CP Input 2
- AH Taste 2
- CP entrée 2
-
-
- CP Input 3
- AH Taste 3
- CP entrée 3
-
-
- CP Input 4
- AH Taste 4
- CP entrée 4
-
-
- unknown
- unbekannt
- inconnu
-
-
- distance
- Entfernung
- distance
-
-
- Waiting time
- Haltezeit
- Temps d'attente
-
-
- Load course:
- Kurs laden:
- Parcours chargé:
-
-
- Course name:
- Name des Kurses:
- Nom de la course:
-
-
- has reached overload point.
- hat Überladepunkt erreicht.
- a atteint le point de déchargement.
-
-
- has reached waiting point.
- hat Wartepunkt erreicht.
- a atteint le point d'attente.
-
-
- has reached end point.
- hat den Tigger bzw. das Ende der Route erreicht.
- a atteint la fin de la course.
-
-
- has finished work.
- hat die Aufgabe erledigt.
- a terminé le travail.
-
-
- ready for unloading bales.
- bereit zum Ballen entladen.
- pret à décharger les ballots.
-
-
- unloading bales.
- Ballen werden entladen.
- decharge les ballots.
-
-
- is in traffic.
- steckt im Verkehr fest
- est coincé.
-
-
- Loading: %d of %d
- Wird Beladen: %d von %d
- Chargement: %d sur %d
-
-
- tip trigger reached
- Abladestelle erreicht
- Le trigger est atteint
-
-
- Unloading: %d of %d
- Wird entladen: %d von %d
- Déchargement: %d sur %d
-
-
- Show waypoints
- Wegpunkte anzeigen
- Montrer les points
-
-
- on
- eingeschaltet
- activé
-
-
- Pathfinding
- Fruchtumfahrung
- Evite les cultures
-
-
- off
- ausgeschaltet
- désactivé
-
-
- Side offset:
- seitl. Abstand:
- Distance latéral:
-
-
- Start at %:
- Start bei %:
- Demarrer à %:
-
-
- Turning cirlce:
- Wendekreis:
- Rayon de braquage:
-
-
- pipe offset:
- Pipe Abstand:
- Distance Av/Ar:
-
-
- maximum AI helpers:
- max. Anz. AI Helfer:
- Aide AI au max.:
-
-
- Combine
- Drescher
- Batteuse
-
-
- none
- keiner
- Aucun
-
-
- Choose combine:
- Drescher wählen:
- Choix de Batteuse:
-
-
- Find combine:
- Dreschersuche:
- Type de recherche:
-
-
- Current:
- Aktuell:
- Actuelle:
-
-
- automatic search
- automatisch finden
- recherche automatique
-
-
- select manually
- manuell zuweisen
- choisir manuellement
-
-
- Copy course:
- Kurs kopieren:
- Importer une course:
-
-
- Vehicle
- Fahrzeug
- véhicule
-
-
- temporary course
- temporärer Kurs
- course temporaire
-
-
- Turn speed:
- Wendemanöver:
- Vitesse de virage:
-
-
- Field speed:
- Auf dem Feld:
- Vitesse de champs:
-
-
- Street speed:
- Auf Straße:
- Vitesse de route:
-
-
- Unload (BGA):
- Abladen (BGA):
- Décharger (BGA):
-
-
- Speed:
- Geschwindigkeit:
- Vitesse:
-
-
- from recording
- wie beim einfahren
- même que l'enregistrement
-
-
- maximum speed
- maximale Geschwindigkeit
- vitesse maximal
-
-
- mph
- km/h
- km/h
-
-
- automatic (from course)
- automatisch (vom Kurs)
- automatique
-
-
- Course:
- Kurs:
- Course:
-
-
- course: no course loaded
- Kurs: kein Kurs geladen
- course: pas de course chargée
-
-
- waypoint:
- Wegpunkt:
- Points:
-
-
- no waypoints yet
- Noch keine Wegpunkte
- pas de points
-
-
- only when recording
- nur bei Aufnahme
- lors de l'enregistrement
-
-
- own waypoints
- eigene Wegpunkte
- mes propres points
-
-
- without crosspoints
- ohne Kreuzungspunkte
- sans les croisements
-
-
- show all
- alle
- montrer les tous
-
-
- none
- keine
- aucun
-
-
- Beacon lights:
- Rundumleuchte:
- Girophares:
-
-
- only on the road
- Auf der Straße
- seulement sur la route
-
-
- always turn on
- eingeschaltet
- toujours allumés
-
-
- never turn on
- ausgeschaltet
- jamais allumés
-
-
- Courseplay control
- Abfahrhelfer Steuerung
- Courseplay control
-
-
- Driver managment
- Abfahrer steuern
- Gestion de la conduite
-
-
- Manage courses
- Kurse verwalten
- Gestion des courses
-
-
- no work area at this course
- Kein Arbeitsbereich in diesem Kurs
- Pas de zone de trvail
-
-
- combined courses
- kombinierte Kurse
- Course combiné
-
-
- Settings combi mode
- Einstellungen Combi Modus
- Option du mode batteuse
-
-
- Manage combines
- Drescher verwalten
- Gestion des batteuses
-
-
- SPEED LIMIT
- Geschwindigkeiten
- Vitesse limite
-
-
- DRIVE SETTINGS
- Fahr- Arbeitseinstellungen
- Paramètres de conduite
-
-
- Combine is turning
- Drescher wendet
- La batteuse tourne
-
-
- Drive behind combine
- Fahre hinter Drescher
- Conduit derriere la batteuse
-
-
- Drive next to combine
- Fahre neben Drescher
- Conduit à coté de la batteuse
-
-
- drive to combine
- Fahre zu Drescher
- Conduit vers la batteuse
-
-
- Combine is telling me to stop
- Drescher sagt ich soll anhalten
- La batteuse me demande de m'arreter
-
-
- Turning to direction %d %d
- wende in Richtung koordinaten %d %d
- Tourne en direction de %d %d
-
-
- Drive to waypoint %d %d
- fahre zu Wegpunkt %d %d
- Conduit vers le points %d %d
-
-
- Waiting until fill level is reached
- Warte bis Füllstand erreicht ist
- Attend que le niveau soit atteint
-
-
- No combine in reach
- Kein Drescher in Reichweite
- Pas de Batteuse en vue
-
-
- Waiting until combine has turned
- Warte bis Drescher gewendet hat
- Attend que la batteuse ait finis de tourner
-
-
- Waiting for new waypoint
- Warte bis ich neuen Wegpunkt habe
- Attend pour le nouveau point
-
-
- Following tractor
- Fahre hinter Traktor
- Suit le tracteur
-
-
- should be refueled soon
- sollte aufgetankt werden
- doit bientôt faire le plein
-
-
- must be refueled
- muss aufgetankt werden
- doit faire le plein
-
-
- is being refueled
- wird aufgetankt
- est en train d'être ravitailler
-
-
- wrong trailer for this mode
- falscher Trailer für diesen Modus
- pas la bonne remorque pour ce mode
-
-
- ESLimiter version is not supported
- ESLimiter-Version wird nicht unterstützt
- la version du ESLimiter n'est pas compatible
-
-
- Settings
- Allgemeine Einstellungen
- Paramètres
-
-
- Waypoint-X Offset
- versetzt fahren
- décalage latéral
-
-
- Waypoint-Z Offset
- Versetzt fahren
- décalage Av/Ar
-
-
- working width
- Arbeitsbreite
- largeur de travail
-
-
- would like to go swimming
- möchte baden gehen
- a voulut prendre un bain
-
-
- wait points:
- Wartepunkte:
- Points d'attente:
-
-
- crossing points:
- Kreuzungspunkte:
- Points de croisement:
-
-
- open Courseplay:
- Courseplay öffnen:
- Ouverture de Courseplay:
-
-
- right mouse button
- rechte Maustaste
- clic droit de la souris
-
-
- Debug level
- Debug-Level
- Niveau de débogage
-
-
- 0: nothing
- 0: nichts
- 0: rien
-
-
- 1: not detailed
- 1: undetailliert
- 1: pas détaillé
-
-
- 2: semi-important
- 2: semi-wichtig
- 3: semi-detaillé
-
-
- 3: important
- 3: wichtig
- 3: important
-
-
- 4: everything (most detailed)
- 4: alles (detailliert)
- 4: tout (le plus détaillé)
-
-
- Show Courseplay HUD
- Courseplay HUD öffnen
- Montrer le Courseplay HUD
-
-
- Hide Courseplay HUD
- Courseplay HUD schließen
- Cacher le Courseplay HUD
-
-
- Courseplay options
- Courseplay-Optionen
- Options du Courseplay
-
-
- Courseplay HUD
- Courseplay HUD
- Courseplay HUD
-
-
- Courseplay key modifier 1
- Courseplay Extrataste 1
- Courseplay touche 1
-
-
- Courseplay key modifier 2
- Courseplay Extrataste 2
- Courseplay touche 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/mode1.lua b/mode1.lua
deleted file mode 100644
index 0f96e997e..000000000
--- a/mode1.lua
+++ /dev/null
@@ -1,58 +0,0 @@
--- handles "mode1" : waiting at start until tippers full - driving course and unloading on trigger
-function courseplay:handle_mode1(self)
- local allowedToDrive = true
- local active_tipper = nil
- local tipper_fill_level, tipper_capacity = self:getAttachedTrailersFillLevelAndCapacity()
-
- if tipper_fill_level == nil then tipper_fill_level = 0 end
- if tipper_capacity == nil then tipper_capacity = 0 end
-
-
- -- done tipping
- if self.unloading_tipper ~= nil and self.unloading_tipper.fillLevel == 0 then
- self.unloading_tipper = nil
- if tipper_fill_level == 0 then
- self.unloaded = true
- self.max_speed_level = 3
- self.currentTipTrigger = nil
- end
- end
-
- -- tippers are not full
- -- tipper should be loaded 10 meters before wp 2
- --if self.loaded ~= true and ((self.recordnumber == 2 and tipper_fill_level < tipper_capacity and self.unloaded == false and self.dist < 10) or self.lastTrailerToFillDistance) then
- if self.loaded ~= true and ((self.recordnumber == 2 and tipper_fill_level < tipper_capacity and self.unloaded == false ) or self.lastTrailerToFillDistance) then
- allowedToDrive = courseplay:load_tippers(self)
- self.info_text = string.format(courseplay:get_locale(self, "CPloading"), tipper_fill_level, tipper_capacity)
- end
-
- -- damn, i missed the trigger!
-
- if self.currentTipTrigger ~= nil then
- local trigger_id = self.currentTipTrigger.triggerId
-
- if self.currentTipTrigger.specialTriggerId ~= nil then
- trigger_id = self.currentTipTrigger.specialTriggerId
- end
-
- local trigger_x, trigger_y, trigger_z = getWorldTranslation(trigger_id)
- local ctx, cty, ctz = getWorldTranslation(self.rootNode);
- local distance_to_trigger = courseplay:distance(ctx, ctz, trigger_x, trigger_z)
-
- if distance_to_trigger > 60 then
- self.currentTipTrigger = nil
- end
-
- end
-
- -- tipper is not empty and tractor reaches TipTrigger
- if tipper_fill_level > 0 and self.currentTipTrigger ~= nil and self.recordnumber > 3 then
- self.max_speed_level = 1
- allowedToDrive = courseplay:unload_tippers(self)
-
-
- self.info_text = courseplay:get_locale(self, "CPTriggerReached") -- "Abladestelle erreicht"
- end
-
- return allowedToDrive
-end
\ No newline at end of file
diff --git a/mode2.lua b/mode2.lua
deleted file mode 100644
index cf8737907..000000000
--- a/mode2.lua
+++ /dev/null
@@ -1,1078 +0,0 @@
--- AI-states
--- 0 Default, wenn nicht in Mode2 aktiv
--- 1 warte am startpunkt auf arbeit
--- 2 fahre hinter drescher
--- 3 fahre zur pipe / abtanken
--- 4 fahre ans heck des dreschers
--- 5 wegpunkte abfahren
--- 7 warte auf die Pipe
--- 6 fahre hinter traktor
--- 8 alle trailer voll
--- 81 alle trailer voll, schlepper wendet von maschine weg
--- 9 wenden
--- 10 seite wechseln
-
-function courseplay:handle_mode2(self, dt)
- local curFile = "mode2.lua"
- local allowedToDrive = false
-
- local tipper_fill_level, tipper_capacity = self:getAttachedTrailersFillLevelAndCapacity()
-
- if tipper_fill_level == nil then
- tipper_fill_level = 0
- end
- if tipper_capacity == nil then
- tipper_capacity = 0
- end
-
- local fill_level = 0
- if tipper_capacity ~= 0 then
- fill_level = tipper_fill_level * 100 / tipper_capacity
- end
-
- if fill_level > self.required_fill_level_for_follow then
- self.allow_following = true
- else
- self.allow_following = false
- end
-
- if self.ai_state == 0 then
- self.ai_state = 1
- end
-
-
- if self.ai_state == 1 and self.active_combine ~= nil then
- courseplay:unregister_at_combine(self, self.active_combine)
- end
-
- -- trailer full
- if self.ai_state == 8 then
- self.recordnumber = 2
- courseplay:unregister_at_combine(self, self.active_combine)
- self.ai_state = 0
- self.loaded = true
- return false
- end
-
- -- support multiple tippers
- if self.currentTrailerToFill == nil then
- self.currentTrailerToFill = 1
- end
-
- local current_tipper = self.tippers[self.currentTrailerToFill]
-
- if current_tipper == nil then
- self.tools_dirty = true
- return false
- end
-
-
- -- switch side
- if self.active_combine ~= nil and (self.ai_state == 10 or self.active_combine.turnAP ~= nil and self.active_combine.turnAP == true) then
- if self.combine_offset > 0 then
- self.target_x, self.target_y, self.target_z = localToWorld(self.active_combine.rootNode, 25, 0, 0)
- else
- self.target_x, self.target_y, self.target_z = localToWorld(self.active_combine.rootNode, -25, 0, 0)
- end
- self.ai_state = 5
- self.next_ai_state = 2
- end
-
- if (current_tipper.fillLevel == current_tipper.capacity) or self.loaded or (fill_level >= self.required_fill_level_for_drive_on and self.ai_state == 1) then
- if table.getn(self.tippers) > self.currentTrailerToFill then
- self.currentTrailerToFill = self.currentTrailerToFill + 1
- else
- self.currentTrailerToFill = nil
- --courseplay:unregister_at_combine(self, self.active_combine)
- if self.ai_state ~= 5 then
- if self.combine_offset > 0 then
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, self.turn_radius, 0, self.turn_radius)
- else
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, -self.turn_radius, 0, self.turn_radius)
- end
- self.ai_state = 5
- self.next_ai_state = 81
- end
- end
- end
-
-
- if self.active_combine ~= nil then
- if self.courseplay_position == 1 then
- -- is there a trailer to fill, or at least a waypoint to go to?
- if self.currentTrailerToFill or self.ai_state == 5 then
- if self.ai_state == 6 then
- -- drive behind combine: self.ai_state = 2
- -- drive next to combine:
- self.ai_state = 3
- end
- courseplay:unload_combine(self, dt)
- end
- else
- -- follow tractor in front of me
- tractor = self.active_combine.courseplayers[self.courseplay_position - 1]
- -- courseplay:follow_tractor(self, dt, tractor)
- self.ai_state = 6
- courseplay:unload_combine(self, dt)
- end
- elseif self.ai_mode == 5 and self.next_ai_state == 81 then
- courseplay:unload_combine(self, dt)
- else -- NO active combine
- -- STOP!!
- if g_server ~= nil then
- AIVehicleUtil.driveInDirection(self, dt, self.steering_angle, 0, 0, 28, false, moveForwards, 0, 1)
- end
-
- if self.loaded then
- self.recordnumber = 2
- self.ai_state = 1
- return false
- end
-
- -- are there any combines out there that need my help?
- if self.timeout < self.timer then
- courseplay:update_combines(self)
- courseplay:set_timeout(self, 5000)
- end
-
- --is any of the reachable combines full?
- if self.reachable_combines ~= nil then
- if table.getn(self.reachable_combines) > 0 then
- -- choose the combine that needs me the most
- if self.best_combine ~= nil then
- courseplay:debug(tostring(self.id)..": request check in: "..tostring(self.combineID), 1)
- if courseplay:register_at_combine(self, self.best_combine) then
- local leftFruit, rightFruit = courseplay:side_to_drive(self, self.best_combine, -10) --changed by THOMAS
- self.ai_state = 2
- end
- else
- self.info_text = courseplay:get_locale(self, "CPwaitFillLevel") --TODO: g_i18n
- end
-
-
- local highest_fill_level = 0;
- local num_courseplayers = 0;
- local distance = 0;
-
- self.best_combine = nil;
- self.combineID = 0;
- self.distanceToCombine = 99999999999;
-
- -- chose the combine who needs me the most
- for k, combine in pairs(self.reachable_combines) do
- if (combine.grainTankFillLevel >= (combine.grainTankCapacity * self.required_fill_level_for_follow / 100)) or combine.grainTankCapacity == 0 or combine.wants_courseplayer then
- if combine.grainTankCapacity == 0 then
- if combine.courseplayers == nil then
- self.best_combine = combine
- elseif table.getn(combine.courseplayers) <= num_courseplayers or self.best_combine == nil then
- num_courseplayers = table.getn(combine.courseplayers)
- if table.getn(combine.courseplayers) > 0 then
- if combine.courseplayers[1].allow_following then
- self.best_combine = combine
- end
- else
- self.best_combine = combine
- end
- end
-
- elseif combine.grainTankFillLevel >= highest_fill_level and combine.isCheckedIn == nil then
- highest_fill_level = combine.grainTankFillLevel
- self.best_combine = combine
- local cx, cy, cz = getWorldTranslation(combine.rootNode)
- local sx, sy, sz = getWorldTranslation(self.rootNode)
- distance = courseplay:distance(sx, sz, cx, cz)
- self.distanceToCombine = distance
- self.combineID = combine.id
- end
- end
- end
-
- if self.combineID ~= 0 then
- courseplay:debug(tostring(self.id).." : call combine: "..tostring(self.combineID), 1)
- end
-
- else
- --self.info_text = "Kein Drescher in Reichweite"
- self.info_text = courseplay:get_locale(self, "CPnoCombineInReach")
- end
- end
- end
- return allowedToDrive
-end
-
-function courseplay:unload_combine(self, dt)
- local curFile = "mode2.lua"
- local allowedToDrive = true
- local combine = self.active_combine
- local x, y, z = getWorldTranslation(self.aiTractorDirectionNode)
- local currentX, currentY, currentZ = nil, nil, nil
-
- --local sl = nil --kann die weg??
- local mode = self.ai_state
- local combine_fill_level, combine_turning = nil, false
- local refSpeed = nil
- local handleTurn = false
- local cornChopper = false
- local isHarvester = false
- local tipper_fill_level, tipper_capacity = self:getAttachedTrailersFillLevelAndCapacity()
- local tipper_percentage = tipper_fill_level / tipper_capacity * 100
- local xt, yt, zt = nil, nil, nil
- local dod = nil
-
- -- Calculate Trailer Offset
-
- if self.currentTrailerToFill ~= nil then
- xt, yt, zt = worldToLocal(self.tippers[self.currentTrailerToFill].fillRootNode, x, y, z)
- else
- courseplay:debug("this should never happen - no currentTrailerToFillSet", 4)
- xt, yt, zt = worldToLocal(self.tippers[1].rootNode, x, y, z)
- end
-
- -- support for tippers like hw80
- if zt < 0 then
- zt = zt * -1
- end
-
- local trailer_offset = zt + self.tipper_offset
-
-
- if self.sl == nil then
- self.sl = 3
- end
-
- if self.isChopperTurning == nil then
- self.isChopperTurning = false
- end
- -- is combine turning ?
- if combine ~= nil and (combine.turnStage == 1 or combine.turnStage == 2 or combine.turnStage == 5) then
- self.info_text = courseplay:get_locale(self, "CPCombineTurning") -- "Drescher wendet. "
- combine_turning = true
- end
-
- if combine.grainTankCapacity > 0 then
- combine_fill_level = combine.grainTankFillLevel * 100 / combine.grainTankCapacity
- else -- combine is a chopper / has no tank
- combine_fill_level = 51
- cornChopper = true
- end
-
-
- if mode == 2 or mode == 3 or mode == 4 then
- if combine == nil then
- self.info_text = "this should never happen" --TODO: change text to something less dramatic
- allowedToDrive = false
- end
- end
-
-
-
- local offset_to_chopper = self.combine_offset
- if combine.turnStage ~= 0 then
- offset_to_chopper = self.combine_offset * 1.6 --1,3
- end
-
-
- local x1, y1, z1 = worldToLocal(combine.rootNode, x, y, z)
- local distance = Utils.vector2Length(x1, z1)
-
- if mode == 2 then -- Drive to Combine or Cornchopper
- self.sl = 2
- refSpeed = self.field_speed
- --courseplay:remove_from_combines_ignore_list(self, combine)
- self.info_text = courseplay:get_locale(self, "CPDriveBehinCombine") -- ""
-
- local x1, y1, z1 = worldToLocal(combine.rootNode, x, y, z)
-
- if z1 > -10 then -- tractor in front of combine --0
- -- left side of combine
- local cx_left, cy_left, cz_left = localToWorld(combine.rootNode, 20, 0, -20) --20,0, -30 (war 20,0,-25
- -- righ side of combine
- local cx_right, cy_right, cz_right = localToWorld(combine.rootNode, -20, 0, -20) -- -20,0,-30 -20,0,-25
- local lx, ly, lz = worldToLocal(self.aiTractorDirectionNode, cx_left, y, cz_left)
- -- distance to left position
- local disL = Utils.vector2Length(lx, lz)
- local rx, ry, rz = worldToLocal(self.aiTractorDirectionNode, cx_right, y, cz_right)
- -- distance to right position
- local disR = Utils.vector2Length(rx, rz)
-
- if disL < disR then
- currentX, currentY, currentZ = cx_left, cy_left, cz_left
- else
- currentX, currentY, currentZ = cx_right, cy_right, cz_right
- end
-
- else
- -- tractor behind combine
- currentX, currentY, currentZ = localToWorld(combine.rootNode, 0, 0, -25)
- end
-
- --if not self.calculated_course then
- -- if courseplay:calculate_course_to(self, currentX, currentZ) then
- -- mode = 5
- -- self.shortest_dist = nil
- -- -- ai_state when waypoint is reached
- -- self.next_ai_state = 2
- -- end
-
- -- end
-
- local lx, ly, lz = worldToLocal(self.aiTractorDirectionNode, currentX, currentY, currentZ)
- dod = Utils.vector2Length(lx, lz)
- -- near point
- if dod < 3 then -- change to mode 4 == drive behind combine or cornChopper
-
- if cornChopper then -- decide on which side to drive based on ai-combine
- local leftFruit, rightFruit = courseplay:side_to_drive(self, combine, 10);
- if combine.forced_side == nil then
- if leftFruit > rightFruit then
- if self.combine_offset > 0 then
- self.combine_offset = math.abs(self.combine_offset) * -1;
- self.sideToDrive = "right"
- end
- elseif leftFruit == rightFruit then
- if self.combine_offset < 0 then
- self.combine_offset = math.abs(self.combine_offset) * -1;
- self.sideToDrive = "left"
- end
- end
- elseif combine.forced_side == "right" then
- self.sideToDrive = "right";
- self.combine_offset = math.abs(self.combine_offset) * -1;
- else
- self.sideToDrive = "left";
- self.combine_offset = math.abs(self.combine_offset);
- end
-
- end
- mode = 4
- end
-
- -- end mode 2
- elseif mode == 4 then -- Drive to rear Combine or Cornchopper
-
- self.info_text = courseplay:get_locale(self, "CPDriveToCombine") -- "Fahre zum Drescher"
- --courseplay:add_to_combines_ignore_list(self, combine)
- refSpeed = self.field_speed
-
- local tX, tY, tZ = nil, nil, nil
-
- if cornChopper then
- tX, tY, tZ = localToWorld(combine.rootNode, self.combine_offset * 0.8, 0, -5) -- offste *0.6 !????????????
- else
- tX, tY, tZ = localToWorld(combine.rootNode, self.combine_offset, 0, -5)
- end
-
- if combine.attachedImplements ~= nil then
- for k, i in pairs(combine.attachedImplements) do
- local implement = i.object;
- if implement.haeckseldolly == true then
- tX, tY, tZ = localToWorld(implement.rootNode, self.combine_offset, 0, trailer_offset)
- end
- end
- end
-
- currentX, currentZ = tX, tZ
-
- local lx, ly, lz = nil, nil, nil
-
- lx, ly, lz = worldToLocal(self.aiTractorDirectionNode, tX, y, tZ)
-
- if currentX ~= nil and currentZ ~= nil then
- local lx, ly, lz = worldToLocal(self.aiTractorDirectionNode, currentX, y, currentZ)
- dod = Utils.vector2Length(lx, lz)
- else
- dod = Utils.vector2Length(lx, lz)
- end
-
-
- if dod < 2 then -- dod < 2
- allowedToDrive = false
- mode = 3 -- change to mode 3 == drive to unload pipe
- self.isChopperTurning = false
- end
-
- if dod > 50 then
- mode = 2
- end
-
- elseif mode == 3 then --drive to unload pipe
-
- self.info_text = courseplay:get_locale(self, "CPDriveNextCombine") -- "Fahre neben Drescher"
- --courseplay:add_to_combines_ignore_list(self, combine)
- refSpeed = self.field_speed
-
- if self.next_targets ~= nil then
- self.next_targets = {}
- end
-
- if combine_fill_level == 0 then --combine empty set waypoints on the field !!!
- local leftFruit, rightFruit = courseplay:side_to_drive(self, combine, -10)
- local tempFruit
-
- if not combine.waitingForDischarge and combine.waitForTurnTime > combine.time then
- --Fruit side switch at end of field line
- tempFruit = leftFruit;
- leftFruit = rightFruit;
- rightFruit = tempFruit;
- end;
-
- local offset = math.abs(self.combine_offset)
- if self.combine_offset > 0 then --I'm left
- if leftFruit < rightFruit then
- courseplay:debug("I'm left, fruit is right",1)
- local fx,fy,fz = localToWorld(self.rootNode, 0, 0, 3)
- if courseplay:is_field(fx, fz) then
- courseplay:debug("target is on field",1)
- mode = 1
- else
- courseplay:debug("target is not on field",1)
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, 2 , 0, -self.turn_radius);
- courseplay:set_next_target(self, -offset , -self.turn_radius-trailer_offset);
- mode = 5
- end
- else
- courseplay:debug("I'm left, fruit is left",1)
- local fx,fy,fz = localToWorld(self.rootNode, 2*offset*-1, 0, -self.turn_radius-trailer_offset)
- if courseplay:is_field(fx, fz) then
- courseplay:debug("deepest waypoint is on field",1)
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, 2, 0, -self.turn_radius-trailer_offset);
- courseplay:set_next_target(self, 2*offset*-1 , -self.turn_radius-trailer_offset);
- fx,fy,fz = localToWorld(self.rootNode, 2*offset*-1, 0, 0)
- if courseplay:is_field(fx, fz) then
- courseplay:debug("traget is on field",1)
- courseplay:set_next_target(self, 2*offset*-1,0);
- else
- courseplay:debug("target is not on field",1)
- courseplay:set_next_target(self, 2*offset*-1 , -(2*self.turn_radius)-trailer_offset);
- end
- mode = 5
- else
- courseplay:debug("deepest waypoint is not on field",1)
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, self.turn_radius, 0, 0);
- courseplay:set_next_target(self, 0 , -(2*trailer_offset));
- courseplay:set_next_target(self, 2*offset*-1 , -(2*trailer_offset));
- courseplay:set_next_target(self, 2*offset*-1 , self.turn_radius);
- mode = 5
- end
-
- end
- else
- if leftFruit < rightFruit then
- courseplay:debug("I'm right, fruit is right",1)
- local fx,fy,fz = localToWorld(self.rootNode, 2*offset, 0, -self.turn_radius-trailer_offset)
- if courseplay:is_field(fx, fz) then
- courseplay:debug("deepest waypoint is on field",1)
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, -4, 0, -self.turn_radius-trailer_offset);
- courseplay:set_next_target(self, 2*offset , -self.turn_radius-trailer_offset);
- fx,fy,fz = localToWorld(self.rootNode, 2*offset, 0, 0)
- if courseplay:is_field(fx, fz) then
- courseplay:debug("traget is on field",1)
- courseplay:set_next_target(self, 2*offset,0);
- else
- courseplay:debug("target is not on field",1)
- courseplay:set_next_target(self, 2*offset, -(2*self.turn_radius)-trailer_offset);
- end
- mode = 5
- else
- courseplay:debug("deepest waypoint is not on field",1)
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, -self.turn_radius, 0, 0);
- courseplay:set_next_target(self, 0 , -(2*trailer_offset));
- courseplay:set_next_target(self, 2*offset, -(2*trailer_offset));
- courseplay:set_next_target(self, 2*offset, self.turn_radius);
- mode = 5
- end
- else
- courseplay:debug("I'm right, fruit is left",1)
- local fx,fy,fz = localToWorld(self.rootNode, 0, 0, 3)
- if courseplay:is_field(fx, fz) then
- courseplay:debug("target is on field",1)
- mode = 1
- else
- courseplay:debug("target is not on field",1)
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, -2 , 0, -self.turn_radius);
- courseplay:set_next_target(self, 0, -self.turn_radius-trailer_offset);
- mode = 5
- end
-
- end
-
- end
-
-
- if tipper_percentage >= self.required_fill_level_for_drive_on then
- self.loaded = true
- else
- self.next_ai_state = 1
- end
- end
-
-
- local current_offset = self.combine_offset
- local current_offset_positive = math.abs(self.combine_offset)
-
- --TODO: move all that shit over to combines.lua, or better yet base.lua, so it doesn't have to be calculated constantly
- --TODO: always use combineToPrnX, no matter what?
- local prnX, prnY, prnZ = getTranslation(combine.pipeRaycastNode)
- local cwX, cwY, cwZ = getWorldTranslation(combine.rootNode)
- local prnwX, prnwY, prnwZ = getWorldTranslation(combine.pipeRaycastNode)
- local combineToPrnX, combineToPrnY, combineToPrnZ = worldToLocal(combine.rootNode, prnwX, prnwY, prnwZ)
- --NOTE by Jakob: after a shitload of testing and failing, it seems combineToPrnX is what we're looking for (instead of prnToCombineX). Always results in correct x-distance from combine.rn to prn.
- --TODO: support for Grimme SE75-55
-
-
-
- if not cornChopper and self.auto_combine_offset then
- --courseplay:debug(string.format("%s(%i): %s: cwX=%f, cwZ=%f, prnwX=%f, prnwZ=%f, combineToPrnX=%f, combineToPrnZ=%f", curFile, debug.getinfo(1).currentline, combine.name, cwX, cwZ, prnwX, prnwZ, combineToPrnX, combineToPrnZ), 2)
- end
-
- --combine // combine_offset is in auto mode
- if not cornChopper and self.auto_combine_offset and combine.currentPipeState == 2 then
- if getParent(combine.pipeRaycastNode) == combine.rootNode then -- pipeRaycastNode is direct child of combine.root
- --safety distance so the trailer doesn't crash into the pipe (sidearm)
- local additionalSafetyDistance = 0
- if combine.name == "Grimme Maxtron 620" then
- additionalSafetyDistance = 0.9 --0.8
- elseif combine.name == "Grimme Tectron 415" then
- additionalSafetyDistance = -0.5
- end
-
- current_offset = prnX + additionalSafetyDistance
- --courseplay:debug(string.format("%s(%i): %s @ %s: root > pipeRaycastNode // current_offset = %f", curFile, debug.getinfo(1).currentline, self.name, combine.name, current_offset), 2)
- elseif getParent(getParent(combine.pipeRaycastNode)) == combine.rootNode then --pipeRaycastNode is direct child of pipe is direct child of combine.root
- local pipeX, pipeY, pipeZ = getTranslation(getParent(combine.pipeRaycastNode))
- current_offset = pipeX - prnZ
-
- if prnZ == 0 or combine.name == "Grimme Rootster 604" then
- current_offset = pipeX - prnY
- end
- --courseplay:debug(string.format("%s(%i): %s @ %s: root > pipe > pipeRaycastNode // current_offset = %f", curFile, debug.getinfo(1).currentline, self.name, combine.name, current_offset), 2)
- elseif combine.pipeRaycastNode ~= nil then --BACKUP pipeRaycastNode isn't direct child of pipe
- current_offset = combineToPrnX + 0.5
- --courseplay:debug(string.format("%s(%i): %s @ %s: combineToPrnX // current_offset = %f", curFile, debug.getinfo(1).currentline, self.name, combine.name, current_offset), 2)
- elseif combine.lmX ~= nil then --user leftMarker
- current_offset = combine.lmX + 2.5;
- else --if all else fails
- current_offset = 8;
- end
-
- --combine // combine_offset is in manual mode
- elseif not cornChopper and not self.auto_combine_offset then
- courseplay:debug(string.format("%s(%i): %s @ %s: combineToPrnX = %f", curFile, debug.getinfo(1).currentline, self.name, combine.name, combineToPrnX), 2)
- if combineToPrnX > 0 then
- current_offset = current_offset_positive
- elseif combineToPrnX < 0 then -- pipe on right side
- current_offset = current_offset_positive * -1
- courseplay:debug(string.format("%s(%i): %s @ %s: pipe on right side / current_offset = %f", curFile, debug.getinfo(1).currentline, self.name, combine.name, current_offset), 2)
- end
-
- --chopper // combine_offset is in auto mode
- elseif cornChopper and self.auto_combine_offset then
- if combine.lmX ~= nil then
- current_offset = combine.lmX + 2.5
- --courseplay:debug(string.format("%s(%i): %s @ %s: using leftMarker, current_offset = %f", curFile, debug.getinfo(1).currentline, self.name, combine.name, current_offset), 2)
- else
- current_offset = 8
- courseplay:debug(string.format("%s(%i): %s @ %s: using default current_offset = %f", curFile, debug.getinfo(1).currentline, self.name, combine.name, current_offset), 2)
- end
-
- if self.sideToDrive == nil then
- local left_fruit, right_fruit = courseplay:side_to_drive(self, combine, -10);
- if left_fruit < right_fruit then
- self.sideToDrive = "left";
- elseif right_fruit < left_fruit then
- self.sideToDrive = "right";
- end
- courseplay:debug(string.format("%s(%i): %s @ %s: sideToDrive first runthrough=%s => current_offset=%f", curFile, debug.getinfo(1).currentline, self.name, combine.name, tostring(self.sideToDrive), current_offset), 2)
- end;
-
- if self.sideToDrive ~= nil then
- if self.sideToDrive == "left" then
- current_offset = math.abs(current_offset);
- elseif self.sideToDrive == "right" then
- current_offset = math.abs(current_offset) * -1;
- end
- end;
- end
-
- --cornChopper forced side offset
- if cornChopper and combine.forced_side ~= nil then
- if combine.forced_side == "left" then
- current_offset = math.abs(current_offset);
- elseif combine.forced_side == "right" then
- current_offset = math.abs(current_offset) * -1;
- end
- courseplay:debug(string.format("%s(%i): %s @ %s: forced_side=%s => current_offset=%f", curFile, debug.getinfo(1).currentline, self.name, combine.name, combine.forced_side, current_offset), 2)
- end
-
- --refresh for display in HUD and other calculations
- self.combine_offset = current_offset;
-
-
-
- currentX, currentY, currentZ = localToWorld(combine.rootNode, current_offset, 0, trailer_offset + 5)
-
- local ttX, ttY, ttZ = localToWorld(combine.rootNode, current_offset, 0, trailer_offset)
-
- if combine.attachedImplements ~= nil then
- for k, i in pairs(combine.attachedImplements) do
- local implement = i.object;
- if implement.haeckseldolly == true then
- ttX, ttY, ttZ = localToWorld(implement.rootNode, current_offset, 0, trailer_offset)
- end
- end
- end
-
- local lx, ly, lz = worldToLocal(self.aiTractorDirectionNode, ttX, y, ttZ)
- dod = Utils.vector2Length(lx, lz)
- if dod > 40 or self.isChopperTurning == true then
- mode = 2
- end
-
- -- combine is not moving and trailer is under pipe
- if not cornChopper and ((combine.movingDirection == 0 and lz <= 0.5) or lz < -0.1 * trailer_offset) then
- self.info_text = courseplay:get_locale(self, "CPCombineWantsMeToStop") -- "Drescher sagt ich soll anhalten."
- allowedToDrive = false
- elseif cornChopper then
- if combine.movingDirection == 0 and (lz == -1 or dod == -1)and self.isChopperTurning == false then
- allowedToDrive = false
- self.info_text = courseplay:get_locale(self, "CPCombineWantsMeToStop") -- "Drescher sagt ich soll anhalten."
- end
- if lz < -2 then
- allowedToDrive = false
- self.info_text = courseplay:get_locale(self, "CPCombineWantsMeToStop")
- --mode = 2
- end
- end
-
- -- refspeed depends on the distance to the combine
- local combine_speed = combine.lastSpeed
- if cornChopper then
- self.sl = 2
- if lz > 20 then
- refSpeed = self.field_speed
- --print("refSpeed = self.field_speed")
- elseif lz > 4 and (combine_speed*3600) > 5 then
- refSpeed = combine_speed *1.5
- --print("refSpeed = combine_speed *1.5")
- elseif lz > 10 then
- refSpeed = self.turn_speed
- --print("refSpeed = self.turn_speed")
- elseif lz < -1 then
- refSpeed = combine_speed / 2
- else
- refSpeed = combine_speed
- --print("refSpeed = combine_speed")
- end
- if (combine.turnStage ~= 0 and lz < 20) then
- refSpeed = 1 / 3600
- self.sl = 1
- if self.ESLimiter == nil then
- self.motor.maxRpm[self.sl] = 200
- end
- end
- else
- self.sl = 2
- if lz > 5 then
- refSpeed = self.field_speed
- elseif lz < -0.5 then
- refSpeed = combine_speed - (2/3600)
- elseif lz > 1 or combine.sentPipeIsUnloading ~= true then
- refSpeed = combine_speed + (2/3600)
- else
- refSpeed = combine_speed
- end
- if combine.movingDirection == 0 then
- refSpeed = self.field_speed * 1.5
- end
- if (combine.turnStage ~= 0 and lz < 20) or self.timer < self.drive_slow_timer then
- refSpeed = 4 / 3600
- self.sl = 1
- if self.ESLimiter == nil then
- self.motor.maxRpm[self.sl] = 200
- end
- if combine.turnStage ~= 0 then
- self.drive_slow_timer = self.timer + 2000
- end
- end
-
- end
-
- --print(tostring(lz))
- --print("refSpeed: "..tostring(refSpeed*3600))
- --print("end")
- --courseplay:debug("combine.sentPipeIsUnloading: "..tostring(combine.sentPipeIsUnloading).." refSpeed: "..tostring(refSpeed*3600).." combine_speed: "..tostring(combine_speed*3600),3)
-
- ---------------------------------------------------------------------
- end -- end mode 3 or 4
-
- if combine_turning and not cornChopper and combine_fill_level > 0 then
- combine.waitForTurnTime = combine.time + 100
- end
-
- if combine_turning and distance < 20 then
- if tipper_percentage >= self.required_fill_level_for_drive_on then
- self.loaded = true
- elseif mode == 3 or mode == 4 then
- if cornChopper then
- self.leftFruit, self.rightFruit = courseplay:side_to_drive(self, combine, -10)
-
- --new chopper turn maneuver by Thomas Gärtner --!!!
- if self.leftFruit < self.rightFruit then -- chopper will turn left
-
- if self.combine_offset > 0 then -- I'm left of chopper
- courseplay:debug(string.format("%s(%i): %s @ %s: combine turns left, I'm left", curFile, debug.getinfo(1).currentline, self.name, combine.name), 2);
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, 0, 0, self.turn_radius);
- courseplay:set_next_target(self, 2*self.turn_radius*-1 , self.turn_radius);
- self.isChopperTurning = true
-
- else --i'm right of choppper
- courseplay:debug(string.format("%s(%i): %s @ %s: combine turns left, I'm right", curFile, debug.getinfo(1).currentline, self.name, combine.name), 2);
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, self.turn_radius*-1, 0, 0);
- self.isChopperTurning = true
- end
-
- else -- chopper will turn right
- if self.combine_offset < 0 then -- I'm right of chopper
- courseplay:debug(string.format("%s(%i): %s @ %s: combine turns right, I'm right", curFile, debug.getinfo(1).currentline, self.name, combine.name), 2);
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, 0, 0, self.turn_radius);
- courseplay:set_next_target(self, 2*self.turn_radius, self.turn_radius);
- self.isChopperTurning = true
- else -- I'm left of chopper
- courseplay:debug(string.format("%s(%i): %s @ %s: combine turns right, I'm left", curFile, debug.getinfo(1).currentline, self.name, combine.name), 2);
- self.target_x, self.target_y, self.target_z = localToWorld(self.rootNode, self.turn_radius, 0, 0);
- self.isChopperTurning = true
- end
- end
- if combine.forced_side == nil then
- if self.sideToDrive == "right" then
- self.sideToDrive = "left"
- elseif self.sideToDrive == "left" then
- self.sideToDrive = "right"
- end
- else
- self.sideToDrive = combine.forced_side
- end
- if self.sideToDrive == "right" then
- self.combine_offset = math.abs(self.combine_offset) * -1;
- elseif self.sideToDrive == "left" then
- self.combine_offset = math.abs(self.combine_offset);
- end
-
-
- mode = 5
- self.shortest_dist = nil
- self.next_ai_state = 7
- end
- elseif mode ~= 5 and mode ~= 9 and not self.realistic_driving then
- -- just wait until combine has turned
- allowedToDrive = false
- self.info_text = courseplay:get_locale(self, "CPCombineWantsMeToStop")
- end
- end
-
-
- if mode == 7 then
- if combine.movingDirection == 0 then
- mode = 3
- else
- self.info_text = courseplay:get_locale(self, "CPWaitUntilCombineTurned") -- ""
- end
- end
-
-
- -- wende man?ver
- if mode == 9 and self.target_x ~= nil and self.target_z ~= nil then
- --courseplay:remove_from_combines_ignore_list(self, combine)
- self.info_text = string.format(courseplay:get_locale(self, "CPTurningTo"), self.target_x, self.target_z)
- allowedToDrive = false
- local mx, mz = self.target_x, self.target_z
- local lx, ly, lz = worldToLocal(self.aiTractorDirectionNode, mx, y, mz)
- self.sl = 1
- refSpeed = self.field_speed --self.turn_speed
-
- if lz > 0 and math.abs(lx) < lz * 0.5 then -- lz * 0.5 --2
- if self.next_ai_state == 4 and not combine_turning then
- self.target_x = nil
- self.target_z = nil
- mode = self.next_ai_state
- self.next_ai_state = 0
- end
-
- if self.next_ai_state == 1 or self.next_ai_state == 2 then
- -- is there another waypoint to go to?
- if table.getn(self.next_targets) > 0 then
- mode = 5
- self.shortest_dist = nil
- self.target_x = self.next_targets[1].x
- self.target_y = self.next_targets[1].y
- self.target_z = self.next_targets[1].z
- table.remove(self.next_targets, 1)
- else
- mode = self.next_ai_state
- self.next_ai_state = 0
- end
- end
- else
- currentX, currentY, currentZ = localToWorld(self.aiTractorDirectionNode, self.turn_factor, 0, 5)
- allowedToDrive = true
- end
- end
-
-
-
- -- drive to given waypoint
- if mode == 5 and self.target_x ~= nil and self.target_z ~= nil then
- if combine ~= nil then
- --courseplay:remove_from_combines_ignore_list(self, combine)
- end
- self.info_text = string.format(courseplay:get_locale(self, "CPDriveToWP"), self.target_x, self.target_z)
- currentX = self.target_x
- currentY = self.target_y
- currentZ = self.target_z
- self.sl = 2
- refSpeed = self.field_speed
-
- distance_to_wp = courseplay:distance_to_point(self, currentX, y, currentZ)
-
- if table.getn(self.next_targets) == 0 then
- if distance_to_wp < 10 then
- refSpeed = self.turn_speed -- 3/3600
- self.sl = 1
- end
- end
-
- -- avoid circling
- local distToChange = 1
- if self.shortest_dist == nil or self.shortest_dist > distance_to_wp then
- self.shortest_dist = distance_to_wp
- end
-
- if distance_to_wp > self.shortest_dist and distance_to_wp < 3 then
- distToChange = distance_to_wp + 1
- end
-
- if distance_to_wp < distToChange then
- if self.next_ai_state == 81 then
- if self.active_combine ~= nil then
- courseplay:unregister_at_combine(self, self.active_combine)
- end
- end
-
- self.shortest_dist = nil
- if table.getn(self.next_targets) > 0 then
- -- mode = 5
- self.target_x = self.next_targets[1].x
- self.target_y = self.next_targets[1].y
- self.target_z = self.next_targets[1].z
-
- table.remove(self.next_targets, 1)
- else
- allowedToDrive = false
- if self.next_ai_state ~= 2 then
- self.calculated_course = false
- end
- if self.next_ai_state == 7 then
-
- mode = 7
-
- --self.target_x, self.target_y, self.target_z = localToWorld(combine.rootNode, self.chopper_offset*0.7, 0, -9) -- -2 --??? *0,5 -10
-
- elseif self.next_ai_state == 4 and combine_turning then
- self.info_text = courseplay:get_locale(self, "CPWaitUntilCombineTurned") -- ""
- elseif self.next_ai_state == 81 then -- tipper turning from combine
-
- self.recordnumber = 2
- courseplay:unregister_at_combine(self, self.active_combine)
- self.ai_state = 0
- self.loaded = true
-
- elseif self.next_ai_state == 1 then
- -- self.sl = 1
- -- refSpeed = self.turn_speed
- mode = self.next_ai_state
- self.next_ai_state = 0
-
- else
- mode = self.next_ai_state
- self.next_ai_state = 0
- end
- end
- end
- end
-
- if mode == 6 then --Follow Tractor
- self.info_text = courseplay:get_locale(self, "CPFollowTractor") -- "Fahre hinter Traktor"
- --use the current tractor's sideToDrive as own
- if tractor.sideToDrive ~= nil then
- courseplay:debug(string.format("setting current tractor's sideToDrive (%s) as my own", tractor.sideToDrive));
- self.sideToDrive = tractor.sideToDrive;
- end;
-
- -- drive behind tractor
- local x1, y1, z1 = worldToLocal(tractor.rootNode, x, y, z)
- local distance = Utils.vector2Length(x1, z1)
-
-
-
- if z1 > 0 then
- -- tractor in front of tractor
- -- left side of tractor
- local cx_left, cy_left, cz_left = localToWorld(tractor.rootNode, 30, 0, -10)
- -- righ side of tractor
- local cx_right, cy_right, cz_right = localToWorld(tractor.rootNode, -30, 0, -10)
- local lx, ly, lz = worldToLocal(self.aiTractorDirectionNode, cx_left, y, cz_left)
- -- distance to left position
- local disL = Utils.vector2Length(lx, lz)
- local rx, ry, rz = worldToLocal(self.aiTractorDirectionNode, cx_right, y, cz_right)
- -- distance to right position
- local disR = Utils.vector2Length(rx, rz)
- if disL < disR then
- currentX, currentY, currentZ = cx_left, cy_left, cz_left
- else
- currentX, currentY, currentZ = cx_right, cy_right, cz_right
- end
- else
- -- tractor behind tractor
- --TODO: ORIG: z = -40
- currentX, currentY, currentZ = localToWorld(tractor.rootNode, 0, 0, -30)
- end
-
- local lx, ly, lz = worldToLocal(self.aiTractorDirectionNode, currentX, currentY, currentZ)
- dod = Utils.vector2Length(lx, lz)
-
- if dod < 2 or tractor.ai_state ~= 3 then
- allowedToDrive = false
- end
-
- if distance > 50 then
- refSpeed = self.max_speed
- else
- refSpeed = tractor.lastSpeedReal --10/3600 -- tractor.lastSpeedReal
- end
-
-
- -- courseplay:debug(string.format("distance: %d dod: %d",distance,dod ), 3)
- end
-
-
- self.ai_state = mode
-
- if currentX == nil or currentZ == nil then
- self.info_text = courseplay:get_locale(self, "CPWaitForWaypoint") -- "Warte bis ich neuen Wegpunkt habe"
- allowedToDrive = false
- end
-
- if self.forced_to_stop then
- self.info_text = courseplay:get_locale(self, "CPCombineWantsMeToStop") -- "Drescher sagt ich soll anhalten."
- allowedToDrive = false
- end
-
- if self.showWaterWarning then
- allowedToDrive = false
- self.global_info_text = courseplay.locales.CPWaterDrive
- end
-
- -- check traffic and calculate speed
- if allowedToDrive then
-
- allowedToDrive = courseplay:check_traffic(self, true, allowedToDrive)
- if self.sl == nil then
- self.sl = 3
- end
- local maxRpm = self.motor.maxRpm[self.sl]
- local real_speed = self.lastSpeedReal
-
- if refSpeed == nil then
- refSpeed = real_speed
- end
- courseplay:setSpeed(self, refSpeed, self.sl)
- end
-
-
-
- if g_server ~= nil then
- local target_x, target_z = nil, nil
- if currentX ~= nil and currentZ ~= nil then
- target_x, target_z = AIVehicleUtil.getDriveDirection(self.aiTractorDirectionNode, currentX, y, currentZ)
- else
- allowedToDrive = false
- end
-
- if not allowedToDrive then
- target_x, target_z = 0, 1
- self.motor:setSpeedLevel(0, false);
- -- AIVehicleUtil.driveInDirection(self, dt, self.steering_angle, 0, 0, 28, false, moveForwards, lx, lz)
- end
-
-
- courseplay:set_traffc_collision(self, target_x, target_z)
-
- AIVehicleUtil.driveInDirection(self, dt, self.steering_angle, 0.5, 0.5, 8, allowedToDrive, true, target_x, target_z, self.sl, 0.4)
-
- -- new
- end
-end
-
-function courseplay:calculate_course_to(self, target_x, target_z)
- local curFile = "mode2.lua"
-
- self.calculated_course = true
- -- check if there is fruit between me and the target, return false if not to avoid the calculating
- local node = nil
- if self.aiTractorDirectionNode ~= nil then
- node = self.aiTractorDirectionNode
- else
- node = self.aiTreshingDirectionNode
- end
- local x, y, z = getWorldTranslation(node)
- local hx, hy, hz = localToWorld(node, -2, 0, 0)
- local lx, ly, lz = nil, nil, nil
- local dlx, dly, dlz = worldToLocal(node, target_x, y, target_z)
- local dnx = dlz * -1
- local dnz = dlx
- local angle = math.atan(dnz / dnx)
- dnx = math.cos(angle) * -2
- dnz = math.sin(angle) * -2
- hx, hy, hz = localToWorld(node, dnx, 0, dnz)
- local density = 0
- for i = 1, FruitUtil.NUM_FRUITTYPES do
- if i ~= FruitUtil.FRUITTYPE_GRASS then
- density = density + Utils.getFruitArea(i, x, z, target_x, target_z, hx, hz);
- end
- end
- if density == 0 then
- return false
- end
- if not self.realistic_driving then
- return false
- end
- if self.active_combine ~= nil then
- local fruit_type = self.active_combine.lastValidInputFruitType
- elseif self.tipper_attached then
- local fruit_type = self.tippers[1].getCurrentFruitType
- else
- local fruit_type = nil
- end
- --courseplay:debug(string.format("position x: %d z %d", x, z ), 4)
- local wp_counter = 0
- local wps = CalcMoves(z, x, target_z, target_x, fruit_type)
- --courseplay:debug(table.show(wps), 4)
- if wps ~= nil then
- self.next_targets = {}
- for _, wp in pairs(wps) do
- wp_counter = wp_counter + 1
- local next_wp = { x = wp.y, y = 0, z = wp.x }
- table.insert(self.next_targets, next_wp)
- wp_counter = 0
- end
- self.target_x = self.next_targets[1].x
- self.target_y = self.next_targets[1].y
- self.target_z = self.next_targets[1].z
- self.no_speed_limit = true
- table.remove(self.next_targets, 1)
- self.ai_state = 5
- else
- return false
- end
- return true
-end
\ No newline at end of file
diff --git a/mode4.lua b/mode4.lua
deleted file mode 100644
index 4644cd1ec..000000000
--- a/mode4.lua
+++ /dev/null
@@ -1,174 +0,0 @@
-function courseplay:handle_mode4(self, allowedToDrive, workArea, workSpeed, fill_level, last_recordnumber)
- local workTool = self.tippers[1] -- to do, quick, dirty and unsafe
- local posToVeh = workTool.cp.positionToVehicle; --1 = front / -1 = back
-
- workArea = (self.recordnumber > self.startWork) and (self.recordnumber < self.stopWork)
- -- Beginn Work
- if last_recordnumber == self.startWork and fill_level ~= 0 then
- if self.abortWork ~= nil then
- self.recordnumber = self.abortWork - 2
- end
- end
- -- last point reached restart
- if self.abortWork ~= nil then
- if (last_recordnumber == self.abortWork - 2) and fill_level ~= 0 then
- self.abortWork = nil
- end
- end
- -- safe last point
- if fill_level == 0 and workArea and self.abortWork == nil then
- self.abortWork = self.recordnumber
- self.recordnumber = self.stopWork - 4
- -- courseplay:debug(string.format("Abort: %d StopWork: %d",self.abortWork,self.stopWork), 2)
- end
-
-
- local firstPoint = last_recordnumber == 1;
- local prevPoint = self.Waypoints[last_recordnumber];
- local nextPoint = self.Waypoints[self.recordnumber];
-
- local ridgeMarker = prevPoint.ridgeMarker;
- local turnStart = prevPoint.turnStart;
- local turnEnd = prevPoint.turnEnd;
- local raiseTool = prevPoint.raiseTool;
-
- -- stop while folding
- if courseplay:isFoldable(workTool) then
- if courseplay:isFolding(workTool) then --TODO: doesn't seem to work perfectly w/ Amazone Condor
- allowedToDrive = false;
- courseplay:debug(workTool.name .. ": isFolding -> allowedToDrive == false", 3);
- end;
- courseplay:debug(string.format("%s: unfold: turnOnFoldDirection=%s, foldMoveDirection=%s", workTool.name, tostring(workTool.turnOnFoldDirection), tostring(workTool.foldMoveDirection)), 3);
- end;
-
- local is_ux5200 = workTool.state ~= nil and workTool.state.isTurnedOn ~= nil
-
- if workArea and fill_level ~= 0 and (self.abortWork == nil or self.runOnceStartCourse) then
- self.runOnceStartCourse = false;
- workSpeed = true
- if is_ux5200 then
- if workTool.state.isTurnedOn ~= true then
- workTool:setIsTurnedOn(true, false)
- workTool:setStateEvent("state", "markOn", true)
-
- workTool:setStateEvent("Speed", "ex", 1.0)
- workTool:setStateEvent("Speed", "trsp", 1.0)
- workTool:setStateEvent("Go", "trsp", true)
- workTool:setStateEvent("Go", "hubmast", false)
- workTool:setStateEvent("Done", "hubmast", true)
- workTool:setStateEvent("Go", "hubmast", false)
- workTool:setStateEvent("Go", "ex", true)
- workTool:setStateEvent("Done", "ex", true)
- end
- else
- if allowedToDrive then
- --unfold
- if courseplay:isFoldable(workTool) and workTool:getIsFoldAllowed() then -- and ((self.abortWork ~= nil and self.recordnumber == self.abortWork - 2) or (self.abortWork == nil and self.recordnumber == 2)) then
- if courseplay:is_sowingMachine(workTool) then
- workTool:setFoldDirection(-1);
-
- elseif workTool.turnOnFoldDirection ~= nil and workTool.turnOnFoldDirection ~= 0 then
- workTool:setFoldDirection(workTool.turnOnFoldDirection);
-
- --Backup
- else
- workTool:setFoldDirection(1); --> doesn't work for Kotte VTL (liquidManure)
- end;
- end;
-
- if not courseplay:isFolding(workTool) then
- --set or stow ridge markers
- if courseplay:is_sowingMachine(workTool) then
- if ridgeMarker ~= nil then
- if workTool.ridgeMarkerState ~= ridgeMarker then
- workTool:setRidgeMarkerState(ridgeMarker);
- end;
- elseif workTool.ridgeMarkerState ~= nil and workTool.ridgeMarkerState ~= 0 then
- workTool:setRidgeMarkerState(0);
- end;
- end;
-
- --lower/raise
- if workTool.needsLowering and workTool.aiNeedsLowering then
- --print(string.format("WP%d: isLowered() = %s, hasGroundContact = %s", self.recordnumber, tostring(workTool:isLowered()), tostring(workTool.hasGroundContact)));
- if turnEnd ~= nil and turnStart ~= nil then
- if not workTool:isLowered() and turnEnd == false and turnStart == false then
- self:setAIImplementsMoveDown(true);
- end;
- elseif not workTool:isLowered() then
- self:setAIImplementsMoveDown(true);
- end;
- end;
-
- --turn on
- if workTool.setIsTurnedOn ~= nil and not workTool.isTurnedOn then
- if courseplay:is_sowingMachine(workTool) then
- --do manually instead of :setIsTurnedOn so that workTool.turnOnAnimation and workTool.playAnimation aren't called
- workTool.isTurnedOn = true;
- --[[if workTool.airBlowerSoundEnabled ~= nil then
- workTool.airBlowerSoundEnabled = true;
- end;]]
- else
- workTool:setIsTurnedOn(true, false);
- end;
- end;
- end; --END if not isFolding
- end;
- end
- else
- workSpeed = false
- if is_ux5200 then
- if workTool.state.isTurnedOn ~= false then
- workTool:setStateEvent("Done", "ex", true)
- workTool:setStateEvent("Go", "ex", false)
- workTool:setStateEvent("Done", "hubmast", true)
- workTool:setStateEvent("Go", "hubmast", false)
- workTool:setStateEvent("Go", "trsp", false)
- workTool:setStateEvent("Speed", "trsp", 1.0)
- workTool:setStateEvent("Speed", "ex", 1.0)
- workTool:setStateEvent("state", "markOn", false)
- workTool:setIsTurnedOn(false, false)
- end
- else
- --turn off
- if workTool.setIsTurnedOn ~= nil and workTool.isTurnedOn then
- if courseplay:is_sowingMachine(workTool) then
- --do manually instead of :setIsTurnedOn so that workTool.turnOnAnimation and workTool.playAnimation aren't called
- workTool.isTurnedOn = false;
- --[[if workTool.airBlowerSoundEnabled ~= nil then
- workTool.airBlowerSoundEnabled = false;
- end;]]
- else
- workTool:setIsTurnedOn(false, false);
- end;
- end;
-
- --raise
- if not courseplay:isFolding(workTool) then
- if workTool.needsLowering and workTool.aiNeedsLowering and workTool:isLowered() then
- self:setAIImplementsMoveDown(false);
- end;
- end;
-
- --fold
- if courseplay:isFoldable(workTool) then
- if courseplay:is_sowingMachine(workTool) then
- workTool:setFoldDirection(1);
-
- elseif workTool.turnOnFoldDirection ~= nil and workTool.turnOnFoldDirection ~= 0 then
- workTool:setFoldDirection(-workTool.turnOnFoldDirection);
-
- --Backup
- else
- workTool:setFoldDirection(-1); --> doesn't work for Kotte VTL (liquidManure)
- end;
- end;
- end
- end
-
- if not allowedToDrive then
- workTool:setIsTurnedOn(false, false)
- end
-
- return allowedToDrive, workArea, workSpeed
-end;
diff --git a/mode6.lua b/mode6.lua
deleted file mode 100644
index cab750bea..000000000
--- a/mode6.lua
+++ /dev/null
@@ -1,269 +0,0 @@
-function courseplay:handle_mode6(self, allowedToDrive, workArea, workSpeed, fill_level, last_recordnumber)
- local workTool = self.tippers[1] -- to do, quick, dirty and unsafe
- local active_tipper = nil
- if self.attachedCutters ~= nil then
- for cutter, implement in pairs(self.attachedCutters) do
- --AICombine.addCutterTrigger(self, cutter);
- end;
- end
- workArea = (self.recordnumber > self.startWork) and (self.recordnumber < self.stopWork)
-
- if workArea then
- workSpeed = true
- end
- if self.recordnumber >= self.stopWork and self.abortWork == nil and not self.loaded then
- allowedToDrive = false
- self.global_info_text = courseplay:get_locale(self, "CPWorkEnd") --'hat Arbeit beendet.'
- end
-
-
- -- worktool defined above
- if workTool ~= nil then
-
- -- stop while folding
- if courseplay:isFoldable(workTool) then
- if courseplay:isFolding(workTool) then
- allowedToDrive = false;
- courseplay:debug(workTool.name .. ": isFolding -> allowedToDrive == false", 3);
- end;
- courseplay:debug(string.format("%s: unfold: turnOnFoldDirection=%s, foldMoveDirection=%s", workTool.name, tostring(workTool.turnOnFoldDirection), tostring(workTool.foldMoveDirection)), 3);
- end;
-
- -- balers
- if courseplay:is_baler(workTool) then
- if self.recordnumber >= self.startWork then
- -- automatic opening for balers
- if workTool.balerUnloadingState ~= nil then
- if fill_level == 100 and workTool.balerUnloadingState == Baler.UNLOADING_CLOSED then
-
- allowedToDrive = false
- workTool:setIsTurnedOn(false, false);
- if table.getn(workTool.bales) > 0 then
- workTool:setIsUnloadingBale(true, false)
- end
- elseif workTool.balerUnloadingState ~= Baler.UNLOADING_CLOSED then
- allowedToDrive = false
- if workTool.balerUnloadingState == Baler.UNLOADING_OPEN then
- workTool:setIsUnloadingBale(false)
- end
- elseif fill_level == 0 and workTool.balerUnloadingState == Baler.UNLOADING_CLOSED then
- workTool:setIsTurnedOn(true, false);
- end
- end
- end
- else
- -- baleloader, copied original code parts
- if SpecializationUtil.hasSpecialization(BaleLoader, workTool.specializations) or courseplay:isUBT(workTool) then
- if workArea and not courseplay:isUBT(workTool) then
- -- automatic stop for baleloader
- if workTool.grabberIsMoving or workTool:getIsAnimationPlaying("rotatePlatform") then
- allowedToDrive = false
- end
- if not workTool.isInWorkPosition and fill_level ~= 100 then
- --g_client:getServerConnection():sendEvent(BaleLoaderStateEvent:new(workTool, BaleLoader.CHANGE_BUTTON_WORK_TRANSPORT));
- workTool.grabberIsMoving = true
- workTool.isInWorkPosition = true
- BaleLoader.moveToWorkPosition(workTool)
- end
- end
-
- if not courseplay:isUBT(workTool) then
- if (fill_level == 100 and self.maxnumber ~= self.stopWork or self.recordnumber == self.stopWork) and workTool.isInWorkPosition and not workTool:getIsAnimationPlaying("rotatePlatform") then
- workTool.grabberIsMoving = true
- workTool.isInWorkPosition = false
- -- move to transport position
- BaleLoader.moveToTransportPosition(workTool)
- end
- end
-
- if fill_level == 100 and self.maxnumber == self.stopWork then
- allowedToDrive = false
- self.global_info_text = courseplay:get_locale(self, "CPReadyUnloadBale") --'bereit zum entladen'
- end
-
- if courseplay:isUBT(workTool) then
- if (workTool.fillLevel == workTool.fillLevelMax or fill_level == 100) and self.maxnumber == self.stopWork then
- allowedToDrive = false
- self.global_info_text = "UBT "..courseplay:get_locale(self, "CPReadyUnloadBale") --'UBT bereit zum entladen'
- end
- end
-
- -- automatic unload
- if self.Waypoints[last_recordnumber].wait and (self.wait or fill_level == 0) then
- if workTool.emptyState ~= BaleLoader.EMPTY_NONE then
- if workTool.emptyState == BaleLoader.EMPTY_WAIT_TO_DROP then
- -- BaleLoader.CHANGE_DROP_BALES
- g_server:broadcastEvent(BaleLoaderStateEvent:new(workTool, BaleLoader.CHANGE_DROP_BALES), true, nil, workTool)
- elseif workTool.emptyState == BaleLoader.EMPTY_WAIT_TO_SINK then
- -- BaleLoader.CHANGE_SINK
- g_server:broadcastEvent(BaleLoaderStateEvent:new(workTool, BaleLoader.CHANGE_SINK), true, nil, workTool)
- elseif workTool.emptyState == BaleLoader.EMPTY_WAIT_TO_REDO then
- -- BaleLoader.CHANGE_EMPTY_REDO
- g_server:broadcastEvent(BaleLoaderStateEvent:new(workTool, BaleLoader.CHANGE_EMPTY_REDO), true, nil, workTool);
- end
- else
- --BaleLoader.CHANGE_EMPTY_START
- if BaleLoader.getAllowsStartUnloading(workTool) then
- g_server:broadcastEvent(BaleLoaderStateEvent:new(workTool, BaleLoader.CHANGE_EMPTY_START), true, nil, workTool)
- end
- end
- end
-
- --END baleloader
- else
-
- -- other worktools, tippers, e.g. forage wagon
- -- start/stop worktool
- if workArea and fill_level ~= 100 and ((self.abortWork == nil and last_recordnumber == self.startWork) or (self.abortWork ~= nil and last_recordnumber == self.abortWork - 4) or (self.runOnceStartCourse)) then
- --activate/lower/unfold workTool also when activating from within course (not only at start)
- self.runOnceStartCourse = false;
-
- --workSpeed = true
- if allowedToDrive then
- --unfold
- if courseplay:isFoldable(workTool) then
- workTool:setFoldDirection(-1);
- --workTool:setFoldDirection(workTool.turnOnFoldDirection);
- end;
-
- if not courseplay:isFolding(workTool) then
- --lower
- if workTool.needsLowering and workTool.aiNeedsLowering then
- self:setAIImplementsMoveDown(true);
- end;
-
- --turn on
- if workTool.setIsTurnedOn ~= nil then
- workTool:setIsTurnedOn(true, false);
- if workTool.setIsPickupDown ~= nil then
- workTool:setIsPickupDown(true, false);
- end;
- elseif workTool.isTurnedOn ~= nil and workTool.pickupDown ~= nil then
- -- Krone ZX - planet-ls.de
- workTool.isTurnedOn = true;
- workTool.pickupDown = true;
- workTool:updateSendEvent();
- end;
- end;
- end
- elseif not workArea or fill_level == 100 or self.abortWork ~= nil or last_recordnumber == self.stopWork then
- workSpeed = false
-
- if not courseplay:isFolding(workTool) then
- --turn off
- if workTool.setIsTurnedOn ~= nil then
- workTool:setIsTurnedOn(false, false);
- if workTool.setIsPickupDown ~= nil then
- workTool:setIsPickupDown(false, false);
- end
- elseif workTool.isTurnedOn ~= nil and workTool.pickupDown ~= nil then
- -- Krone ZX - planet-ls.de
- workTool.isTurnedOn = false;
- workTool.pickupDown = false;
- workTool:updateSendEvent();
- end;
-
- --raise
- if workTool.needsLowering and workTool.aiNeedsLowering then
- self:setAIImplementsMoveDown(false);
- end;
- end;
-
- --fold
- if courseplay:isFoldable(workTool) then
- workTool:setFoldDirection(1);
- --workTool:setFoldDirection(-workTool.turnOnFoldDirection);
- end;
- end;
-
- -- done tipping
- local tipper_fill_level, tipper_capacity = self:getAttachedTrailersFillLevelAndCapacity()
-
- if tipper_fill_level ~= nil and tipper_capacity ~= nil then
- if self.unloading_tipper ~= nil and self.unloading_tipper.fillLevel == 0 then
- self.unloading_tipper = nil
-
- if tipper_fill_level == 0 then
- self.unloaded = true
- self.max_speed_level = 3
- self.currentTipTrigger = nil
- end
- end
-
- -- damn, i missed the trigger!
- if self.currentTipTrigger ~= nil then
- local trigger_id = self.currentTipTrigger.triggerId
-
- if self.currentTipTrigger.specialTriggerId ~= nil then
- trigger_id = self.currentTipTrigger.specialTriggerId
- end
-
- local trigger_x, trigger_y, trigger_z = getWorldTranslation(trigger_id)
- local ctx, cty, ctz = getWorldTranslation(self.rootNode);
- local distance_to_trigger = courseplay:distance(ctx, ctz, trigger_x, trigger_z)
- if distance_to_trigger > 60 then
- self.currentTipTrigger = nil
- end
- end
-
- -- tipper is not empty and tractor reaches TipTrigger
- if tipper_fill_level > 0 and self.currentTipTrigger ~= nil and self.recordnumber > 3 then
- self.max_speed_level = 1
- allowedToDrive, active_tipper = courseplay:unload_tippers(self)
- self.info_text = courseplay:get_locale(self, "CPTriggerReached") -- "Abladestelle erreicht"
- end
- end;
-
- -- Begin Work
- if last_recordnumber == self.startWork and fill_level ~= 100 then
- if self.abortWork ~= nil then
- self.recordnumber = self.abortWork - 4
- if self.recordnumber < 1 then
- self.recordnumber = 1
- end
- end
- end
- -- last point reached restart
- if self.abortWork ~= nil then
- if (last_recordnumber == self.abortWork - 4) and fill_level ~= 100 then
- self.recordnumber = self.abortWork - 2 -- drive to waypoint after next waypoint
- self.abortWork = nil
- end
- end
- -- safe last point
- if (fill_level == 100 or self.loaded) and workArea and self.abortWork == nil and self.maxnumber ~= self.stopWork then
- self.abortWork = self.recordnumber
- self.recordnumber = self.stopWork - 4
- if self.recordnumber < 1 then
- self.recordnumber = 1
- end
- -- courseplay:debug(string.format("Abort: %d StopWork: %d",self.abortWork,self.stopWork), 2)
- end
- end
- end
- else
- if SpecializationUtil.hasSpecialization(Combine, self.specializations) or SpecializationUtil.hasSpecialization(combine, self.specializations) then
- if self.grainTankCapacity == 0 and ((self.pipeParticleActivated and not self.isPipeUnloading) or not self.pipeStateIsUnloading[self.currentPipeState]) then
- -- there is some fruit to unload, but there is no trailer. Stop and wait for a trailer
- self.waitingForTrailerToUnload = true;
- end;
- if self.waitingForTrailerToUnload then
- if self.lastValidOutputFruitType ~= FruitUtil.FRUITTYPE_UNKNOWN then
- local trailer = self:findTrailerToUnload(self.lastValidOutputFruitType);
- if trailer ~= nil then
- -- there is a trailer to unload. Continue working
- self.waitingForTrailerToUnload = false;
- end;
- else
- -- we did not cut anything yet. We shouldn't have ended in this state. Just continue working
- self.waitingForTrailerToUnload = false;
- end;
- end;
-
- if (self.grainTankFillLevel >= self.grainTankCapacity and self.grainTankCapacity > 0) or self.waitingForTrailerToUnload or self.waitingForDischarge then
- allowedToDrive = false;
- end;
- end;
- end
- return allowedToDrive, workArea, workSpeed, active_tipper
-end
\ No newline at end of file
diff --git a/mode8.lua b/mode8.lua
deleted file mode 100644
index e32e76eb0..000000000
--- a/mode8.lua
+++ /dev/null
@@ -1,13 +0,0 @@
--- handles "mode1" : waiting at start until tippers full - driving course and unloading on trigger
-function courseplay:handle_mode8(self)
- if self.tippers ~= nil then
- for i = 1, table.getn(self.tippers) do
- workTool = self.tippers[i]
- if workTool ~= nil then
- if workTool.trailerInTrigger ~= nil and workTool.fillLevel > 0 and not workTool.fill then
- workTool.fill = true;
- end
- end
- end
- end
-end
\ No newline at end of file
diff --git a/readme.md b/readme.md
index 353435f26..e03bb9d38 100644
--- a/readme.md
+++ b/readme.md
@@ -1,244 +1,15 @@
-# Courseplay - Abfahrhelfer für LS 2013 v 3.20
+# Courseplay for Farming Simulator 2013
-##### Inhaltsverzeichnis
+### We've moved
+We've moved to a **[new repository][CP Github]**. Please visit go there for any updates. We will not answer anymore to any issues posted here.
-1. [Changelog](#changelog)
-2. [Installationsanweisung](#install)
-3. [Bedienungsanleitung](#bedienungsanleitung)
-4. [Credits](#credits)
+Our **[homepage][CP Website Link]** is still where it used to be .
-___
+----
+### Wir sind umgezogen
+Wir sind auf ein **[neues Repository][CP Github]** umgezogen. Wir werden hier keine Supportanfragen mehr beantworten.
-
-## Changelog
+Unsere **[Homepage][CP Website Link]** ist immer doch da wo sie sein sollte.
-### Änderungen seit Version 3.12
-* Konvertierung auf LS 2013
-* Unterstützung mehrerer Abkippseiten beim Hänger
-* Automatische Einstellung des seitlichen Abstandes
-* Fruchtumfahrung dekativiert (gab zu viele Probleme damit)
-* Unterstützung für Rüben/Kartoffelernter
-* Optimiertes Wendemanöver beim Dreschen und Häckseln
-* Einstellungen im HUD können mit gedrückter STRG-Taste in größeren Schritten verstellt werden.
-* Debug-Level in allgemeinen Einstellungen einstellbar
-* Abkippen auf der BGA erfolgt während der Fahrt
-* Doppelbelegung der EINFG-Taste behoben
-* Infomeldung wenn Abfahrer im Verkehr steckt wird wieder angezeigt
-* Bedienung von Courseplay mit STRG+7 STRG+8 und STRG+9 statt ohne STRG
-* manuelles Rückwärtsfahren: Um einen Kurs rückwärts aufzuzeichnen muss man jetzt die Fahrtrichtung im HUD ändern
-* und zig Bugfixes
-
-### Änderungen seit Version 2.2 / 2.4
-* **Neuer Modus: Drescher fährt selbst zum abtanken**
- Mähdrescher können jetzt auch selbstständig zu Hängern am Feldrand fahren. Dazu muss man mit dem Drescher einen Kurs einfahren der einen Wartepunkt enthält. Dieser Wartepunkt ist die Stelle an der auf den Hänger übergeladen wird. Nach dem Überladepunkt muss die Aufzeichnung beendet werden. Dann richtet man den Drescher auf dem Feld aus, schaltet den Helfer ein und ERST DANN stellt man den Abfahrhelfer ein.
-
-* **Überladewagen kippen im Überlademodus automatisch ab**
- Brent Avelanche, Hilken, Agroliner TUW & Co., HAWE SUW 5000, Perard Innerbanne 25, Kverneland Taarup Shuttle & Co. laden am Überladepunkt automatisch ab. Der Taarup fährt sogar seinen Aufbau hoch und auch wieder runter.
-
-* AlternativeTipping von SFM wird voll unterstützt
-
-* Wendemanöver im Kombimodus wurden überarbeitet
-
-* **A\*Star Pathfinding**
- Abfahrer versuchen auf dem Feld nicht durch die Frucht zu fahren. Es wird automatisch nach einem Umweg um die Frucht herum gesucht. Wird ein Weg gefunden wird dieser genutzt und der Abfahrer fährt um die Frucht herum. *(Dieses Feature ist noch experimentell)*
-
-* beim speichern von Kursen steigt man nicht mehr aus dem Fahrzeug aus
-
-* Im Feldmodus werden weitere Rundballenpressen unterstützt
-
-* Man kann in den Einstellungen die max. Geschwindigkeit auswählen zwischen *"max Geschwindigkeit"* und *"eingefahrener Geschwindigkeit"*. Das erste ist die alte Einstellung, Courseplay ermittelt die auf der Straße zu fahrende Geschwindigkeit. Bei der zweiten Option wird immer die Geschwindigkeit genutzt die beim Einfahren des Kurses gefahren wurde.
-
-* man kann auf der letzten Seite der Einstellungen die Haltezeit am Wartepunkt definieren. Ist diese auf *"0"* wartet der Abfahrer am Wartepunkt bis er weitergeschickt wird. Ansonsten wartet er die vorgegebene Zeit am Wartepunkt und fährt dann automatisch weiter (ideal für die *MapWeightStation*).
-
-### Änderungen seit Version 2.11
-* Neuer Modus: Drescher fährt selbst zum abtanken
-* support für das BGA Silo des Giants DLC2
-* support für TipAnywhere mod
-* support für kommenden Drescher-Autopiloten 3.0.5
-* bessere Unterstützung für Ballensammelwagen
-* Fehler beim Befüllen von Überladewagen und Abfahrern auf der zweiten Runde gefixt
-* selten auftretenden Multiplayer-Callstacks behoben
-
-### Änderungen seit Version 2.0
-* In der Version 2.0 waren leider noch einige Fehler die den Multiplayermodus gestört haben. Diese wurden behoben.
-* Neu in dieser Version ist vor allem, dass ihr eure Schlepper nicht mehr mit courseplay nachrüsten müsst. Einfach den Mod ins Modverzeichnis und alle Fahrzeuge sind automatisch damit ausgestattet.
-Durch diese Änderung müsst ihr leider in allen bereits umgerüsteten Schleppern den Eintrag `` entfernen.
-* Weiterhin wurde in dieser Version das Kombinieren von Kursen verbessert.
-* ***Wichtig:*** die Datei aaacourseplay.zip (v2 und kleiner) **muss** aus dem Mod-Verzeichnis gelöscht werden.
-
-### Änderungen seit Version 1.6
-Die größte Änderung im courseplay ist natürlich die Multiplayerfähigkeit. Dabei werden beim Spielstart alle Werte und sogar gespeicherte Kurse vom Host an die Clients übertragen. Das kann mitunter ein bisschen dauern ist aber notwendig.
-
-Neben zahlreichen Bugfixes und Performance-Optimierungen die hier nicht weiter erwähnt werden sollen gibt es im wesentlichen die folgende Neuerungen:
-
-* Kursverwaltung: Gespeicherte Kurse werden jetzt alphabetisch sortiert und werden immmer global für alle Fahrzeuge gespeichert. Dadurch ist kein Synchronisieren der Kurse zwischen den einzelnen Fahrzeugen mehr nötig und der Speicherverbrauch ist drastisch gesunken.
-* Kurse aufnhemen: Das Pausieren der Kursaufnahme wurde überarbeitet. Man kann jetzt die Kursaufzeichnung pausieren und die letzten Wegpunkte löschen. Dabei wird jetzt immer nur der letzte Wegpunkt angezeigt und nicht mehr alle.
-* Neu: Kurs Offset
-* Dieses Feature ist noch experimentell und soll dafür sorgen, dass der Schlepper den gespeicherten Kurs leicht versetzt abfährt. Gedacht ist dies zum Beispiel für Ballensammelwagen.
-* Neue Kurskombination:
-* Ihr könnt beim Einfahren eines Kurses jetzt Kreuzungspunkte setzen. Wenn ihr später mehrere Kurse hintereinander ladet werden diese immer am ersten gemeinsamen Kreuzungspunkt (Abstand unter 30 Metern!) zusammengefügt. Damit könnt ihr also auch Teile von Routen wieder verwenden.
-* Das Rückwärtsfahren wurden optimiert und sollte jetzt wieder richtig funktionieren.
-* Wenn ihr das Spiel speichert werden die Einstellungen eurer Abfahrer mit gespeichert. Nach dem Neuladen müsst ihr also normalerweise nichts mehr einstellen. Die zuvor geladenen Kurse und Einstellungen sollten komplett wieder verfügbar sein.
-* Außerdem gibt es neue Symbole für die Wegpunkte und spezielle Wegpunkte wie Kreuzungspunkte und Startpunkte sind auch sichtbar wenn ihr nicht im Fahrzeug seid welches die Route gespeichert hat.
-
-### Änderungen seit Version 1.2
-* Neu hinzugekommen sind vor allem der Feldmodus mit dem man Ballen pressen und Heusammeln kann. Der Güllemodus wurde weiter perfektioniert und es ist jetzt auch möglich den Abfahrhelfer in Drescher und Häcksler einzubauen.
- Damit kann man beispielsweise mit Dreschern im Helfermodus Kurse aufzeichnen lassen die man dann später für den Gülle- oder Feldmodus verändern kann.
-* Zudem gibt es eine Steuerung des Abfahrhelfers aus dem Drescher heraus. Man kann einen Abfahrhelfer rufen, starten, stoppen und beim Häcksler die Seite des Abfahrers ändern.
-* Beim Abfahrhelfer kann man jetzt einstellen bei wieviel Prozenz Füllstand er frühzeitig abfahren soll. Hat ein Abfahrer zum Beispiel einen Füllstand von 90% und der Drescher wendet am Ende des Feldes, fährt der Abfahrer gleich ab und wartet nicht auf das Wendemanöver.
-* Zudem fährt der Überladewagen an seinem Überladepunkt wieder zurück aufs Feld wenn er einen gewissen Füllstand unterschritten hat und für etwa 20 Sekunden kein weiterer Abfahrer zum überladen konmmt.
-* Außerdem wurde gewünscht, dass der Abfahrhelfer auf der Straße seine Rundumleuchte einschaltet - das tut er jetzt ;)
-* Dann gab es natürlich auch noch etwas Feintuning:
- * Das unsinnige Kreiseln auf dem Feld sollte jetzt vorbei sein
- * HW80 Drehschemel und Agroliner Container werden jetzt auch unterstützt.
-
-
-### Änderungen seit Version 1.0
-* Als neue Funktionen sind im wesentlichen der Düngemodus und das Rückwärtsfahren hinzugekommen. Außerdem wurde das Fahrverhalten (besonders in Kurven) verbessert und es werden mehr EntladeTrigger (Gras und Silage) erkannt.
-* Zudem kann man jetzt gespeicherte Kurse kombinieren indem man mehrere Kurse hintereinander lädt. Wenn man nur einen neuen Kurs laden will muss man allerdings jetzt vorher die Wegpunkte des alten zurücksetzen.
-* Außerdem ist der Abfahrhelfer jetzt kein "hireable" mehr, das heißt er verbraucht jetzt Benzin(Dünger..) beim Fahren. Damit der Abfahrer nicht einfach irgendwo stehen bleibt bekommt man eine Warnung sobald der Tank fast leer ist und bei einem minimalen Tankinhalt bleibt der Abfahrhelfer stehen damit man ihn noch bis zur Zapfsäule bekommt.
-* Im Menu wurde noch der "BUG" behoben, dass man das Menu mit allen Maustasten steuern konnte.
-* Natürlich gab es noch viele weitere kleine Bugfixes.
-
-Dieses Mal geht ein besonders großer Dank an Wolverine, der einen Großteil dieses Updates (Düngemodus und Rückwärtsfahren) implementiert hat.
-
-Wir haben weiterhin an einer Version 2 die komplett multiplayerfähig ist, die aktuelle Version 1.20 ist aber zumindest im MP vom Host bedienbar.
-
-___
-
-
-## Installationsanweisung
-Das Archiv `ZZZ_courseplay.zip` in das Verzeichnis `C:\Users\`*[dein Username]*`\MyGames\FarmingSimulator2011\mods` kopieren. Das war es!
-
-___
-
-
-## Bedienungsanleitung
-
-### Steuerung
-Die Steuerung des Abfahrhelfers funktioniert im wesentlichem mit der Maus da freie Tasten im Landwirtschafts Simulator ja sehr rah sind.
-Mit einem Klick auf die rechte Maustaste aktiviert ihr das Courseplay HUD in dem ihr den Abfahrer konfigurieren könnt. Zusätzlich sind einige Funktionen wie Abfahrer starten und stoppen auch über die Tastatur über die Tasten *NUMPAD 7* bis *NUMPAD 9* belegt.
-
-### HUD
-Wenn ihr das HUD öffnet wird automatisch die Maussteuerung aktiviert. Das heißt ihr könnt euch mit der Maus nicht mehr umgucken. Um die Maussteuerung zu deaktivieren müsst ihr einfach nochmal auf die rechte Maustaste klicken.
-Alternativ könnt ihr auch auf das rote X oben rechts im HUD klicken. Dabei wird das HUD geschlossen und die Maussteuerung wieder deaktiviert.
-
-Das HUD ist in mehrere Unterseiten unterteilt. Diese könnt ihr mit den blauen Pfeilen im oberen Bereich des HUDs wechseln.
-Im mittleren Bereich des HUDs könnt ihr auf jeder Unterseite verschiede Einstellungen vornehmen oder Befehle geben. Klickt dazu einfach auf die gewünschte Aktion.
-
-Im unteren Bereich des HUDs findet ihr Infos über euren Abfahrer den geladenen Kurs und den aktuellen Status. Dort könnt ihr durch klick auf die Diskette euren eingefahrenen Kurs auch speichern.
-
-#### HUD "Abfahrhelfer Steuerung"
-
-* **Kursaufzeichnung beginnen**
- Mit dieser Option wird der Aufnahmemodus des Abfahrhelfers aktiviert. Ihr könnt damit den Kurs einfahren den der Abfahrer später fahren soll.
- Bei Aktivierung werden anfangs drei Fässchen im Abstand von 10-20 Metern gesetzt. Ihr solltet darauf achten, dass ihr bis zum dritten Fass nach Möglichkeit geradeaus fahrt.
- Wenn ihr diese Funktion aktiviert habt könnt ihr mit der rechten Maustaste die Maussteuerung deaktivieren damit ihr euch beim Einfahren des Kurses auch umschauen könnt.
-
-* **Kursaufzeichnung anhalten**
- Wenn die Kursaufzeichnung läuft könnt ihr mit dieser Funktion die Kursaufzeichnung pausieren. Es wird ein gelber Pfeil angezeigt der zum letzten Wegpunkt zeigt. Zusätzlich könnt ihr in diesem Modus auch den letzten Wegpunkt löschen.
-
-* **Kursaufzeichnung beenden**
- Diese Aktion ist nur im Aufnahmemodus vergügbar und dient dazu diesen zu beenden. Klickt auf diese Funktion wenn ihr den Endpunkt eurer eingefahrenen Route erreicht habt.
- Es empfiehlt sich, dass der Endpunkt etwa 10 Meter vor dem Startpunkt liegt und dass man grob aus der Richtung kommt in die der Abfahrer beim Startpunkt auch weiterfahren soll.
-
-* **Hier Wartepunkt setzen**
- Im Aufnahmemodus habt ihr die Möglichkeit auf der Strecke Wartepunkte zu setzen. An diesen Punkten wird der Abfahrer später beim Abfahren anhalten bis man ihn manuell weiter schickt.
- Wenn ein Abfahrer einen Wartepunkt erreicht hat wird euch das am unteren Bildschirmrand angezeigt.
-
-* **Abfahrer einstellen**
- Wenn ihr einen Kurs eingefahren habt könnt ihr jetzt den Abfahrer einstellen. Dabei wird der Abfahrhelfer aktiviert und fährt brav seine Route ab.
-
-* **Abfahrer entlassen**
- Den aktivierten Abfahrer könnt ihr natürlich auch jederzeit entlassen bzw. anhalten. Wenn ihr den Abfahrhelfer später wieder aktiviert wird er seine Route am letzen Punkt fortführen.
-
-* **weiterfahren**
- Diese Option steht euch zur Verfügung wenn der Abfahrer einen Wartepunkt erreicht hat.
-
-* **Abfahrer-Typ wechseln**
- Damit der Abfahrhelfer möglichst viele Aufgaben erledigen kann gibt es verschiedene Abfahrhelfer Typen. Der aktuelle Typ wird im unteren Bereich des HUDs angezeigt. Mit klick auf diese Aktion könnt ihr die Typen durchgehen.
-
- * **Typ: Abfahrer**
- Der Typ Abfahrer wartet am Startpunkt bis er voll beladen ist und fährt erst dann die Route ab. Wenn er auf seiner Route über eine Abkippstelle kommt hält er an und entleert seine(n) Anhänger.
- Man kann dem Abfahrer am Startpunkt allerdings auch sagen, dass er sofort abfahren soll.
-
- * **Typ: Kombiniert**
- Der Kombinierte Modus ist ähnlich wie der Abfahrer Modus mit dem Unterschied, dass der Abfahrer am Startpunkt nicht wartet bis er beladen ist sondern selbstständig zu einem Drescher oder Häcksler auf dem aktuellen Feld fährt und diese bedient.
- Wenn alle Hänger voll sind fährt der Abfahrer das zweite Fässchen auf seiner Route an und fährt von da an die Route ab wie der normale Abfahrer.
- Damit der kombinierte Modus funktioniert muss der Startpunkt des Abfahrers unbedingt auf dem gleichen Feld liegen auf dem der oder die Drescher sind.
-
- * **Typ: Überladewagen**
- Beim Typ Überladewagen fährt der Abfahrer auch direkt zum Drescher oder Häcksler und fährt anschließend seine Route ab. Der Unterschied hierbei ist, dass der Überladewagen "Wartepunkte" als "Abladepunkte" nutzt. Wenn der Überladewagen also voll ist fährt er seine Route bis zum Wartepunkt ab und fährt dort automatisch weiter, wenn der Überladewagen leer ist.
-
- * **Typ: Überführung**
- In diesem Modus fährt der Abfahrer lediglich seine Route ab. Er wartet nicht am Startpunkt und wird an Abladestellen auch nicht entladen. Dieser Modus eignet sich in Verbindung mit Wartepunkten um Gerätschaften zum Feld zu bringen oder zum Beispiel auch auf andere Höfe.
-
- * **Typ: Düngen**
- Im Düngemodus füllt der Abfahrhelfer am Startpunkt eine Spritze oder ein Güllefass und fährt dann seine Route ab. Man fährt mit dem Abfahrhelfer zum Feld, setzt einen Wartepunkt an der Stelle an der er mit dem Düngen beginnen soll, fährt das Feld ab und setzt einen Wartepunkt am Feldende.
- Beim Abfahren klappt der Abfahrhelfer automatisch die Spritze/Güllefass aus und schaltet es an, fährt das Feld ab bis der Tank leer ist und fährt zurück zum auftanken. Nach dem Auftanken macht er an der Position weiter an der er aufgehört hat.
-
- * **Typ: Feldarbeit (Ballenpressen, Schwadaufnahme)**
- Der Feldarbeitsmodus funktioniert ähnlich wie der Düngemodus. Hierbei wird ein zuvor aufgezeichneter Kurs mit Feldgeschwindigkeit abgefahren.
- Als Besonderheit kann man in diesem Modus zum Beispiel eine Ballenpresse anhängen. Die Rundballenpresse hält hierbei an wenn sie voll ist und wirft den Ballen aus.
- Wenn man einen Ladewagen anhängt wird der Kurs abgefahren bis dieser voll ist, dann wird die letzte Position gespeichert und der Kurs abgefahren. Der Kurs sollte dann natürlich an einem Abladetrigger vorbei führen. Dort wird der Wagen entleert und dann fährt er zurück zum Feld und setzt seine Arbeit am letzten Punkt fort.
- Der Arbeitsbereich des Modus Feldarbeit muss wie im Düngemodus durch zwei Wartepunkte markiert werden.
-
- * **Typ: Drescher fährt selbst zum abtanken**
- Dieser Modus ist ähnlich dem des Überladewagens, nur eben für Drescher. Der Startpunkt der Route ist der Punkt den der Drescher anfährt wenn er den eingestellen Füllstand erreicht hat. Er fährt dann die Route bis zum 1. Wartepunkt ab. Am Wartepunkt tankt der Drescher ab und fährt, sobald er leer ist die Route weiter. Der Endpunkt der Route ist der Punkt an dem der Drescher den Helfer aktiviert. Wenn er bereits auf dieser Route gedroschen hat, fährt er nach dem abtanken den letzten Wegpunkt an und dann weiter an den Punkt an dem der Drescher weggefahren ist.
-
-
-* **Wegpunkte löschen**
- Wenn ein Kurs eingefahren ist kannst du über diese Option den Kurs wieder zurücksetzen. Dabei wird der gespeicherte Kurs nicht aus der Konfigurationsdaten gelöscht sondern nur der aktuelle Abfahrer wieder zurückgesetzt.
-
-
-#### HUD Kurs speichern
-Im unteren Breich des Huds findet ihr eine Diskette. Wenn ihr einen Kurs eingefahren habt könnt ihr durch Klick auf die Diskette euren Kurs speichern. Dabei wird im oberen Bereich eine Eingabemaske angezeigt. Hier könnt ihr mit der Tastatur einen Namen für euren Kurs vergeben und diesen mit *ENTER* (Eingabetaste) bestätigen.
-**Hinweis:** Aktuell ist die Steuerung des Spiels im Speichermodus noch aktiv. Das heißt wenn ihr zum Beispiel "e" drückt steigt ihr leider noch aus dem Fahrzeug aus. In diesem Fall einfach wieder einsteigen und weiter tippen. Dieses Problem wird in einer späteren Version natürlich behoben.
-
-
-#### HUD "Kurse verwalten"
-Auf dieser Unterseite des HUD findet ihr eine Übersicht eurer gespeicherten Kurse. Ihr könnt durch Klick auf das Ordner Symbol einen Kurs laden und durch einen Klick auf das rote X einen Kurs komplett löschen.
-**ACHTUNG:** seit version 1.2 müsst ihr wenn ihr einen neuen Kurs laden wollt erst die alten Wegpunkte zurücksetzen, sonst kombiniert ihr die beiden Kurse!
-Mit den blauen Pfeilen rechts oben und rechts unten könnt ihr durch die gespeicherten Kurse blättern.
-**Hinweis zum Kombinieren von Kursen:** Das Ordner Symbol ohne den blauen Pfeil kombiniert die Kurse am ersten gemeinsamen Kreuzungspunkt, der mit dem blauen Pfeil hängt die Kurse einfach hintereinander.
-
-
-#### HUD "Einstellungen Combi Modus":
-Diese Einstellungen gelten (wie der Name es andeutet) nur für den kombinierten Modus und den Überlademodus. Hiermit könnt ihr euren Abfahrer an den jeweiligen Drescher anpassen. Ihr könnt die Werte mit einem Klick auf das +/- Symbol daneben anpassen (Bei klick mit gedrückter STRG-Taste verstellt ihr die Werte in größeren Abständen)
-
-* **seitl. Abstand**
- Dieser Wert definiert den seitlichen Abstand den ein Abfahrer zum Drescher oder Häcksler beim nebenher fahren einhalten soll. Voreingestellt ist hier "auto" damit passt sich der Abfahrer automatisch an den Drescher oder Häcksler an.
-
-* **Start bei %**
- Dieser Wert legt fest ab welchem Füllstand des Dreschers der Abfahrer zu ihm fährt und ihn abtankt. Bei Häckslern wird durch diesen Wert festgelegt ab wann der zweite Abfahrer in der Kette dem ersten hinterherfahren soll.
-
-* **Wenderadius**
- Dieser Wert ist nur beim Häckseln wichtig und legt fest wie weit der Abfahrer beim Wenden des Häckslers von ihm wegfahren soll ohne ihm im Weg zu stehen.
-
-* **Pipe Abstand**
- entfällt in aktueller Version
-
-
-#### HUD "Drescher verwalten"
-Auch diese Einstellungen sind nur für den kombinierten Modus relevant. Hier könnt ihr einstellen ob der Abfahrer sich automatisch einen Drescher oder Häcksler suchen soll (Standard) oder er einen manuell zugewiesenen Drescher nutzen soll.
-Wenn ihr einen Drescher manuell zuweist muss dieser auch nicht auf dem gleichen Feld stehen. Der Abfahrer fährt von seinem Startpunkt automatisch zum Drescher, egal wo dieser sich befindet.
-
-Interessant ist diese Einstellung vor allem bei großen oder hügeligen Feldern auf denen die automatische Zuweisung nicht immer funktioniert und auf Feldern ohne Grubbertextur z.B. Wiesen.
-
-
-#### HUD "Geschwidigkeiten":
-Hier könnt ihr festlegen wie schnell euer Abfahrer fahren soll. Ich denke mal die Einstellungen sind selbst erklärend ;)
-
-___
-
-
-## Credits
-* Lautschreier (Grundversion)
-* Hummel (modhoster.de)
-* Wolverin0815 (Feldarbeitsmodus, HUD, ...)
-* Bastian82 (Feldarbeitsmodus, Optimierungen, ...)
-* Skydancer (Feldkursgenerierung, Güllezubringerunterstützung, ...)
-* JakobT (debug Modus, automatischer Abstand, neue Steuerung mit STRG)
-
-
-
\ No newline at end of file
+[CP Github]: https://github.com/Courseplay/courseplay
+[CP Website Link]: http://courseplay.github.com/courseplay/
diff --git a/recording.lua b/recording.lua
deleted file mode 100644
index 6c0aa2c0d..000000000
--- a/recording.lua
+++ /dev/null
@@ -1,404 +0,0 @@
--- records waypoints for course
-function courseplay:record(self)
- local cx, cy, cz = getWorldTranslation(self.rootNode);
- local x, y, z = localDirectionToWorld(self.rootNode, 0, 0, 1);
- local length = Utils.vector2Length(x, z);
- local dX = x / length
- local dZ = z / length
- local newangle = math.deg(math.atan2(dX, dZ))
- local fwd = self.direction
- if self.recordnumber < 2 then
- self.rotatedTime = 0
- end
- if self.recordnumber > 2 then
- local oldcx, oldcz, oldangle = self.Waypoints[self.recordnumber - 1].cx, self.Waypoints[self.recordnumber - 1].cz, self.Waypoints[self.recordnumber - 1].angle
- anglediff = math.abs(newangle - oldangle)
- self.dist = courseplay:distance(cx, cz, oldcx, oldcz)
- if self.direction == true then
- if self.dist > 2 and (anglediff > 1.5 or dist > 10) then
- self.tmr = 101
- end
- else
- if self.dist > 5 and (anglediff > 5 or dist > 10) then
- self.tmr = 101
- end
- end
- end
- if self.recordnumber == 2 then
- local oldcx, oldcz = self.Waypoints[1].cx, self.Waypoints[1].cz
- self.dist = courseplay:distance(cx, cz, oldcx, oldcz)
- if self.dist > 10 then
- self.tmr = 101
- else
- self.tmr = 1
- end
- end
- if self.recordnumber == 3 then
- local oldcx, oldcz = self.Waypoints[2].cx, self.Waypoints[2].cz
- self.dist = courseplay:distance(cx, cz, oldcx, oldcz)
- if self.dist > 20 then --20-
- self.tmr = 101
- else
- self.tmr = 1
- end
- end
- local set_crossing = false
- if self.recordnumber == 1 then
- set_crossing = true
- end
- if self.tmr > 100 then
- self.Waypoints[self.recordnumber] = { cx = cx, cz = cz, angle = newangle, wait = false, rev = self.direction, crossing = set_crossing, speed = self.lastSpeedReal }
- if self.recordnumber < 4 or self.waypointMode == 3 then
- if self.recordnumber == 1 then
- courseplay:addsign(self, cx, newangle, cz, self.start_sign)
- else
- courseplay:addsign(self, cx, newangle, cz)
- end
- end
- self.tmr = 1
- self.recordnumber = self.recordnumber + 1
- end
-end
-
-function courseplay:set_next_target(self, x, z)
- local next_x, next_y, next_z = localToWorld(self.rootNode, x, 0, z)
- local next_wp = { x = next_x, y = next_y, z = next_z }
- table.insert(self.next_targets, next_wp)
-end
-
-function courseplay:set_waitpoint(self)
- local cx, cy, cz = getWorldTranslation(self.rootNode);
- local x, y, z = localDirectionToWorld(self.rootNode, 0, 0, 1);
- local length = Utils.vector2Length(x, z);
- local dX = x / length
- local dZ = z / length
- local newangle = math.deg(math.atan2(dX, dZ))
- self.Waypoints[self.recordnumber] = { cx = cx, cz = cz, angle = newangle, wait = true, rev = self.direction, crossing = false, speed = 0 }
- self.tmr = 1
- self.recordnumber = self.recordnumber + 1
- self.waitPoints = self.waitPoints + 1
- courseplay:addsign(self, cx, cy, cz, self.wait_sign)
-end
-
-
-function courseplay:set_crossing(self, stop)
- local cx, cy, cz = getWorldTranslation(self.rootNode);
- local x, y, z = localDirectionToWorld(self.rootNode, 0, 0, 1);
- local length = Utils.vector2Length(x, z);
- local dX = x / length
- local dZ = z / length
- local newangle = math.deg(math.atan2(dX, dZ))
- self.Waypoints[self.recordnumber] = { cx = cx, cz = cz, angle = newangle, wait = false, rev = self.direction, crossing = true, speed = nil }
- self.tmr = 1
- self.recordnumber = self.recordnumber + 1
- self.crossPoints = self.crossPoints + 1
- if stop ~= nil then
- courseplay:addsign(self, cx, cy, cz, self.stop_sign)
- else
- courseplay:addsign(self, cx, cy, cz, self.cross_sign, true)
- end
-end
-
--- set Waypoint before change direction
-function courseplay:set_direction(self)
- local cx, cy, cz = getWorldTranslation(self.rootNode);
- local x, y, z = localDirectionToWorld(self.rootNode, 0, 0, 1);
- local length = Utils.vector2Length(x, z);
- local dX = x / length
- local dZ = z / length
- local newangle = math.deg(math.atan2(dX, dZ))
- local fwd = nil
- self.Waypoints[self.recordnumber] = { cx = cx, cz = cz, angle = newangle, wait = false, rev = self.direction, crossing = false, speed = nil }
- self.direction = not self.direction
- self.tmr = 1
- self.recordnumber = self.recordnumber + 1
- courseplay:addsign(self, cx, cy, cz)
-end
-
--- starts course recording -- just setting variables
-function courseplay:start_record(self)
- -- courseplay:reset_course(self)
- self.record = true
- self.drive = false
- self.loaded_courses = {}
- self.recordnumber = 1
- self.waitPoints = 0
- self.crossPoints = 0
- self.tmr = 101
- self.direction = false
-end
-
--- stops course recording -- just setting variables
-function courseplay:stop_record(self)
- courseplay:set_crossing(self, true)
- self.record = false
- self.record_pause = false
- self.drive = false
- self.dcheck = false
- self.play = true
- self.maxnumber = self.recordnumber - 1
- self.recordnumber = 1
- self.back = false
-end
-
--- interrupts course recording -- just setting variables
-function courseplay:interrupt_record(self)
- if self.recordnumber > 3 then
- self.record_pause = true
- self.record = false
- courseplay:sign_visibility(self, false)
- self.dcheck = true
- -- Show last 2 waypoints, in order to find position for continue
- local cx, cz = self.Waypoints[self.recordnumber - 1].cx, self.Waypoints[self.recordnumber - 1].cz
- courseplay:addsign(self, cx, 0, cz)
- cx, cz = self.Waypoints[self.recordnumber - 2].cx, self.Waypoints[self.recordnumber - 2].cz
- courseplay:addsign(self, cx, 0, cz)
- end
-end
-
--- continues course recording -- just setting variables
-function courseplay:continue_record(self)
- self.record_pause = false
- self.record = true
- self.dcheck = false
- courseplay:sign_visibility(self, false)
- courseplay:RefreshSigns(self)
-end
-
--- delete last waypoint
-function courseplay:delete_waypoint(self)
- if self.recordnumber > 3 then
- self.recordnumber = self.recordnumber - 1
- self.tmr = 1
- courseplay:RefreshSigns(self)
- self.Waypoints[self.recordnumber] = nil
- -- Show last 2 waypoints, in order to find position for continue
- local cx, cz = self.Waypoints[self.recordnumber - 1].cx, self.Waypoints[self.recordnumber - 1].cz
- courseplay:addsign(self, cx, 0, cz)
- cx, cz = self.Waypoints[self.recordnumber - 2].cx, self.Waypoints[self.recordnumber - 2].cz
- courseplay:addsign(self, cx, 0, cz)
- end
-end
-
--- resets actual course -- just setting variables
-function courseplay:reset_course(self)
- courseplay:reset_merged(self)
- self.recordnumber = 1
- self.target_x, self.target_y, self.target_z = nil, nil, nil
- if self.active_combine ~= nil then
- courseplay:unregister_at_combine(self, self.active_combine)
- end
- self.next_targets = {}
- self.loaded_courses = {}
- self.current_course_name = nil
- --self.ai_mode = 1
- self.ai_state = 1
- self.tmr = 1
- self.Waypoints = {}
- self.loaded_courses = {}
- courseplay:RefreshSigns(self)
- self.play = false
- self.back = false
- self.abortWork = nil
- self.createCourse = false
- self.startlastload = 1
-end
-
-function courseplay:set_FieldPoint(self)
- courseplay:createCourse(self, self.Waypoints)
-end
-
-function courseplay:createCourse(self, poly)
- courseplay:reset_course(self)
- n = table.getn(poly)
- minZ = poly[1].cz
- maxZ = poly[1].cz
- minX = poly[1].cx
- maxX = poly[1].cx
- for i = 2, n do
- local p = poly[i]
- if p.cx < minX then minX = p.cx end
- if p.cx > maxX then maxX = p.cx end
- if p.cz < minZ then minZ = p.cz end
- if p.cz > maxZ then maxZ = p.cz end
- end
- ab = {}
- cd = {}
- ab[1] = { x = minX, z = minZ, ka = "0" }
- ab[2] = { x = minX, z = maxZ, ka = "0" }
- ab[3] = { x = maxX, z = minZ, ka = "0" }
- ab[4] = { x = maxX, z = maxZ, ka = "0" }
- for i = 1, 4 do
- if (i + 1) == 5 then
- j = 1;
- else
- j = i + 1;
- end
- local dist = courseplay:distance(ab[i].x, ab[i].z, poly[1].cx, poly[1].cz)
- cd[i] = { x = ab[i].x, z = ab[i].z, ka = dist }
- end
- table.sort(cd, function(a, b) return a.ka < b.ka end)
- local duangel = 0
- for i = 1, 5 do
- duangel = duangel + poly[i].angle
- end
- duangel = duangel / 5
- local function bubbleSort(cd)
- local hasChanged
- local itemCount = 4
- repeat
- itemCount = itemCount - 1
- hasChanged = false
- for i = 2, itemCount do
- j = i + 1;
- local aTanA = math.atan2(cd[i].x - cd[1].x, cd[i].z - cd[1].z);
- local aTanB = math.atan2(cd[j].x - cd[1].x, cd[j].z - cd[1].z);
- if (duangel > 180 and duangel < 270) or (duangel > 0 and duangel < 90) then
- if (aTanA < aTanB) then
- cd[i].x, cd[j].x = cd[j].x, cd[i].x
- cd[i].z, cd[j].z = cd[j].z, cd[i].z
- hasChanged = true
- end
- else
- if (aTanB < aTanA) then
- cd[i].x, cd[j].x = cd[j].x, cd[i].x
- cd[i].z, cd[j].z = cd[j].z, cd[i].z
- hasChanged = true
- end
- end
- end
- until hasChanged == false
- end
-
- bubbleSort(cd)
-
- local cax = cd[1].x
- local caz = cd[1].z
- local cbx = cd[2].x
- local cbz = cd[2].z
- local ccx = cd[3].x
- local ccz = cd[3].z
- local cdx = cd[4].x
- local cdz = cd[4].z
- courseplay:reset_course(self)
- local vadx = cax - cdx
- local vadz = caz - cdz
- local vdax = cdx - cax
- local vdaz = cdz - caz
- local vbcx = cbx - ccx
- local vbcz = cbz - ccz
- local vcbx = ccx - cbx
- local vcbz = ccz - cbz
- local vabx = cax - cbx
- local vabz = caz - cbz
- local vbax = cbx - cax
- local vbaz = cbz - caz
- local vlad = Utils.vector2Length(vdax, vdaz)
- local vlbc = Utils.vector2Length(vcbx, vcbz)
- local workWidht = self.toolWorkWidht;
- local distWayPoint = 3
- local wx, wz = cax, caz
- local i, ib = 1, 1
- local fieldEndVad, fieldEndVbc, fieldEnd = false, false, false
- while fieldEnd == false do
- local reachedVad = (workWidht * (ib + 1) - (workWidht / 2)) / vlad
- local reachedVbc = (workWidht * (ib + 1) - (workWidht / 2)) / vlbc
- if math.mod(ib, 2) == 0 then
- if reachedVbc < 1 then
- if ib == 1 then
- wxe = cax + (workWidht / 2) * ib / vlad * vdax
- wze = caz + (workWidht / 2) * ib / vlad * vdaz
- wx = cbx + (workWidht / 2) * ib / vlbc * vcbx
- wz = cbz + (workWidht / 2) * ib / vlbc * vcbz
-
- else
- wxe = cax + (workWidht * ib - (workWidht / 2)) / vlad * vdax
- wze = caz + (workWidht * ib - (workWidht / 2)) / vlad * vdaz
- wx = cbx + (workWidht * ib - (workWidht / 2)) / vlbc * vcbx
- wz = cbz + (workWidht * ib - (workWidht / 2)) / vlbc * vcbz
- end
- else
- wxe = cdx + (workWidht / 2) / vlad * vadx
- wze = cdz + (workWidht / 2) / vlad * vadz
- wx = ccx + (workWidht / 2) / vlbc * vbcx
- wz = ccz + (workWidht / 2) / vlbc * vbcz
- fieldEndVbc = true
- end
- else
- if reachedVad < 1 then
- if ib == 1 then
- wx = cax + (workWidht / 2) * ib / vlad * vdax
- wz = caz + (workWidht / 2) * ib / vlad * vdaz
- wxe = cbx + (workWidht / 2) * ib / vlbc * vcbx
- wze = cbz + (workWidht / 2) * ib / vlbc * vcbz
- else
- wx = cax + (workWidht * ib - (workWidht / 2)) / vlad * vdax
- wz = caz + (workWidht * ib - (workWidht / 2)) / vlad * vdaz
- wxe = cbx + (workWidht * ib - (workWidht / 2)) / vlbc * vcbx
- wze = cbz + (workWidht * ib - (workWidht / 2)) / vlbc * vcbz
- end
- else
- wx = cdx + (workWidht / 2) / vlad * vadx
- wz = cdz + (workWidht / 2) / vlad * vadz
- wxe = ccx + (workWidht / 2) / vlbc * vbcx
- wze = ccz + (workWidht / 2) / vlbc * vbcz
- fieldEndVad = true
- end
- end
- self.Waypoints[i] = { cx = wx, cz = wz, angle = 0, wait = false, rev = false, crossing = false }
- local vsex = wx - wxe
- local vsez = wz - wze
- local vesx = wxe - wx
- local vesz = wze - wz
- local vlse = Utils.vector2Length(vsex, vsez)
- local vlab = Utils.vector2Length(vabx, vabz)
- local ig = 1
- local fielEndLength = false
- while fielEndLength == false do -- gerade setzen
- local reachedEndlength = (distWayPoint * (ig + 1) / vlse)
- if reachedEndlength < 1 then
- wxl = wx + (distWayPoint * ig / vlse) * vesx
- wzl = wz + (distWayPoint * ig / vlse) * vesz
- else
- wxl = wxe
- wzl = wze
- fielEndLength = true
- end
- local kamu = courseplay:pointInPolygon(poly, wxl, wzl)
- if kamu == true then
- self.Waypoints[i] = { cx = wxl, cz = wzl, angle = 0, wait = false, rev = false, crossing = false }
- i = i + 1
- end
- ig = ig + 1
- end
- ib = ib + 1
- fieldEnd = fieldEndVad or fieldEndVbc -- to do for not square Fields
- end
-
- self.maxnumber = table.getn(self.Waypoints)
- self.recordnumber = 1
- self.createCourse = false
- self.play = true
- self.Waypoints[1].wait = true
- self.Waypoints[self.maxnumber].wait = true
- courseplay:RefreshSigns(self)
-end
-
-function courseplay:pointInPolygon(vertices, x, z)
- local intersectionCount = 0
- local x0 = vertices[#vertices].cx - x;
- local z0 = vertices[#vertices].cz - z;
- for i = 1, #vertices do
- local x1 = vertices[i].cx - x;
- local z1 = vertices[i].cz - z;
- if z0 > 0 and z1 <= 0 and x1 * z0 > z1 * x0 then
- intersectionCount = intersectionCount + 1
- end
- if z1 > 0 and z0 <= 0 and x0 * z1 > z0 * x1 then
- intersectionCount = intersectionCount + 1
- end
- x0 = x1
- z0 = z1
- end
- return (intersectionCount % 2) == 1
-end
\ No newline at end of file
diff --git a/register.lua b/register.lua
deleted file mode 100644
index 313f7e478..000000000
--- a/register.lua
+++ /dev/null
@@ -1,98 +0,0 @@
-SpecializationUtil.registerSpecialization("courseplay", "courseplay", g_modsDirectory .. "/ZZZ_courseplay/courseplay.lua")
-SpecializationUtil.registerSpecialization("autoovercharge", "AutoOvercharge", g_modsDirectory .. "/ZZZ_courseplay/AutoOvercharge.lua")
-SpecializationUtil.registerSpecialization("perard", "perard", g_modsDirectory .. "/ZZZ_courseplay/AutoOvercharge.lua")
-
-
--- adding courseplay to default vehicles and vehicles that are loaded after courseplay in multiplayer
--- thanks to donner!
-
-function register_courseplay()
- for k, v in pairs(VehicleTypeUtil.vehicleTypes) do
- if v ~= nil then
- if v.name == "perard.perard" then
- --courseplay:debug("renew perard interbenne 25", 2);
- for l, w in pairs(v.specializations) do
- v.specializations[l] = nil
- end
- table.insert(v.specializations, SpecializationUtil.getSpecialization("fillable"));
- table.insert(v.specializations, SpecializationUtil.getSpecialization("attachable"));
- table.insert(v.specializations, SpecializationUtil.getSpecialization("trailer"));
- table.insert(v.specializations, SpecializationUtil.getSpecialization("perard"));
- else
- for a = 1, table.maxn(v.specializations) do
- local s = v.specializations[a];
- if s ~= nil then
- if s == SpecializationUtil.getSpecialization("steerable") then
- if not SpecializationUtil.hasSpecialization(courseplay, v.specializations) then
- --courseplay:debug("adding courseplay to:"..tostring(v.name), 3);
- table.insert(v.specializations, SpecializationUtil.getSpecialization("courseplay"));
- end
- end;
- if s == SpecializationUtil.getSpecialization("fillable") then
- if not SpecializationUtil.hasSpecialization(autoovercharge, v.specializations) then
- --courseplay:debug("adding autoovercharge to:"..tostring(v.name), 3);
- table.insert(v.specializations, SpecializationUtil.getSpecialization("autoovercharge"));
- end
- end
- end;
- end;
- end;
- end;
- end;
-end
-
-
--- dirty workaround for localization - don't try this at home!
--- get all l10n > text > #name attribues from modDesc.xml, insert them into courseplay.locales
-function cp_setLocales()
- courseplay.locales = {};
- if not Utils.endsWith(courseplay_path, "/") then
- courseplay_path = courseplay_path .. "/";
- end;
- local cp_modDesc_file = loadXMLFile("cp_modDesc", courseplay_path .. "modDesc.xml");
- local b=0;
- while true do
- local attr = string.format("modDesc.l10n.text(%d)#name", b);
- local textName = getXMLString(cp_modDesc_file, attr);
- if textName ~= nil then
- if not g_i18n:hasText(textName) then
- g_i18n:setText(textName, textName);
- end;
- courseplay.locales[textName] = g_i18n:getText(textName);
- --print(string.format("courseplay.locales[%s] (#%d) = %s", textName, b, courseplay.locales[textName]));
- b = b + 1;
- else
- break;
- end;
- end;
-end;
-
-function cp_setLines()
- courseplay.hud = {
- infoBasePosX = 0.433;
- infoBasePosY = 0.002;
- infoBaseWidth = 0.512; --try: 512/1920
- infoBaseHeight = 0.512; --try: 512/1080
- linesPosY = {};
- linesBottomPosY = {};
- linesButtonPosY = {};
- numLines = 5;
- lineHeight = 0.021;
- };
- for l=1,courseplay.hud.numLines do
- if l == 1 then
- courseplay.hud.linesPosY[l] = courseplay.hud.infoBasePosY + 0.210;
- courseplay.hud.linesBottomPosY[l] = courseplay.hud.infoBasePosY + 0.077;
- else
- courseplay.hud.linesPosY[l] = courseplay.hud.linesPosY[1] - ((l-1) * courseplay.hud.lineHeight);
- courseplay.hud.linesBottomPosY[l] = courseplay.hud.linesBottomPosY[1] - ((l-1) * courseplay.hud.lineHeight);
- end;
- courseplay.hud.linesButtonPosY[l] = courseplay.hud.linesPosY[l] + 0.0045;
- end;
-
-end;
-
-cp_setLines();
-cp_setLocales();
-register_courseplay();
-
diff --git a/settings.lua b/settings.lua
deleted file mode 100644
index bc2b002c8..000000000
--- a/settings.lua
+++ /dev/null
@@ -1,295 +0,0 @@
-function courseplay:change_ai_state(self, change_by)
- self.ai_mode = self.ai_mode + change_by
-
- if self.ai_mode == 9 or self.ai_mode == 0 then
- self.ai_mode = 1
- end
-end
-
-function courseplay:call_player(self)
- if self.wants_courseplayer then --edit for more sites
- self.wants_courseplayer = false
- else
- self.wants_courseplayer = true
- end
-end
-
-function courseplay:start_stop_player(self)
- local tractor = self.courseplayers[1]
- if tractor.forced_to_stop then --edit for more sites
- tractor.forced_to_stop = false
- else
- tractor.forced_to_stop = true
- end
-end
-
-function courseplay:send_player_home(self)
- local tractor = self.courseplayers[1]
- tractor.loaded = true
-end
-
-function courseplay:switch_player_side(self)
- if self.grainTankCapacity == 0 then
- local tractor = self.courseplayers[1]
- if tractor == nil then
- return
- end
-
- tractor.ai_state = 10
-
- if self.forced_side == nil then
- self.forced_side = "left"
- elseif self.forced_side == "left" then
- self.forced_side = "right"
- else
- self.forced_side = nil
- end
- end
-end
-
-function courseplay:switch_hud_page(self, change_by)
- self.showHudInfoBase = self.showHudInfoBase + change_by
-
- if self.showHudInfoBase < self.min_hud_page then --edit for more sites
- self.showHudInfoBase = 7
- end
-
- if self.showHudInfoBase == 8 then --edit for more sites
- self.showHudInfoBase = self.min_hud_page
- end
-end
-
-
-function courseplay:change_combine_offset(self, change_by)
- local previousOffset = self.combine_offset
-
- self.auto_combine_offset = false
- self.combine_offset = roundCustom(self.combine_offset, 1) + change_by
- if self.combine_offset < 0.1 and self.combine_offset > -0.1 then
- self.combine_offset = 0.0
- self.auto_combine_offset = true
- end
-
- courseplay:debug("manual combine_offset change: prev " .. previousOffset .. " // new " .. self.combine_offset .. " // auto = " .. tostring(self.auto_combine_offset), 2)
-end
-
-function courseplay:change_tipper_offset(self, change_by)
- self.tipper_offset = roundCustom(self.tipper_offset, 1) + change_by
- if self.tipper_offset > -0.1 and self.tipper_offset < 0.1 then
- self.tipper_offset = 0.0
- end
-end
-
-
-function courseplay:changeCPWpOffsetX(self, change_by)
- self.WpOffsetX = self.WpOffsetX + change_by
-end
-
-function courseplay:changeCPWpOffsetZ(self, change_by)
- self.WpOffsetZ = self.WpOffsetZ + change_by
-end
-
-function courseplay:changeWorkWidth(self, change_by)
- self.toolWorkWidht = self.toolWorkWidht + change_by
- self.workWidthChanged = self.timer + 2000
- if self.toolWorkWidht < 0.1 then
- self.toolWorkWidht = 0.1
- end
-end
-
-function courseplay:change_WaypointMode(self, change_by)
- self.waypointMode = self.waypointMode + change_by
- if self.waypointMode == 6 then
- self.waypointMode = 1
- end
- courseplay:RefreshSigns(self)
-end
-
-
-function courseplay:change_required_fill_level_for_drive_on(self, change_by)
- self.required_fill_level_for_drive_on = self.required_fill_level_for_drive_on + change_by
-
- if self.required_fill_level_for_drive_on < 0 then
- self.required_fill_level_for_drive_on = 0
- end
-
- if self.required_fill_level_for_drive_on > 100 then
- self.required_fill_level_for_drive_on = 100
- end
-end
-
-
-function courseplay:change_required_fill_level(self, change_by)
- self.required_fill_level_for_follow = self.required_fill_level_for_follow + change_by
-
- if self.required_fill_level_for_follow < 0 then
- self.required_fill_level_for_follow = 0
- end
-
- if self.required_fill_level_for_follow > 100 then
- self.required_fill_level_for_follow = 100
- end
-end
-
-
-function courseplay:change_turn_radius(self, change_by)
- self.turn_radius = self.turn_radius + change_by;
- self.turnRadiusAutoMode = false;
-
- if self.turn_radius < 0.5 then
- self.turn_radius = 0;
- end;
-
- if self.turn_radius <= 0 then
- self.turnRadiusAutoMode = true;
- self.turn_radius = self.autoTurnRadius
- end;
-end
-
-
-function courseplay:change_turn_speed(self, change_by)
- local speed = self.turn_speed * 3600
- speed = speed + change_by
- if speed < 5 then
- speed = 5
- end
- self.turn_speed = speed / 3600
-end
-
-function courseplay:change_wait_time(self, change_by)
- local speed = self.waitTime
-
- speed = speed + change_by
-
- if speed < 0 then
- speed = 0
- end
- self.waitTime = speed
-end
-
-function courseplay:change_field_speed(self, change_by)
- local speed = self.field_speed * 3600
- speed = speed + change_by
- if speed < 5 then
- speed = 5
- end
- self.field_speed = speed / 3600
-end
-
-function courseplay:change_max_speed(self, change_by)
- if not self.use_speed then
- local speed = self.max_speed * 3600;
- speed = speed + change_by;
- if speed < 5 then
- speed = 5;
- end
- self.max_speed = speed / 3600;
- end;
-end
-
-function courseplay:change_unload_speed(self, change_by)
- local speed = self.unload_speed * 3600;
- speed = speed + change_by;
- if speed < 3 then
- speed = 3;
- end
- self.unload_speed = speed / 3600;
-end
-
-function courseplay:change_RulMode(self, change_by)
- self.RulMode = self.RulMode + change_by
- if self.RulMode == 4 then
- self.RulMode = 1
- end
-end
-
-function courseplay:switch_mouse_right_key_enabled(self)
- self.mouse_right_key_enabled = not self.mouse_right_key_enabled
-end
-
-function courseplay:switch_search_combine(self)
- self.search_combine = not self.search_combine
-end
-
-function courseplay:switch_realistic_driving(self)
- self.realistic_driving = not self.realistic_driving
-end
-
-
-function courseplay:switch_use_speed(self)
- self.use_speed = not self.use_speed
-end
-
-function courseplay:switch_combine(self, change_by)
- local combines = courseplay:find_combines(self)
-
- local selected_combine_number = self.selected_combine_number + change_by
-
- if selected_combine_number < 0 then
- selected_combine_number = 0
- end
-
- if selected_combine_number > table.getn(combines) then
- selected_combine_number = table.getn(combines)
- end
-
- self.selected_combine_number = selected_combine_number
-
- if self.selected_combine_number == 0 then
- self.saved_combine = nil
- else
- self.saved_combine = combines[self.selected_combine_number]
- end
-end
-
-
-function courseplay:change_selected_course(self, change_by)
-
- local selected_course_number = self.selected_course_number
- selected_course_number = selected_course_number + change_by
-
- self.courseListPrev = true;
- self.courseListNext = true;
-
- local number_of_courses = 0
- for k, trigger in pairs(g_currentMission.courseplay_courses) do --TODO: table.getn ?
- number_of_courses = number_of_courses + 1
- end
-
- if selected_course_number >= number_of_courses - 4 then
- selected_course_number = number_of_courses - 5
- end
-
- if selected_course_number < 0 then
- selected_course_number = 0
- end
-
- if selected_course_number == 0 then
- self.courseListPrev = false;
- end;
- if selected_course_number == (number_of_courses - 5) then
- self.courseListNext = false;
- end;
-
- self.selected_course_number = selected_course_number
-end
-
-function courseplay:change_num_ai_helpers(self, change_by)
- local num_helpers = g_currentMission.maxNumHirables
- num_helpers = num_helpers + change_by
-
- if num_helpers < 1 then
- num_helpers = 1
- end
-
- g_currentMission.maxNumHirables = num_helpers
-end
-
-function courseplay:change_DebugLevel(change_by)
- CPDebugLevel = CPDebugLevel + change_by
- if CPDebugLevel == 5 then
- CPDebugLevel = 0
- end
- --print('CPDebugLevel = '..CPDebugLevel)
-end
-
diff --git a/signs.lua b/signs.lua
deleted file mode 100644
index 19429326b..000000000
--- a/signs.lua
+++ /dev/null
@@ -1,108 +0,0 @@
--- adds a visual waypoint to the map
-function courseplay:addsign(self, x, y, z, forced_sign, always_visible)
- local height = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, x, 300, z)
- local root = nil
- if forced_sign ~= nil then
- root = forced_sign
- else
- root = self.sign
- end
-
- local sign = clone(root, true)
- if forced_sign == nil then
- setTranslation(sign, x, height + 5, z)
- elseif forced_sign == self.cross_sign then
- setTranslation(sign, x, height + 4, z)
- else
- setTranslation(sign, x, height + 3, z)
- end
-
- setVisibility(sign, true)
- local sign_data = { sign = sign, always_visible = always_visible }
- table.insert(self.signs, sign_data)
- return (sign)
-end
-
-
--- should the signs be visible?
-function courseplay:sign_visibility(self, visibilty, force_remove)
- if self.signs == nil then
- return
- end
- for k, v in pairs(self.signs) do
- local vis = visibilty
-
- if v.always_visible then
- if self.waypointMode == 1 then
- if self.record then
- vis = true
- else
- vis = false
- end
-
- elseif self.waypointMode == 2 or self.waypointMode == 4 then
- vis = true
- elseif self.waypointMode == 3 then
- vis = false
- end
- end
-
- if force_remove then
- vis = false
- end
- setVisibility(v.sign, vis)
- end
-end
-
-
--- add Crosspoints to the signs
-function courseplay:RefreshGlobalSigns(self)
-
- if self.signs ~= nil then
- courseplay:sign_visibility(self, false, true)
- self.signs = {}
- end
- if g_currentMission.courseplay_courses ~= nil then -- ??? MP Ready ???
- for i = 1, table.getn(g_currentMission.courseplay_courses) do
- for k, v in pairs(g_currentMission.courseplay_courses[i].waypoints) do
- local wp = g_currentMission.courseplay_courses[i].waypoints[k]
- if wp.crossing == true then
- local x = wp.cx
- local y = wp.angle
- local z = wp.cz
- courseplay:addsign(self, x, y, z, self.cross_sign, true)
- end
- end
- end
- -- courseplay:debug("Refresh Global Signs", 4)
- end
-end
-
-
-function courseplay:RefreshSigns(self)
- self.waitPoints = 0
- self.crossPoints = 0
- courseplay:RefreshGlobalSigns(self)
- self.maxnumber = table.getn(self.Waypoints)
- for k, wp in pairs(self.Waypoints) do
- if k <= 3 or self.waypointMode >= 3 or wp.wait == true or k == self.maxnumber then
- if k == 1 then
- courseplay:addsign(self, wp.cx, wp.angle, wp.cz, self.start_sign)
- elseif wp.wait then
- courseplay:addsign(self, wp.cx, wp.angle, wp.cz, self.wait_sign)
- elseif k == self.maxnumber then
- courseplay:addsign(self, wp.cx, wp.angle, wp.cz, self.stop_sign)
- else
- courseplay:addsign(self, wp.cx, wp.angle, wp.cz)
- end
- end
-
-
- if wp.wait then
- self.waitPoints = self.waitPoints + 1
- end
- if wp.crossing then
- self.crossPoints = self.crossPoints + 1
- end
- end
-end
diff --git a/start_stop.lua b/start_stop.lua
deleted file mode 100644
index 02a0d92ab..000000000
--- a/start_stop.lua
+++ /dev/null
@@ -1,162 +0,0 @@
--- starts driving the course
-function courseplay:start(self)
- self.maxnumber = table.getn(self.Waypoints)
- if self.maxnumber < 1 then
- return
- end
-
- self.CPnumCollidingVehicles = 0;
- self.traffic_vehicle_in_front = nil
- --self.numToolsCollidingVehicles = {};
- self.drive = false
- self.record = false
- self.record_pause = false
- self.calculated_course = false
-
- AITractor.addCollisionTrigger(self, self);
-
- self.orig_maxnumber = self.maxnumber
- -- set default ai_state if not in mode 2 or 3
- if self.ai_mode ~= 2 and self.ai_mode ~= 3 then
- self.ai_state = 0
- end
-
- if (self.ai_mode == 4 or self.ai_mode == 6) and self.tipper_attached then
- local start_anim_time = self.tippers[1].startAnimTime
- if start_anim_time == 1 then
- self.fold_move_direction = 1
- else
- self.fold_move_direction = -1
- end
- end
-
- if self.recordnumber < 1 then
- self.recordnumber = 1
- end
-
- -- add do working players if not already added
- if self.working_course_player_num == nil then
- self.working_course_player_num = courseplay:add_working_player(self)
- end
-
- courseplay:reset_tools(self)
- -- show arrow
- self.dcheck = true
- -- current position
- local ctx, cty, ctz = getWorldTranslation(self.rootNode);
- -- positoin of next waypoint
- local cx, cz = self.Waypoints[self.recordnumber].cx, self.Waypoints[self.recordnumber].cz
- -- distance
- dist = courseplay:distance(ctx, ctz, cx, cz)
-
- if self.ai_state == 0 then
- local nearestpoint = dist
- local wpanz = 0
- -- search nearest Waypoint
- for i = 1, self.maxnumber do
- local cx, cz = self.Waypoints[i].cx, self.Waypoints[i].cz
- local wait = self.Waypoints[i].wait
- dist = courseplay:distance(ctx, ctz, cx, cz)
- if dist < nearestpoint then
- nearestpoint = dist
- self.recordnumber = i + 1
- end
- -- specific Workzone
- if self.ai_mode == 4 or self.ai_mode == 6 or self.ai_mode == 7 then
- if wait then
- wpanz = wpanz + 1
- end
-
- if wpanz == 1 and self.startWork == nil then
- self.startWork = i
- end
- if wpanz > 1 and self.stopWork == nil then
- self.stopWork = i
- end
- end
- end
- -- mode 6 without start and stop point, set them at start and end, for only-on-field-courses
- if self.ai_mode == 6 and wpanz == 0 then
- self.startWork = 1
- self.stopWork = self.maxnumber
- end
- -- print(string.format("StartWork: %d StopWork: %d",self.startWork,self.stopWork))
- if self.recordnumber > self.maxnumber then
- self.recordnumber = 1
- end
- end
-
- if self.recordnumber > 2 and self.ai_mode ~= 4 then
- self.loaded = true
- end
-
-
- self.forceIsActive = true;
- self.stopMotorOnLeave = false;
- self.steeringEnabled = false;
- self.deactivateOnLeave = false
- self.disableCharacterOnLeave = false
- -- ok i am near the waypoint, let's go
- self.checkSpeedLimit = false
- self.runOnceStartCourse = true;
- self.drive = true;
-
- self.orgRpm = {}
- self.orgRpm[1] = self.motor.maxRpm[1]
- self.orgRpm[2] = self.motor.maxRpm[2]
- self.orgRpm[3] = self.motor.maxRpm[3]
- self.record = false
- self.dcheck = false
-end
-
--- stops driving the course
-function courseplay:stop(self)
- --self:dismiss()
- self.forceIsActive = false;
- self.stopMotorOnLeave = true;
- self.steeringEnabled = true;
- self.deactivateOnLeave = true
- self.disableCharacterOnLeave = true
- if self.orgRpm then
- self.motor.maxRpm[1] = self.orgRpm[1]
- self.motor.maxRpm[2] = self.orgRpm[2]
- self.motor.maxRpm[3] = self.orgRpm[3]
- end
- self.record = false
- self.record_pause = false
- if self.ai_state > 4 then
- self.ai_state = 1
- end
-
- AITractor.removeCollisionTrigger(self, self);
-
-
- -- removing tippers
- if self.tipper_attached then
- for key, tipper in pairs(self.tippers) do
- -- TODO AITractor.removeToolTrigger(self, tipper)
- if SpecializationUtil.hasSpecialization(Attachable, tipper.specializations) then
- tipper:aiTurnOff()
- end
- end
- end
-
- -- reseting variables
-
- self.checkSpeedLimit = true
- self.currentTipTrigger = nil
- self.drive = false
- self.play = true
- self.dcheck = false
-
- self.motor:setSpeedLevel(0, false);
- self.motor.maxRpmOverride = nil;
- self.startWork = nil
- self.stopWork = nil
- self.StopEnd = false
- self.unloaded = false
-
- if g_server ~= nil then
- AIVehicleUtil.driveInDirection(self, 0, self.steering_angle, 0, 0, 28, false, moveForwards, 0, 1)
- end
-end
\ No newline at end of file
diff --git a/store.dds b/store.dds
deleted file mode 100644
index a7a42b476..000000000
Binary files a/store.dds and /dev/null differ
diff --git a/store_mg.dds b/store_mg.dds
deleted file mode 100644
index a7a42b476..000000000
Binary files a/store_mg.dds and /dev/null differ
diff --git a/tippers.lua b/tippers.lua
deleted file mode 100644
index 05437cad8..000000000
--- a/tippers.lua
+++ /dev/null
@@ -1,438 +0,0 @@
-function courseplay:detachImplement(implementIndex)
- self.tools_dirty = true;
-end
-
-function courseplay:reset_tools(self)
- self.tippers = {}
- -- are there any tippers?
- self.tipper_attached = courseplay:update_tools(self, self)
- self.currentTrailerToFill = nil
- self.lastTrailerToFillDistance = nil
- self.tools_dirty = false;
-end
-
-function courseplay:is_baler(workTool) -- is the tool a baler?
- return (SpecializationUtil.hasSpecialization(Baler, workTool.specializations) or workTool.balerUnloadingState ~= nil);
-end;
-function courseplay:is_baleLoader(workTool) -- is the tool a bale loader?
- return (SpecializationUtil.hasSpecialization(baleLoader, workTool.specializations) or SpecializationUtil.hasSpecialization(BaleLoader, workTool.specializations));
-end;
-function courseplay:is_sowingMachine(workTool) -- is the tool a sowing machine?
- return (SpecializationUtil.hasSpecialization(sowingMachine, workTool.specializations) or SpecializationUtil.hasSpecialization(SowingMachine, workTool.specializations));
-end;
-function courseplay:isFoldable(workTool) --is the tool foldable?
- return SpecializationUtil.hasSpecialization(Foldable, workTool.specializations) or SpecializationUtil.hasSpecialization(foldable, workTool.specializations);
-end;
-function courseplay:isUBT(workTool) --is the tool a UBT?
- return SpecializationUtil.hasSpecialization(ubt, workTool.specializations);
-end;
-
--- update implements to find attached tippers
-function courseplay:update_tools(self, tractor_or_implement)
- --steerable (tractor, combine etc.)
- local tipper_attached = false
- if SpecializationUtil.hasSpecialization(AITractor, tractor_or_implement.specializations) then
- local object = tractor_or_implement
- if self.ai_mode == 1 or self.ai_mode == 2 then
- -- if SpecializationUtil.hasSpecialization(Trailer, object.specializations) then
- if object.allowTipDischarge then
- tipper_attached = true
- table.insert(self.tippers, object)
- end
- elseif self.ai_mode == 3 then -- Overlader
- if SpecializationUtil.hasSpecialization(Trailer, object.specializations) then --to do
- tipper_attached = true
- table.insert(self.tippers, object)
- end
- elseif self.ai_mode == 4 then -- Fertilizer
- if SpecializationUtil.hasSpecialization(Sprayer, object.specializations) or courseplay:is_sowingMachine(object) or object.name == "AmazoneUX5200" then
- tipper_attached = true
- table.insert(self.tippers, object)
- end
- elseif self.ai_mode == 6 then -- Baler, foragewagon, baleloader
- if courseplay:is_baler(object)
- or courseplay:is_baleLoader(object)
- or SpecializationUtil.hasSpecialization(Tedder, object.specializations)
- or SpecializationUtil.hasSpecialization(windrower, object.specializations)
- or SpecializationUtil.hasSpecialization(cultivator, object.specializations)
- or SpecializationUtil.hasSpecialization(plough, object.specializations)
- or object.allowTipDischarge
- or courseplay:isUBT(object)
- or courseplay:isFoldable(object) then
- tipper_attached = true
- table.insert(self.tippers, object)
- end
- elseif self.ai_mode == 8 then -- Baler, foragewagon, baleloader
- --if SpecializationUtil.hasSpecialization(RefillTrigger, object.specializations) then
- tipper_attached = true
- table.insert(self.tippers, object)
- -- end
- end
- end
-
-
- -- go through all implements
- self.cpTrafficCollisionIgnoreList = {}
- for k, implement in pairs(tractor_or_implement.attachedImplements) do
- local object = implement.object
-
- --in front or in the back?
- if object.cp == nil then
- object.cp = {};
- end;
- local impXw, impYw, impZw = getWorldTranslation(object.rootNode);
- local vehToImpX, vehToImpY, vehToImpZ = worldToLocal(self.rootNode, impXw, impYw, impZw);
- if vehToImpZ > 0 then --implement in front of vehicle
- object.cp.positionToVehicle = 1;
- --print(string.format("Implement %s position = %d (in front) (vehToImpZ = %f)", object.name, object.cp.positionToVehicle, vehToImpZ));
- else
- object.cp.positionToVehicle = -1;
- --print(string.format("Implement %s position = %d (in back) (vehToImpZ = %f)", object.name, object.cp.positionToVehicle, vehToImpZ));
- end;
- --END in front or in the back
-
- if self.ai_mode == 1 or self.ai_mode == 2 then
- -- if SpecializationUtil.hasSpecialization(Trailer, object.specializations) then
- if object.allowTipDischarge then
- tipper_attached = true
- table.insert(self.tippers, object)
- end
- elseif self.ai_mode == 3 then -- Overlader
- if SpecializationUtil.hasSpecialization(Trailer, object.specializations) then --to do
- tipper_attached = true
- table.insert(self.tippers, object)
- end
- elseif self.ai_mode == 4 then -- Fertilizer and Seeding
- if SpecializationUtil.hasSpecialization(Sprayer, object.specializations) or courseplay:is_sowingMachine(object) or object.name == "AmazoneUX5200" then
- tipper_attached = true
- table.insert(self.tippers, object)
- end
- elseif self.ai_mode == 5 then -- Überführung
- if object.setPlane ~= nil then --open/close cover
- tipper_attached = true;
- table.insert(self.tippers, object);
- end;
- elseif self.ai_mode == 6 then -- Baler, foragewagon, baleloader
- if courseplay:is_baler(object)
- or courseplay:is_baleLoader(object)
- or SpecializationUtil.hasSpecialization(Tedder, object.specializations)
- or SpecializationUtil.hasSpecialization(windrower, object.specializations)
- or SpecializationUtil.hasSpecialization(cultivator, object.specializations)
- or SpecializationUtil.hasSpecialization(plough, object.specializations)
- or object.allowTipDischarge
- or courseplay:isUBT(object)
- or courseplay:isFoldable(object) then
- tipper_attached = true
- table.insert(self.tippers, object)
- end
- elseif self.ai_mode == 8 then -- Baler, foragewagon, baleloader
- --if SpecializationUtil.hasSpecialization(RefillTrigger, object.specializations) then
- tipper_attached = true
- table.insert(self.tippers, object)
- -- end
- end
-
- -- are there more tippers attached to the current implement?
- local other_tipper_attached
- if table.getn(object.attachedImplements) ~= 0 then
- other_tipper_attached = courseplay:update_tools(self, object)
- end
- if other_tipper_attached == true then
- tipper_attached = true
- end
-
- courseplay:debug(string.format("courseplay:update_tools() (%s)", self.name), 2);
-
- for k,v in pairs(self.components) do --TODO: self.components needed?
- self.cpTrafficCollisionIgnoreList[v.node] = true;
- end;
- courseplay:debug(tostring(object.name).." - adding to cpTrafficCollisionIgnoreList", 2)
- self.cpTrafficCollisionIgnoreList[object.rootNode] = true;
- end; --END for implement in attachedImplements
-
- if CPDebugLevel > 0 then
- print(string.format("%s cpTrafficCollisionIgnoreList", self.name));
- for a,b in pairs(self.cpTrafficCollisionIgnoreList) do
- local name = g_currentMission.nodeToVehicle[a].name
- print(string.format("\\___ %s = %s", tostring(a), tostring(name)));
- end;
- end
-
- courseplay:getAutoTurnradius(self, tipper_attached);
-
- --tipreferencepoints
- self.tipRefOffset = 0;
- if tipper_attached and self.tippers[1].rootNode ~= nil and self.tippers[1].tipReferencePoints ~= nil then
- local tipperX, tipperY, tipperZ = getWorldTranslation(self.tippers[1].rootNode);
- if tipper_attached and table.getn(self.tippers[1].tipReferencePoints) > 1 then
- for n=1 ,table.getn(self.tippers[1].tipReferencePoints) do
- local tipRefPointX, tipRefPointY, tipRefPointZ = worldToLocal(self.tippers[1].tipReferencePoints[n].node, tipperX, tipperY, tipperZ);
- tipRefPointX = math.abs(tipRefPointX);
- if tipRefPointX > 0.1 then
- self.tipRefOffset = tipRefPointX;
- break;
- end;
- end;
- else
- self.tipRefOffset = 0;
- end;
- end;
-
-
- --tippers with covers
- self.cp.tipperHasCover = false;
- self.cp.tippersWithCovers = nil;
- self.cp.tippersWithCovers = {};
- --courseplay:debug(self.name .. ": tipper_attached = ".. tostring(tipper_attached), 3);
- if tipper_attached then
- for i=1, table.getn(self.tippers) do
- if self.tippers[i].setPlane ~= nil then
- courseplay:debug(string.format("Implement \"%s\" has a cover (setPlane ~= nil)", self.tippers[i].name), 3);
- self.cp.tipperHasCover = true;
- table.insert(self.cp.tippersWithCovers, i);
- else
- courseplay:debug(string.format("Implement \"%s\" doesn't have a cover (setPlane == nil)", self.tippers[i].name), 3);
- end;
- end;
- end;
- courseplay:debug(tableShow(self.cp.tippersWithCovers, self.name .. ": self.cp.tippersWithCovers"), 4);
- --END tippers with covers
-
-
- if tipper_attached then
- return true
- end
- return nil
-end
-
--- loads all tippers
-function courseplay:load_tippers(self)
- local allowedToDrive = false
- local cx, cz = self.Waypoints[2].cx, self.Waypoints[2].cz
- local tipper_fill_level, tipper_capacity = self:getAttachedTrailersFillLevelAndCapacity()
- if tipper_fill_level == nil then tipper_fill_level = 0 end
- if tipper_capacity == nil then tipper_capacity = 0 end
- local fill_level = 0
- if tipper_capacity ~= 0 then
- fill_level = tipper_fill_level * 100 / tipper_capacity
- end
-
- if self.currentTrailerToFill == nil then
- self.currentTrailerToFill = 1
- end
-
- -- drive on when required fill level is reached
- local drive_on = false
- if self.timeout < self.timer or self.last_fill_level == nil then
- if self.last_fill_level ~= nil and fill_level == self.last_fill_level and fill_level > self.required_fill_level_for_follow then
- drive_on = true
- end
- self.last_fill_level = fill_level
- courseplay:set_timeout(self, 7000)
- end
-
- if fill_level == 100 or drive_on then
- self.last_fill_level = nil
- self.loaded = true
- self.lastTrailerToFillDistance = nil
- self.currentTrailerToFill = nil
- return true
- end
-
- if self.lastTrailerToFillDistance == nil then
-
- local current_tipper = self.tippers[self.currentTrailerToFill]
-
- -- drive on if actual tipper is full
- if current_tipper.fillLevel == current_tipper.capacity then
- if table.getn(self.tippers) > self.currentTrailerToFill then
- local tipper_x, tipper_y, tipper_z = getWorldTranslation(self.tippers[self.currentTrailerToFill].rootNode)
-
- self.lastTrailerToFillDistance = courseplay:distance(cx, cz, tipper_x, tipper_z)
-
- self.currentTrailerToFill = self.currentTrailerToFill + 1
- else
- self.currentTrailerToFill = nil
- self.lastTrailerToFillDistance = nil
- end
- allowedToDrive = true
- end
-
- else
- local tipper_x, tipper_y, tipper_z = getWorldTranslation(self.tippers[self.currentTrailerToFill].rootNode)
-
- local distance = courseplay:distance(cx, cz, tipper_x, tipper_z)
-
- if distance > self.lastTrailerToFillDistance and self.lastTrailerToFillDistance ~= nil then
- allowedToDrive = true
- else
- allowedToDrive = false
- local current_tipper = self.tippers[self.currentTrailerToFill]
- if current_tipper.fillLevel == current_tipper.capacity then
- if table.getn(self.tippers) > self.currentTrailerToFill then
- local tipper_x, tipper_y, tipper_z = getWorldTranslation(self.tippers[self.currentTrailerToFill].rootNode)
- self.lastTrailerToFillDistance = courseplay:distance(cx, cz, tipper_x, tipper_z)
- self.currentTrailerToFill = self.currentTrailerToFill + 1
- else
- self.currentTrailerToFill = nil
- self.lastTrailerToFillDistance = nil
- end
- end
- end
- end
-
- -- normal mode if all tippers are empty
- return allowedToDrive
-end
-
--- unloads all tippers
-function courseplay:unload_tippers(self)
- local allowedToDrive = true
- for k, tipper in pairs(self.tippers) do
- --if not tipper.allowsDetaching then
- local numReferencePoints = table.getn(tipper.tipReferencePoints);
- local fruitType = tipper:getCurrentFruitType()
-
- if self.currentTipTrigger.bunkerSilo ~= nil then
-
- local silos = table.getn(self.currentTipTrigger.bunkerSilo.movingPlanes)
- local x, y, z = getWorldTranslation(tipper.tipReferencePoints[1].node)
- local sx, sy, sz = worldToLocal(self.currentTipTrigger.bunkerSilo.movingPlanes[1].nodeId, x, y, z)
- local ex, ey, ez = worldToLocal(self.currentTipTrigger.bunkerSilo.movingPlanes[silos].nodeId, x, y, z)
- self.startentfernung = Utils.vector2Length(sx, sz)
- self.endentfernung = Utils.vector2Length(ex, ez)
- local laenge = courseplay:distance(sx, sz, ex, ez)
- self.position = self.startentfernung*100/laenge
- self.gofortipping = false
- if self.runonce == nil then
- self.runonce = 0
- end
- self.filling1 = 0
- self.filling2 = 0
- self.filling3 = 0
- if self.runonce == 0 then
- if self.startentfernung < self.endentfernung then --Richtungsentscheidung
- self.BGAdirection = 1 --vorwärts
- else
- self.BGAdirection = 0 --rückwärts
- end
- for k = 1,silos,1 do
- local filling = self.currentTipTrigger.bunkerSilo.movingPlanes[k].fillLevel
- if k <= math.ceil(silos * 0.3) then
- self.filling1 = self.filling1 + filling
- --print(tostring(k)..":1:"..tostring(self.filling1))
- elseif k <= math.ceil(silos * 0.6) then
- self.filling2 = self.filling2 + filling
- --print(tostring(k)..":2:"..tostring(self.filling2))
- elseif k <= silos then
- self.filling3 = self.filling3 + filling
- --print(tostring(k)..":3:"..tostring(self.filling3))
- end
- end;
- print(string.format("bga section 1: %f, bga section 3: %f, bga section 3: %f", self.filling1, self.filling2, self.filling3));
-
- if self.filling1 <= self.filling2 and self.filling1 < self.filling3 then
- self.tipLocation = 1
- elseif self.filling2 <= self.filling3 and self.filling2 < self.filling1 then
- self.tipLocation = 2
- elseif self.filling3 < self.filling1 and self.filling3 < self.filling2 then
- self.tipLocation = 3
- else
- self.tipLocation = 1
- end
- print(string.format("BGA tipLocation = %d", self.tipLocation));
- self.runonce = 1
- end
- if self.tipLocation == 1 then
- if self.position >= 0 and self.position <= 40 then
- self.gofortipping = true
- end
- elseif self.tipLocation == 2 then
- if self.position >= 30 and self.position <= 70 then
- self.gofortipping = true
- end
- elseif self.tipLocation == 3 then
- if self.position >= 60 then
- self.gofortipping = true
- end
- end
- else
- self.gofortipping = true
- end
- if self.currentTipTrigger.acceptedFillTypes[fruitType] and self.gofortipping == true then
- if tipper.tipState == Trailer.TIPSTATE_CLOSED then
- if self.currentTipTrigger:getTipDistanceFromTrailer(tipper, tipper.currentTipReferencePointIndex) == 0 or self.currentTipTrigger.bunkerSilo ~= nil then --courtesy of Satis
- if self.toggledTipState < numReferencePoints then
- self.toggledTipState = self.toggledTipState +1
- tipper:toggleTipState(self.currentTipTrigger,self.toggledTipState);
- self.unloading_tipper = tipper
- else
- self.toggledTipState = 0
- end
- end
- elseif tipper.tipState ~= Trailer.TIPSTATE_CLOSING then
- allowedToDrive = false
- end
-
- if self.currentTipTrigger.bunkerSilo ~= nil then
- allowedToDrive = true
- end
- else
- courseplay:debug("trigger does not accept fruit or self.gofortipping = false(BGA) ", 1);
- end
- end
- return allowedToDrive
-end
-
-function courseplay:getAutoTurnradius(self, tipper_attached)
- local sinAlpha = 0 --Sinus vom Lenkwinkel
- local wheelbase = 0 --Radstand
- local track = 0 --Spurweite
- local turnRadius --Wendekreis unbereinigt
- if self.foundWheels == nil then
- self.foundWheels = {}
- end
- for i=1,#self.wheels do
- local wheel = self.wheels[i]
- if wheel.rotMax ~= 0 then
- if self.foundWheels[1] == nil then
- sinAlpha = wheel.rotMax
- self.foundWheels[1] = wheel
- elseif self.foundWheels[2] == nil then
- self.foundWheels[2] = wheel
- end
- elseif self.foundWheels[3] == nil then
- self.foundWheels[3] = wheel
- end
-
- end
- if table.getn(self.foundWheels) == 3 then
- local wh1X, wh1Y, wh1Z = getWorldTranslation(self.foundWheels[1].driveNode);
- local wh2X, wh2Y, wh2Z = getWorldTranslation(self.foundWheels[2].driveNode);
- local wh3X, wh3Y, wh3Z = getWorldTranslation(self.foundWheels[3].driveNode);
- track = courseplay:distance(wh1X, wh1Z, wh2X, wh2Z)
- wheelbase = courseplay:distance(wh1X, wh1Z, wh3X, wh3Z)
- turnRadius = 2*wheelbase/sinAlpha+track
- self.foundWheels = {}
- else
- turnRadius = self.turn_radius -- Kasi and Co are not supported. Nobody does hauling with a Kasi or Quadtrack !!!
- end
- if tipper_attached then
- local n = table.getn(self.tippers)
- if n == 1 then
- if self.tippers[1].attacherVehicle ~= self then
- self.autoTurnRadius = turnRadius * 2 --Dolly
- else
- self.autoTurnRadius = turnRadius --normaler Trailer
- end
- else
- self.autoTurnRadius = (turnRadius * n) -->1 Trailers
- end
- else
- self.autoTurnRadius = turnRadius
- end
-
- if self.turnRadiusAutoMode then
- self.turn_radius = self.autoTurnRadius;
- end;
-end
diff --git a/triggers.lua b/triggers.lua
deleted file mode 100644
index f45c5ac33..000000000
--- a/triggers.lua
+++ /dev/null
@@ -1,134 +0,0 @@
--- triggers
-
--- traffic collision
-function courseplay:cponTrafficCollisionTrigger(triggerId, otherId, onEnter, onLeave, onStay, otherShapeId)
- if otherId == self.rootNode then
- return
- end
- if onEnter or onLeave then
- if otherId == Player.rootNode then
- if onEnter then
- self.CPnumCollidingVehicles = self.CPnumCollidingVehicles + 1;
- self.numCollidingVehicles[triggerId] = self.numCollidingVehicles[triggerId]+1;
- elseif onLeave then
- self.CPnumCollidingVehicles = math.max(self.CPnumCollidingVehicles - 1, 0);
- self.numCollidingVehicles[triggerId] = math.max(self.numCollidingVehicles[triggerId]-1, 0);
-
- end;
- else
- courseplay:debug("found trigger",1)
- local vehicle = g_currentMission.nodeToVehicle[otherId];
- local vehicleConcerned = g_currentMission.nodeToVehicle[otherId]
- local vehicleOnList = false
- if vehicle ~= nil then
- courseplay:debug("checking CollisionIgnoreList",1)
- for a,b in pairs (self.cpTrafficCollisionIgnoreList) do
- courseplay:debug(tostring(g_currentMission.nodeToVehicle[a].name).." vs "..tostring(vehicleConcerned.name),1)
- if g_currentMission.nodeToVehicle[a].id == vehicleConcerned.id then
- courseplay:debug(tostring(vehicleConcerned.name).." is on list",1)
- vehicleOnList = true
- break
- end
- end
- end
- if vehicle ~= nil and self.trafficCollisionIgnoreList[otherId] == nil and vehicleOnList == false then
- if onEnter then
- self.traffic_vehicle_in_front = otherId
- self.CPnumCollidingVehicles = self.CPnumCollidingVehicles + 1;
- self.numCollidingVehicles[triggerId] = self.numCollidingVehicles[triggerId]+1;
- elseif onLeave then
- self.CPnumCollidingVehicles = math.max(self.CPnumCollidingVehicles - 1, 0);
- self.numCollidingVehicles[triggerId] = math.max(self.numCollidingVehicles[triggerId]-1, 0);
- end;
- end;
- end;
- end;
-end
-
--- tip trigger
-function courseplay:findTipTriggerCallback(transformId, x, y, z, distance)
- --C.Schoch
- --local trigger_objects = g_currentMission.onCreateLoadedObjects
- local trigger_objects = {};
- if g_currentMission.onCreateLoadedObjects ~= nil then
- for k, trigger in pairs(g_currentMission.onCreateLoadedObjects) do
- table.insert(trigger_objects, trigger)
- end
- end
- --C.Schoch
- if g_currentMission.tipAnywhereTriggers ~= nil then
- for k, trigger in pairs(g_currentMission.tipAnywhereTriggers) do
- table.insert(trigger_objects, trigger)
- end
- end
- -- C.Schoch
- if g_currentMission.tipTriggers ~= nil then
- for k, trigger in pairs(g_currentMission.tipTriggers) do
- if trigger.isExtendedTrigger or trigger.className == "HeapTipTrigger" then
- table.insert(trigger_objects, trigger);
- end;
- end
- end;
- -- C.Schoch
- -- courseplay:debug(table.show(trigger_objects), 4);
- for k, trigger in pairs(trigger_objects) do
- --courseplay:debug(trigger.className, 3);
- if (trigger.className and (trigger.className == "SiloTrigger" or trigger.className == "HeapTipTrigger" or endswith(trigger.className, "TipTrigger") or startswith(trigger.className, "MapBGA"))) or trigger.isTipAnywhereTrigger then
- -- transformId
- if not trigger.className then
- -- little hack ;)
- trigger.className = "TipAnyWhere"
- end
- local tipper_fill_level, tipper_capacity = self:getAttachedTrailersFillLevelAndCapacity()
- if trigger.triggerId ~= nil and trigger.triggerId == transformId and (trigger.bunkerSilo == nil or (trigger.bunkerSilo.fillLevel + tipper_capacity) < trigger.bunkerSilo.capacity) then
- courseplay:debug(table.show(trigger), 4);
- local fruitType = self.tippers[1]:getCurrentFruitType()
-
- if trigger.acceptedFillTypes[fruitType] then
- self.currentTipTrigger = trigger
- end
- elseif trigger.triggerIds ~= nil and transformId ~= nil and table.contains(trigger.triggerIds, transformId) then
- self.currentTipTrigger = trigger
- elseif trigger.specialTriggerId ~= nil and trigger.specialTriggerId == transformId then
- -- support map bga by headshot xxl
- if trigger.silage.fillLevel < trigger.silage.maxFillLevel then
- self.currentTipTrigger = trigger
- end
- end
- end
- end
-end
-
-
-function table.contains(table, element)
- for _, value in pairs(table) do
- if value == element then
- return true
- end
- end
- return false
-end
-
-function startswith(sbig, slittle)
- if type(slittle) == "table" then
- for k, v in ipairs(slittle) do
- if string.sub(sbig, 1, string.len(v)) == v then
- return true
- end
- end
- return false
- end
- return string.sub(sbig, 1, string.len(slittle)) == slittle
-end
-
-function endswith(sbig, slittle)
- if type(slittle) == "table" then
- for k, v in ipairs(slittle) do
- if string.sub(sbig, string.len(sbig) - string.len(v) + 1) == v then
- return true
- end
- end
- return false
- end
- return string.sub(sbig, string.len(sbig) - string.len(slittle) + 1) == slittle
-end