The relevant parts of the mod:
Code: Select all
local function onTick(event)
if global.destroyNextTick[event.tick] then
local pis = global.destroyNextTick[event.tick]
for _, pi in pairs(pis) do
GUI.destroyGui(game.players[pi])
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)
end
end
end
--snip
function onPlayerDrivingChangedState(event)
local player = game.players[event.player_index]
if (player.vehicle ~= nil and player.vehicle.name == "farl") then
if player.gui.left.farl == nil then
FARL.onPlayerEnter(player)
GUI.createGui(player)
end
end
if player.vehicle == nil and player.gui.left.farl ~= nil then
FARL.onPlayerLeave(player)
local tick = event.tick + 1
if not global.destroyNextTick[tick] then
global.destroyNextTick[tick] = {}
end
table.insert(global.destroyNextTick[tick], event.player_index)
end
end
--snip
game.on_event(defines.events.on_tick, onTick)
game.on_event(defines.events.on_player_driving_changed_state, onPlayerDrivingChangedState)
mod: https://github.com/Choumiko/FARL/releas ... _0.3.3.zip
Error log attached