Skip to content

Instantly share code, notes, and snippets.

@marfillaster
Last active May 8, 2020 11:22
Show Gist options
  • Save marfillaster/2400d3cb903310bb6101ffea8da14c4f to your computer and use it in GitHub Desktop.
Save marfillaster/2400d3cb903310bb6101ffea8da14c4f to your computer and use it in GitHub Desktop.
Freeplay deepwater bordered starter base map modifier
-- resources targeted for https://kirkmcdonald.github.io/calc.html#zip=bVHbbsMgDP2bPEGVtFk3VcrHOI6TWiWAjFnVvx+5adLWR59jzsUMoNDVtvm017oSUOpSNbPvztWYxQOWWYmc3aeKlebUQdYwg3LwNiGTR7IR8HEbb01tXJg4KeM/6mzwTjMjuL/UuTVRwpDxrWRrsrJjfb1hJOCD1GLwKsHZ7FkL0dYHMWZyG+DC0w7k06qjUryy0OL9ZcgRqpTEe8uC1qerYVnClCaPFfgwKuBTDKK2J6c7uG5NBGKfd1rNlrelDlJK7KcjU3O6GBi+oeQfLLJg5k3i8A++JPglmqIyuteiIKEPpYrAfESLDtYT9yA70oMqyWtXjBy31YvBECOJRejdAaXsStN9dfvfIqjrNS6n6w8=
/c
local r=640
local rr=-r
local t={}
local g=4
game.player.surface.request_to_generate_chunks({0,0}, math.ceil(r/32)+1)
game.player.surface.force_generate_chunk_requests()
for y=rr-g,r+g do
if y % g == 0
then
t={}
end
for x=rr-g,r+g do
if (x < rr) or (x > r) or (y < rr) or (y > r) then
table.insert(t, {name = "deepwater", position = {x, y}})
elseif game.player.surface.get_tile(x, y).name == "deepwater" or game.player.surface.get_tile(x, y).name == "water" then
table.insert(t, {name = "dirt-1", position = {x, y}})
end
end
game.player.surface.set_tiles(t)
end
t={}
for y=rr-g,r+g do
if y % 128 >= 0 and y % 128 <= 16 and (y <= -64 or y >= 64)
then
for x=-1,1 do
table.insert(t, {name = "deepwater", position = {x, y}})
end
end
end
game.player.surface.set_tiles(t)
for x=rr-g,r+g do
if x % 128 >= 0 and x % 128 <= 16 and (x <= -64 or x >= 64)
then
for y=-1,1 do
table.insert(t, {name = "deepwater", position = {x, y}})
end
end
end
game.player.surface.set_tiles(t)
for _, e in ipairs(game.player.surface.find_entities_filtered{area={{rr,rr},{r,r}}, type="resource"})
do e.destroy()
end
function resource_strip(resources, x_offset, y_offset, depth, gap)
for _, res in ipairs(resources) do
local width = res.lanes*(res.name == "crude-oil" and 4 or 10)
for _, e in ipairs(game.player.surface.find_entities_filtered{area={{x_offset,y_offset},{x_offset+depth,y_offset+width}}})
do e.destroy()
end
game.player.surface.destroy_decoratives{area={{x_offset,y_offset},{x_offset+depth,y_offset+width}}}
for y=y_offset,y_offset+width do
for x=x_offset,x_offset+depth do
if not(res.name == "crude-oil") or ( (x % 4 == 1) and (y % 4 == 1)) then
game.player.surface.create_entity({name=res.name, amount=100000, position={x,y}})
end
end
end
y_offset = y_offset + width + gap
end
return y_offset
end
local x_offset = 30
local y_offset = 30
local gap = 6
local depth = 65
resources = {
{name="iron-ore", lanes=1},
{name="coal", lanes=1},
{name="copper-ore", lanes=1},
{name="iron-ore", lanes=1},
{name="stone", lanes=2},
{name="crude-oil", lanes=2},
{name="coal", lanes=2},
{name="coal", lanes=3},
{name="iron-ore", lanes=14},
{name="copper-ore", lanes=13},
{name="uranium-ore", lanes=2}
}
local rresources = {}
local rsize = table_size(resources)
for k, val in ipairs(resources) do
rresources[rsize + 1 - k] = val
end
ry_offset=resource_strip(resources, x_offset, y_offset, depth, gap)
resource_strip(rresources, x_offset, -ry_offset, depth, gap)
resource_strip(rresources, -(x_offset+depth), -ry_offset, depth, gap)
resource_strip(resources, -(x_offset+depth), y_offset, depth, gap)
-- screenshot stiching https://www.microsoft.com/en-us/research/product/computational-photography-applications/image-composite-editor/
/c
game.player.surface.always_day=true
local r=7
local rr=-r
local z=0
for y=rr,r-1 do
for x=rr,r-1 do
z = z + 1
game.take_screenshot{position={(x*100) + 50, (y*100) + 50}, path="screenshot-"..(string.format("%03d", z)).."_"..(x+7).."_"..(y+7)..".jpg" , zoom=0.5 }
end
end
game.player.surface.always_day=false
@marfillaster
Copy link
Author

Screenshot

screenshot-001_0_0_stitch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment