From 7ed49fb711c49de20d0edcd38e4abffa2a6af797 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Sat, 18 Feb 2017 13:42:29 -0500 Subject: [PATCH] Update for Factorio 0.14 --- .gitignore | 2 ++ YARM | 2 +- advanced-logistics-system | 2 +- promfacto/control.lua | 23 ++++++++++++----------- promfacto/info.json | 5 +++-- 5 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f26573f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.zip +*.sw? diff --git a/YARM b/YARM index f232f3a..587bef3 160000 --- a/YARM +++ b/YARM @@ -1 +1 @@ -Subproject commit f232f3af5e7e5766b442dbfc822055f9255a1158 +Subproject commit 587bef31935c70b4bf25aaa020c49008aab95983 diff --git a/advanced-logistics-system b/advanced-logistics-system index a335905..a300d3c 160000 --- a/advanced-logistics-system +++ b/advanced-logistics-system @@ -1 +1 @@ -Subproject commit a335905309b25dd308eefeb21150232b740b7719 +Subproject commit a300d3c67f1b9b3ce18750cd62c2c8232bf443a9 diff --git a/promfacto/control.lua b/promfacto/control.lua index ee0a212..48efd91 100644 --- a/promfacto/control.lua +++ b/promfacto/control.lua @@ -4,7 +4,7 @@ -- - sample input inventory: when nonzero, indicates a potentially blocked machine -- - try counting enemies via surface rather than game.force -require "defines" +-- require "defines" prometheus = require("prometheus/tarantool-prometheus") count_deaths = prometheus.counter("factorio_deaths", "entity died", {"entity_name"}) @@ -117,7 +117,7 @@ end) --- init all players function initPlayers() - for _,player in ipairs(game.players) do + for _,player in pairs(game.players) do initPlayer(player) end end @@ -145,7 +145,7 @@ function initPlayer(player) end function updatePlayers() - for _,player in ipairs(game.players) do + for _,player in pairs(game.players) do updatePlayer(player) end end @@ -202,7 +202,7 @@ end function reportFurnaces(forceName) local totEnergy = 0 local furnaces = {} - local surface = game.get_surface(1) + local surface = game.surfaces["nauvis"] for xys,ent in pairs(global.furnaces) do local details = global.furnaceDetails[xys] or {name = ent.name} if (not ent.valid) and details then @@ -257,7 +257,7 @@ end function reportBatteries(forceName) local totEnergy = 0 - local surface = game.get_surface(1) + local surface = game.surfaces["nauvis"] for xys,ent in pairs(global.batteries) do if not ent.valid then ent = surface.find_entity("basic-accumulator", str2pos(xys)) @@ -274,7 +274,7 @@ function reportBuilders(forceName) local hasoutput = {} local hasinput = {} local crafting = {} - local surface = game.get_surface(1) + local surface = game.surfaces["nauvis"] for xys,ent in pairs(global.builders) do if not ent.valid then for i = 1,3 do @@ -319,7 +319,7 @@ end function getPollution() - local surface = game.get_surface(1) + local surface = game.surfaces["nauvis"] local pollutionTotal = 0 local chunks = 0 forEachChunk(function(chunk_coord, area) @@ -334,7 +334,7 @@ function getPollution() end function forEachChunk(f) - local surface = game.get_surface(1) + local surface = game.surfaces["nauvis"] for coord in surface.get_chunks() do local X,Y = coord.x, coord.y @@ -349,7 +349,8 @@ end function getEntities(force, types) -- print("getEntities " .. serpent.line(types)) - local surface = game.get_surface(1) + local surface = game.surfaces["nauvis"] + local ents = {} forEachChunk(function(chunk_coord, area) for _,type in pairs(types) do @@ -367,7 +368,7 @@ end function getStoredFluids(storageTanksByPos) local count_by_name_total = {} - local surface = game.get_surface(1) + local surface = game.surfaces["nauvis"] for xys,ent in pairs(storageTanksByPos) do if ent then @@ -510,7 +511,7 @@ end -- debugging tools function debugLog(msg, force) if (DEV or force) and msg then - for i,player in ipairs(game.players) do + for i,player in pairs(game.players) do if player and player.valid then if type(msg) == "string" then player.print(msg) diff --git a/promfacto/info.json b/promfacto/info.json index 46eb2f8..4ec33b7 100644 --- a/promfacto/info.json +++ b/promfacto/info.json @@ -1,9 +1,10 @@ { "name": "promfacto", - "version": "0.1.4", + "version": "0.2.0", "title": "Promfacto", "author": "ncabatoff", "description": "Publish metrics to a Prometheus.io server", "homepage": "https://github.com/ncabatoff/promfacto", - "dependencies": ["base >= 0.12.25"] + "dependencies": ["base >= 0.14.22"], + "factorio_version": "0.14" }