Skip to content

Commit

Permalink
Update for Factorio 0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
ncabatoff committed Feb 18, 2017
1 parent 04baf6c commit 7ed49fb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.zip
*.sw?
2 changes: 1 addition & 1 deletion YARM
Submodule YARM updated from f232f3 to 587bef
2 changes: 1 addition & 1 deletion advanced-logistics-system
23 changes: 12 additions & 11 deletions promfacto/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions promfacto/info.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 7ed49fb

Please sign in to comment.