Compare commits

...

8 Commits
v1.0.2 ... main

  1. 3
      README.md
  2. 21
      changelog.txt
  3. 8
      info.json
  4. 20
      script/commands.lua
  5. 20
      script/fetcher.lua

3
README.md

@ -320,7 +320,7 @@ Pull requests for any of these are very welcome:
- [x] Console commands for admins only
- [x] Cached settings for performance
- [ ] Check for multiplayer desyncs
- [x] Check for multiplayer desyncs
- [ ] More game API functions exposed
- [ ] Robust API calling methods
- [ ] Multiplayer settings
@ -334,6 +334,7 @@ Pull requests for any of these are very welcome:
- [X] More output file formats beyond JSON
- [ ] Support for simulations
- [ ] Translations of the mod and supporting documentation
- [ ] Sanitise game speed vs tick output
If you'd like to add anything else then its worth reaching out first.

21
changelog.txt

@ -0,0 +1,21 @@
---------------------------------------------------------------------------------------------------
Version: 1.0.3
Date: 15.05.2022
Fixes:
- Fixes bug where get_entity_count always returned an API error
- get_flow_count now supports LuaItemProductionFlowStatistics and other undocumented parents
Features:
- Improved help prompts for missing command arguments
- Added `rm` as an alias of `del`
- Added `show` as an alias of `list`
---------------------------------------------------------------------------------------------------
Version: 1.0.2
Date: 11.02.2021
Features:
- Added statsd support
- Improved examples in documentation
---------------------------------------------------------------------------------------------------
Version: 1.0.1
Date: 09.02.2021
Features:
- First release

8
info.json

@ -1,11 +1,11 @@
{
"name": "statorio",
"version": "1.0.2",
"version": "1.0.3",
"title": "Statorio",
"author": "aoi44",
"author": "chksm",
"homepage": "https://factorio.яю.com/statorio/",
"contact": "a@яю.com",
"factorio_version": "1.1",
"dependencies": ["base >= 1.0"],
"description": "Experimental! Export realtime JSON statistics to disk. Use the stat command to add, list and remove game API metrics. See homepage for usage"
}
"description": "Export realtime JSON statistics to disk from the built-in Factorio game API. Use the /stat command to add, list and remove game API metrics. See homepage for usage"
}

20
script/commands.lua

@ -21,7 +21,7 @@ commands.add_command("stat", "Used to control metrics in Statorio mod\n[add|list
argsArr = split(param.parameter, " ")
if argsArr[1] == "list" then
if argsArr[1] == "list" or argsArr[1] == "show" then
if table_size(global.statorio.metrics) > 0 then
for index, val in pairs(global.statorio.metrics) do
@ -33,16 +33,31 @@ commands.add_command("stat", "Used to control metrics in Statorio mod\n[add|list
elseif argsArr[1] == "add" then
if not argsArr[2] then
player.print("Adding requires a metric")
return
end
table.insert(global.statorio.metrics, argsArr[2])
player.print("Added metric ["..table_size(global.statorio.metrics).."]")
elseif argsArr[1] == "del" then
elseif argsArr[1] == "del" or argsArr[1] == "rm" then
if not argsArr[2] then
player.print("Deleting requires the index number of a metric from the list command")
return
end
table.remove(global.statorio.metrics, argsArr[2])
player.print("Removed metric ["..argsArr[2].."]")
elseif argsArr[1] == "test" then
if not argsArr[2] then
player.print("Testing requires a metric")
return
end
if not Fetcher.traverseApiForValues(argsArr[2], function(name, val)
player.print(name..": "..safeString(val))
end)
@ -53,5 +68,6 @@ commands.add_command("stat", "Used to control metrics in Statorio mod\n[add|list
else
player.print("Try list, add, del or test. For example:\n/stat list")
player.print("For more information see https://mods.factorio.com/mod/statorio")
end
end)

20
script/fetcher.lua

@ -17,7 +17,9 @@ this.overlays.get_entity_count = function(parent, entity)
return parent.get_entity_count(entity)
end)
return data
if res then return data end
return nil
end
@ -45,10 +47,17 @@ this.callOverlayFunction = function(functionName, callback, name, parent, args)
--data = parent.get_entity_count(args[1])
data = this.overlays.get_entity_count(parent, args[1])
this.doCallback(callback, name, data)
if data == nil then
return false
else
this.doCallback(callback, name, data)
return true
end
-- flow statistics
elseif functionName == "get_flow_count" and parent.object_name == "LuaFlowStatistics" then
-- worst hack to validate that parent inherits from FlowStatistics
elseif functionName == "get_flow_count" and string.sub(parent.object_name, -14) == "FlowStatistics" then
if args[2] == 'input' then isInput = true else isInput = false end
@ -75,6 +84,11 @@ this.callOverlayFunction = function(functionName, callback, name, parent, args)
end
elseif functionName == "get_flow_count" then
game.players[1].print("Cannot get_flow_count for unexpected instance of:")
game.players[1].print(parent.object_name)
end
end

Loading…
Cancel
Save