Download scripts/flow_debug/export_with_lanes.py from beyarkay/factorio-blueprints: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/datasets/beyarkay/factorio-blueprints/resolve/main/scripts/flow_debug/export_with_lanes.py
- Command line
-
hf download hf://datasets/beyarkay/factorio-blueprints/scripts/flow_debug/export_with_lanes.py
-
curl -L -o export_with_lanes.py https://huggingface.co/datasets/beyarkay/factorio-blueprints/resolve/main/scripts/flow_debug/export_with_lanes.py
1.15 kB
| """Re-export a save's regions with each belt line's contents in the blueprint frame.""" | |
| import json, sys | |
| from pathlib import Path | |
| import corpus.extract_saves as es | |
| LANES = """local lanes = {} | |
| for _, e in pairs(surface.find_entities_filtered{area = area, type = {"transport-belt", "underground-belt"}, force = "player"}) do | |
| for i = 1, 2 do | |
| local items = {} | |
| for _, c in pairs(e.get_transport_line(i).get_contents()) do items[#items + 1] = c.name end | |
| if #items > 0 then | |
| lanes[#lanes + 1] = {math.floor(e.position.x + ox), math.floor(e.position.y + oy), i, table.concat(items, ",")} | |
| end | |
| end | |
| end | |
| helpers.write_file(""" | |
| assert es.LUA.count('helpers.write_file("OUT"') == 1 | |
| es.LUA = es.LUA.replace('helpers.write_file("OUT"', LANES + '"OUT"').replace("string = bp.export_stack(), unbuildable = runs}", "string = bp.export_stack(), unbuildable = runs, lanes = lanes}") | |
| regions = es.extract(Path(sys.argv[1]), {"base"}, es.FACTORIO) | |
| json.dump(regions, open(sys.argv[2], "w")) | |
| print(len(regions), "regions;", sum(len(r.get("lanes") or []) for r in regions), "labelled lines") | |