Last active
December 15, 2015 03:59
-
-
Save JakobTischler/5198137 to your computer and use it in GitHub Desktop.
automatic closing/opening of covers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
--INFO: setPlane(true) = open / setPlane(false) = closed | |
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- [ update_tools() ] | |
--tippers with covers | |
self.cp.tipperHasCover = false; | |
self.cp.tippersWithCovers = nil; | |
self.cp.tippersWithCovers = {}; | |
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)", tostring(self.tippers[i].name)), 3); | |
self.cp.tipperHasCover = true; | |
table.insert(self.cp.tippersWithCovers, i); | |
end; | |
end; | |
end; | |
courseplay:debug(tableShow(self.cp.tippersWithCovers, tostring(self.name) .. ": self.cp.tippersWithCovers"), 4); | |
--END tippers with covers | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment