Skip to content

Commit

Permalink
check if YARM has required interface
Browse files Browse the repository at this point in the history
ignore blueprints containing only concrete/stone paths
init globals when updating FARL
don't try to start on curves (needs reqrite first)
  • Loading branch information
Choumiko committed Nov 2, 2015
1 parent f9e8396 commit 4ce2660
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
11 changes: 9 additions & 2 deletions FARL.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ FARL = {
farl = FARL.new(player)
table.insert(global.farl, farl)
end
if remote.interfaces.YARM then
if remote.interfaces.YARM and remote.interfaces.YARM.hide_expando then
farl.settings.YARM_old_expando = remote.call("YARM", "hide_expando", player.index)
end
--apiCalls = {find={item=0,tree=0,stone=0,other=0},canplace=0,create=0,count={item=0,tree=0,stone=0,other=0}}
Expand All @@ -166,7 +166,7 @@ FARL = {
f:deactivate()
f.driver = false
f.destroy = tick
if remote.interfaces.YARM and f.settings.YARM_old_expando then
if remote.interfaces.YARM and remote.interfaces.YARM.show_expando and f.settings.YARM_old_expando then
remote.call("YARM", "show_expando", player.index)
end
--f.settings = false
Expand Down Expand Up @@ -659,6 +659,10 @@ FARL = {

local maintenance = self.maintenance and 10 or false
self.lastrail = self:findLastRail(maintenance)
if self.lastrail.name == self.settings.rail.curved then
self:deactivate({"msg-error-curves"}, true)
return
end
self.lastCheckIndex = 1
if self.lastrail then
self:findLastPole()
Expand Down Expand Up @@ -938,6 +942,9 @@ FARL = {
local vertSignal = signalOffset[0]
local diagSignal = signalOffset[1]
local e = bp[j].get_blueprint_entities()
if not e then -- blueprint with only tiles in it
break
end
local offsets = {pole=false, chain=false, poleEntities={}, rails={}, signals={}}
local bpType = false
local rails = 0
Expand Down
35 changes: 15 additions & 20 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ local function init_global()
global.godmode = false
godmode = global.godmode
global.destroyNextTick = global.destroyNextTick or {}

global.version = global.version or "0.4.41"
setMetatables()
end

Expand Down Expand Up @@ -100,15 +100,10 @@ local function on_configuration_changed(data)
local newVersion = data.mod_changes[MOD_NAME].new_version
local oldVersion = data.mod_changes[MOD_NAME].old_version
-- mod was added to existing save
if not oldVersion then
init_global()
init_players()
global.electricInstalled = remote.interfaces.dim_trains and remote.interfaces.dim_trains.railCreated
else
if oldVersion < "0.4.4" then
global.electricInstalled = remote.interfaces.dim_trains and remote.interfaces.dim_trains.railCreated
end
end
init_global()
init_players()
global.electricInstalled = remote.interfaces.dim_trains and remote.interfaces.dim_trains.railCreated
global.version = "0.4.41"
end
if data.mod_changes["5dim_trains"] then
--5dims_trains was added/updated
Expand All @@ -131,17 +126,17 @@ end

local function on_gui_click(event)
local status, err = pcall(function()
local index = event.player_index
local player = game.players[index]
if player.gui.left.farl ~= nil then --and player.gui.left.farlAI == nil then
local farl = FARL.findByPlayer(player)
if farl then
GUI.onGuiClick(event, farl, player)
else
player.print("Gui without train, wrooong!")
GUI.destroyGui(player)
local index = event.player_index
local player = game.players[index]
if player.gui.left.farl ~= nil then --and player.gui.left.farlAI == nil then
local farl = FARL.findByPlayer(player)
if farl then
GUI.onGuiClick(event, farl, player)
else
player.print("Gui without train, wrooong!")
GUI.destroyGui(player)
end
end
end
end)
if not status then
debugDump("Unexpected error:",true)
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.4.4",
"version": "0.4.41",
"title": "Fully Automated Rail Layer",
"author": "Choumiko",
"contact": "www.factorioforums.com",
Expand Down

0 comments on commit 4ce2660

Please sign in to comment.