]> git.somenet.org - factorio/some-benchmark.git/blob - control.lua
Updated and gitified another trivial mod.
[factorio/some-benchmark.git] / control.lua
1
2 script.on_event(defines.events.on_tick, function(event)
3         if event.tick % 5000 == 0 then
4         local f = game.forces["player"]
5         log("\n\ntick:"..game.tick.."\titem\tproduced\tconsumed\tlost\tdiff")
6         for k, prod in pairs(f.item_production_statistics.input_counts) do
7             local cons = 0
8             local lost = 0
9             if f.item_production_statistics.output_counts[k] then
10                 cons = f.item_production_statistics.output_counts[k]
11             end
12             if f.kill_count_statistics.output_counts[k] then
13                 lost = f.kill_count_statistics.output_counts[k]
14             end
15             log("\t"..k.."\t"..prod.."\t"..(-cons).."\t"..(-lost).."\t"..(prod-cons-lost))
16         end
17         for k, cons in pairs(f.item_production_statistics.output_counts) do
18             local prod = 0
19             local lost = 0
20             if f.kill_count_statistics.output_counts[k] then
21                 lost = f.kill_count_statistics.output_counts[k]
22             end
23             if not f.item_production_statistics.input_counts[k] then
24                 log("\t"..k.."\t"..prod.."\t"..(-cons).."\t"..(-lost).."\t"..(prod-cons-lost))
25             end
26         end
27     end
28 end)