1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00
RedMew/map_gen/presets/mobius_strip.lua

121 lines
3.9 KiB
Lua
Raw Normal View History

2018-01-21 15:31:20 +00:00
map_gen_decoratives = false -- Generate our own decoratives
map_gen_rows_per_tick = 8 -- Inclusive integer between 1 and 32. Used for map_gen_threaded, higher numbers will generate map quicker but cause more lag.
-- Recommend to use generate, but generate_not_threaded may be useful for testing / debugging.
--require "map_gen.shared.generate_not_threaded"
require "map_gen.shared.generate"
2017-08-25 06:27:50 +01:00
local inner_circle = invert(circle_builder(48))
local outer_circle = circle_builder(64)
2017-08-27 00:29:17 +01:00
local square = invert(rectangle_builder(1000,1000))
2017-08-25 06:27:50 +01:00
square = rotate(square, degrees(45))
2017-08-27 00:29:17 +01:00
square = translate(square, math.sqrt(2) * 500,0)
2017-08-25 06:27:50 +01:00
local circle = compound_and({ inner_circle, outer_circle, square })
2017-08-27 00:29:17 +01:00
local line1 = rectangle_builder(77,16)
2017-08-25 06:27:50 +01:00
line1 = rotate(line1, degrees(45))
2017-08-27 00:29:17 +01:00
line1 = translate(line1,66.5,12.6875)
2017-08-25 06:27:50 +01:00
2017-08-27 18:15:07 +01:00
local line2 = rectangle_builder(45, 16)
2017-08-25 06:27:50 +01:00
local line2 = rotate(line2, degrees(-45))
2017-08-27 00:29:17 +01:00
line2 = translate(line2, 55.5,-23.6875)
2017-08-25 06:27:50 +01:00
--line2 =change_tile(line2, true, "water")
local half = compound_or({ line2,line1,circle})
2017-08-27 00:29:17 +01:00
half = translate(half, -79.1875, 0)
2017-08-25 06:27:50 +01:00
local map = compound_or({ half, flip_xy(half) })
2017-08-27 18:15:07 +01:00
map = scale(map, 11, 11)
2017-08-25 06:27:50 +01:00
2017-08-25 15:35:53 +01:00
local function research_finished(event)
local tech = event.research.name
if tech == "rocket-silo" then
game.forces["player"].recipes["rocket-silo"].enabled = false
end
end
Event.register(defines.events.on_research_finished, research_finished)
local function max_axis_distance(world_x, world_y, target_x, target_y)
local x = math.abs(world_x - target_x)
local y = math.abs(world_y - target_y)
return math.max(x, y)
end
local function distance(world_x, world_y, target_x, target_y)
return math.abs(world_x - target_x) + math.abs(world_y - target_y)
end
local init = false
local safe_distance = 480
local function effect(x, y, world_x, world_y, tile, entity)
local surface = MAP_GEN_SURFACE
if not init then
init = true
game.forces["player"].chart(surface, { {-32, -32}, {31, 31} })
end
if world_x == 0 and world_y == 0 then
for _, e in ipairs(surface.find_entities({ {-5, -5}, {5, 5} })) do
e.destroy()
end
local e = surface.create_entity({ name = "rocket-silo", position = {0, 0}, force = "player" })
e.destructible = false
e.minable = false
end
2017-08-27 18:15:07 +01:00
--[[
2017-08-25 15:35:53 +01:00
if max_axis_distance(world_x, world_y, -2144, 0) < safe_distance then
for _, e in ipairs(surface.find_entities_filtered({ force = "enemy", position = { world_x, world_y } } )) do
e.destroy()
end
elseif max_axis_distance(world_x, world_y, 2144, 0) < safe_distance then
for _, e in ipairs(surface.find_entities_filtered({ force = "enemy", position = { world_x, world_y } } )) do
e.destroy()
end
end
for _, e in ipairs(surface.find_entities_filtered({ type = "resource", area = {{world_x, world_y }, {world_x + 1, world_y + 1 } } })) do -- I want to use position but for some reason it doesn't seem to work for ores.
local dist1 = distance(world_x, world_y, -2144, 0)
local dist2 = distance(world_x, world_y, 2144, 0)
local amount = math.min(dist1, dist2)
local name = e.name
if name == "iron-ore" then
amount = 800 + 0.4 * amount
elseif name == "copper-ore" then
amount = 700 + 0.35 * amount
elseif name == "coal" then
amount = 600 + 0.3 * amount
elseif name == "stone" then
amount = 400 + 0.2 * amount
elseif name == "uranium-ore" then
amount = 300 + 0.15 * amount
elseif name == "crude-oil" then
2017-08-26 13:23:03 +01:00
amount = 50000 + 50 * amount
2017-08-25 15:35:53 +01:00
end
e.amount = amount
end
2017-08-27 18:15:07 +01:00
--]]
2017-08-25 15:35:53 +01:00
return tile, entity
end
map = apply_effect(map, effect)
2017-08-28 07:09:15 +01:00
require "spawn_control"
add_spawn("left", -88, -88)
add_spawn("right", 88, 88)
2017-08-25 15:35:53 +01:00
2017-08-25 06:27:50 +01:00
return map