Skip to content

Commit

Permalink
0.3.31
Browse files Browse the repository at this point in the history
  • Loading branch information
Choumiko committed Aug 12, 2015
1 parent dede1e7 commit 6719a23
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 4 additions & 2 deletions FARL.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ FARL = {
direction = false, input = 1, name = vehicle.backer_name,
signalCount = 0, cruise = false, cruiseInterrupt = 0,
lastposition = false, maintenance = false, surface = vehicle.surface,
recheckRails = {}
recheckRails = {}, destroy = false
}
new.settings = Settings.loadByPlayer(player)
setmetatable(new, {__index=FARL})
Expand All @@ -155,16 +155,18 @@ FARL = {
if i then
global.farl[i].driver = player
global.farl[i].settings = Settings.loadByPlayer(player)
global.farl[i].destroy = false
else
table.insert(global.farl, FARL.new(player))
end
end,

onPlayerLeave = function(player)
onPlayerLeave = function(player, tick)
for i,f in ipairs(global.farl) do
if f.driver and f.driver.name == player.name then
f:deactivate()
f.driver = false
f.destroy = tick
--f.settings = false
break
end
Expand Down
19 changes: 14 additions & 5 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,21 @@ clearAreas = {
local pis = global.destroyNextTick[event.tick]
for _, pi in pairs(pis) do
GUI.destroyGui(game.players[pi])
debugDump("Gui destroyed (on tick)")
end
global.destroyNextTick[event.tick] = nil
end
for i, farl in pairs(global.farl) do
farl:update(event)
if farl.driver and farl.driver.name ~= "farl_player" then
GUI.updateGui(farl)
if not farl.destroy then
farl:update(event)
if farl.driver and farl.driver.name ~= "farl_player" then
GUI.updateGui(farl)
end
else
if farl.destroy == event.tick then
farl.destroy = false
farl.settings = false
end
end
end
end
Expand Down Expand Up @@ -281,8 +289,9 @@ clearAreas = {
end
end
if player.vehicle == nil and player.gui.left.farl ~= nil then
FARL.onPlayerLeave(player)
local tick = event.tick + 1
FARL.onPlayerLeave(player, event.tick + 5)
debugDump("onPlayerLeave (driving state changed)")
local tick = event.tick + 5
if not global.destroyNextTick[tick] then
global.destroyNextTick[tick] = {}
end
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FARL",
"version": "0.3.3",
"version": "0.3.31",
"title": "Fully Automated Rail Layer",
"author": "Choumiko",
"contact": "www.factorioforums.com",
Expand Down

0 comments on commit 6719a23

Please sign in to comment.