Last active
November 22, 2024 22:02
-
-
Save morsk/a21393dabe4ebf9d6001b529d0b66b42 to your computer and use it in GitHub Desktop.
[Factorio] Dump spore-absorption tile data from Gleba.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/c --[[ Dump spore-absorption tile data from gleba. This will take a few seconds to run! ]] | |
local function tiles_on_surface(surface) | |
local found_tiles = {} | |
for c in surface.get_chunks() do | |
local box = c.area | |
for x = box.left_top.x, box.right_bottom.x do | |
for y = box.left_top.y, box.right_bottom.y do | |
local tile = surface.get_tile(x, y) | |
if tile.valid and not found_tiles[tile.name] then | |
found_tiles[tile.name] = true | |
end | |
end | |
end | |
end | |
return found_tiles | |
end | |
--[[ Find spore-absorption count and sort by it. ]] | |
local ordered = {} | |
for name, _ in pairs(tiles_on_surface(game.surfaces["gleba"])) do | |
local spores = prototypes.tile[name].absorptions_per_second["spores"] | |
table.insert(ordered, {name = name, spores = spores}) | |
end | |
table.sort(ordered, function(a, b) | |
return (a.spores < b.spores) or (a.spores == b.spores and a.name < b.name) | |
end) | |
--[[ Now print to both console and file. ]] | |
local filename = "spore_absorptions_per_second.txt" | |
helpers.write_file(filename, "") --[[ Write nothing, without append, to reset file. ]] | |
for _,t in pairs(ordered) do | |
local proto = prototypes.tile[t.name] | |
local out = { "", proto.localised_name, " (", t.name, "): ", string.format("%f", proto.absorptions_per_second["spores"]) } | |
game.player.print(out) | |
helpers.write_file(filename, out, true, game.player.index) | |
helpers.write_file(filename, "\n", true, game.player.index) | |
end | |
game.player.print("Data written to script-output/"..filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment