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
/sc --[[ logi group finder ]] | |
local c = 0 | |
local function check_for_group(e, section_container, group_name) | |
for _, section in pairs(section_container.sections) do | |
if section.group == group_name then | |
game.player.print({"", e.localised_name, ": ", e.gps_tag}) | |
c = c + 1 | |
end | |
end | |
end |
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 |
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
/sc --[[ vehicle finder ]] | |
local found_vehicles = game.player.surface.find_entities_filtered{type = {"car", "spider-vehicle"}, force=game.player.force} | |
for _, vehicle in pairs(found_vehicles) do | |
game.player.print({"", vehicle.localised_name, ": ", vehicle.gps_tag}) | |
end | |
if table_size(found_vehicles) == 0 then | |
game.player.print({"gui.nothing-found"}) | |
end |
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
/sc --[[ undo landfill 3.0, for Patch 2.0 ]] | |
--[[ | |
EXPERIMENTAL!!! I took my 1.1 script and tried to make it work in 2.0 in a hurry!! | |
Truly undoes landfill. Regenerates the original chunks in a separate surface to see which water/ | |
shore tiles used to be under the landfill, copies from those tiles, and cleans up afterwards. | |
Ends in an unterminated quote, intended to contain map pings. | |
Will select a box region around all pings. | |
Any number of pings 2+ will work, but it's most intuitive to ping 2 opposing corners, or 4 sides. |
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
/sc --[[ blueprint change grid position ]] | |
local function printf(...) game.player.print(string.format(...)) end | |
local function handle_blueprint(bp, new_position) --[[ not recursive; does one blueprint ]] | |
if not (bp.blueprint_snap_to_grid and bp.blueprint_absolute_snapping) then | |
return 0 --[[ changed nothing ]] | |
end | |
local old_x = bp.blueprint_position_relative_to_grid.x | |
local old_y = bp.blueprint_position_relative_to_grid.y | |
if new_position.x ~= old_x or new_position.y ~= old_y then | |
printf("Converting %d,%d -> %d,%d \"%s\"", old_x, old_y, new_position.x, new_position.y, bp.label) |
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 --[[ Destroy all logistic bots on the force + surface. ]] | |
--[[ utility to count bots destroyed ]] | |
local counts = {} | |
local function count_bot(name, n) | |
counts[name] = (counts[name] or 0) + n | |
end | |
--[[ Find bot item names in this game. Start by searching entity prototypes. ]] | |
local bot_names = {} | |
for _, bot_prototype in pairs(game.get_filtered_entity_prototypes{{filter="type", type="logistic-robot"}}) do | |
for _, item_stack in pairs(bot_prototype.items_to_place_this) do |
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 --[[ remove rocks ]] | |
local function count_in(t, s) | |
t[s] = (t[s] or 0) + 1 | |
end | |
local counts = {} | |
for _,e in pairs(game.player.surface.find_entities_filtered{type = {"simple-entity"}}) do | |
--[[ starts rock- , has -rock- in middle, or ends -rock ]] | |
if e.name:match("^rock%-") or e.name:match("%-rock%-") or e.name:match("%-rock$") then | |
count_in(counts, e.name) | |
e.destroy() |
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 | |
--[[ CHUNK REMOVER --]] | |
local SAFE_PLAYER_DISTANCE = 64 --[[ must be >= 32 --]] | |
local function bounding_box_from_gps_tags(s) | |
local x1 = math.huge | |
local y1,x2,y2 = x1,-x1,-x1 | |
for x,y in s:gmatch("%[gps=([+-]?%d+),([+-]?%d+)%]") do | |
x1 = math.min(x1, x+0) | |
y1 = math.min(y1, y+0) | |
x2 = math.max(x2, x+0) |
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 | |
--[[ file appears in Factorio's script-output folder ]] | |
local OUTPUT_FILE = "recipe_dump.txt" | |
local function print_table_to_file(t,filename) | |
local text_format_of_table = serpent.block(t) | |
game.write_file(filename, text_format_of_table) | |
end |
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 | |
--[[ a "station" is an existing station, of which you have many. | |
a "waypoint" is a single station to add before its stacker. | |
the table maps station names to the new waypoint name you're adding. | |
t[k] = v, where key is the station name, and v is the waypoint name. ]] | |
local station_waypoints = { | |
["[img=item/iron-ore] [U] @ [img=item/lab]"] = "[img=item/iron-ore] [W] @ [img=item/lab]", | |
["[img=item/copper-ore] [U] @ [img=item/lab]"] = "[img=item/copper-ore] [W] @ [img=item/lab]", | |
["[img=item/stone] [U] @ [img=item/lab]"] = "[img=item/stone] [W] @ [img=item/lab]", | |
["[img=item/coal] [U] @ [img=item/lab]"] = "[img=item/coal] [W] @ [img=item/lab]", |