1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/map_gen/presets/fractal_balls.lua

156 lines
4.7 KiB
Lua
Raw Normal View History

2018-07-21 13:29:46 +02:00
local b = require 'map_gen.shared.builders'
2018-11-06 14:08:33 +02:00
local degrees = require "utils.math".degrees
2018-05-08 22:23:07 +02:00
2018-02-13 02:49:57 +02:00
local function value(base, mult)
2018-07-21 13:29:46 +02:00
return function(x, y)
2018-02-13 02:49:57 +02:00
return mult * (math.abs(x) + math.abs(y)) + base
end
end
2018-07-21 13:29:46 +02:00
local function no_resources(x, y, world, tile)
for _, e in ipairs(
world.surface.find_entities_filtered(
{type = 'resource', area = {{world.x, world.y}, {world.x + 1, world.y + 1}}}
)
) do
2018-02-13 02:49:57 +02:00
e.destroy()
end
return tile
2018-02-13 02:49:57 +02:00
end
2018-02-07 02:26:51 +02:00
-- bot_islands_flag true if you want to add islands of ores only reachable by robots
2018-11-12 00:28:49 +02:00
local bot_islands_flag = true
2018-05-08 22:23:07 +02:00
local arm1 = b.translate(b.rectangle(2, 3), 0, -5)
local arm2 = b.translate(b.rectangle(6, 2), 0, 22)
2018-02-13 02:49:57 +02:00
2018-05-08 22:23:07 +02:00
local inner = b.circle(22)
local outer = b.circle(24)
2018-07-21 13:29:46 +02:00
local ring = b.all {outer, b.invert(inner)}
2018-02-07 02:26:51 +02:00
2018-07-21 13:29:46 +02:00
map = b.any {map, ring}
2018-02-07 02:26:51 +02:00
2018-07-21 13:29:46 +02:00
local arms = b.any {arm1, arm2}
2018-05-08 22:23:07 +02:00
arms = b.translate(arms, 0, -16)
2018-07-21 13:29:46 +02:00
arms =
b.any {
arms,
2018-05-08 22:23:07 +02:00
b.rotate(arms, degrees(120)),
b.rotate(arms, degrees(-120))
2018-02-07 02:26:51 +02:00
}
2018-07-21 13:29:46 +02:00
local frame = b.any {arms, ring}
2018-02-07 02:26:51 +02:00
2018-05-08 22:23:07 +02:00
local ball = b.circle(8)
2018-02-07 02:26:51 +02:00
2018-07-21 13:29:46 +02:00
local iron = b.resource(b.circle(6), 'iron-ore', value(1000, 1))
local copper = b.resource(b.circle(6), 'copper-ore', value(800, 0.8))
local stone = b.resource(b.circle(4), 'stone', value(500, .5))
local coal = b.resource(b.circle(6), 'coal', value(600, 0.6))
local uranium = b.resource(b.circle(4), 'uranium-ore', value(400, 1))
local oil = b.resource(b.throttle_world_xy(b.circle(6), 1, 4, 1, 4), 'crude-oil', value(100000, 50))
--[[ local iron_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, iron), 'water-tile', 'grass-1')
local copper_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, copper), 'water-tile', 'grass-1')
local stone_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, stone), 'water-tile', 'grass-1')
local coal_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, coal), 'water-tile', 'grass-1')
local uranium_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, uranium), 'water-tile', 'grass-1')
local oil_ball = b.change_map_gen_collision_tile(b.apply_entity(ball, oil), 'water-tile', 'grass-1') ]]
local iron_ball = b.apply_entity(ball, iron)
local copper_ball = b.apply_entity(ball, copper)
local stone_ball = b.apply_entity(ball, stone)
local coal_ball = b.apply_entity(ball, coal)
local uranium_ball = b.apply_entity(ball, uranium)
local oil_ball = b.apply_entity(ball, oil)
local balls1 =
b.any {
2018-05-08 22:23:07 +02:00
b.translate(iron_ball, 0, -12),
b.rotate(b.translate(copper_ball, 0, -12), degrees(120)),
2018-07-21 13:29:46 +02:00
b.rotate(b.translate(coal_ball, 0, -12), degrees(-120)),
2018-02-13 02:49:57 +02:00
frame
}
2018-05-08 22:23:07 +02:00
--shape = b.rotate(shape, degrees(rot))
balls1 = b.rotate(balls1, degrees(180))
balls1 = b.choose(outer, balls1, b.empty_shape)
balls1 = b.translate(balls1, 0, -36)
2018-02-07 02:26:51 +02:00
2018-07-21 13:29:46 +02:00
local balls2 =
b.any {
2018-05-08 22:23:07 +02:00
b.translate(iron_ball, 0, -12),
b.rotate(b.translate(copper_ball, 0, -12), degrees(120)),
2018-07-21 13:29:46 +02:00
b.rotate(b.translate(stone_ball, 0, -12), degrees(-120)),
2018-02-13 02:49:57 +02:00
frame
}
2018-05-08 22:23:07 +02:00
balls2 = b.rotate(balls2, degrees(180))
2018-07-21 13:29:46 +02:00
balls2 = b.choose(outer, balls2, b.empty_shape)
2018-05-08 22:23:07 +02:00
balls2 = b.translate(balls2, 0, -36)
balls2 = b.rotate(balls2, degrees(120))
2018-02-07 02:26:51 +02:00
2018-07-21 13:29:46 +02:00
local balls3 =
b.any {
2018-05-08 22:23:07 +02:00
b.translate(iron_ball, 0, -12),
b.rotate(b.translate(uranium_ball, 0, -12), degrees(120)),
2018-07-21 13:29:46 +02:00
b.rotate(b.translate(oil_ball, 0, -12), degrees(-120)),
2018-02-13 02:49:57 +02:00
frame
}
2018-05-08 22:23:07 +02:00
balls3 = b.rotate(balls3, degrees(180))
2018-07-21 13:29:46 +02:00
balls3 = b.choose(outer, balls3, b.empty_shape)
2018-05-08 22:23:07 +02:00
balls3 = b.translate(balls3, 0, -36)
balls3 = b.rotate(balls3, degrees(-120))
2018-02-07 02:26:51 +02:00
2018-07-21 13:29:46 +02:00
local balls4 =
b.any {
2018-02-13 02:49:57 +02:00
balls1,
balls2,
balls3,
2018-05-08 22:23:07 +02:00
b.scale(frame, 3, 3)
2018-02-07 02:26:51 +02:00
}
2018-05-08 22:23:07 +02:00
balls4 = b.rotate(balls4, degrees(180))
if bot_islands_flag == true then
2018-11-21 15:42:39 +02:00
balls4 = b.any{
balls4,
b.translate(iron_ball, 0, 0),
b.rotate(b.translate(coal_ball, 0, -40),degrees(120)),
b.rotate(b.translate(iron_ball, 0, -40),degrees(-120)),
b.translate(copper_ball, 0, -40),
}
end
2018-05-08 22:23:07 +02:00
balls4 = b.apply_effect(balls4, no_resources)
balls4 = b.choose(b.scale(outer, 3, 3), balls4, b.empty_shape)
2018-02-07 02:26:51 +02:00
2018-02-13 02:49:57 +02:00
local function make_ball(shape, sf)
2018-05-08 22:23:07 +02:00
local s1 = b.translate(shape, 0, -12 * sf)
2018-07-21 13:29:46 +02:00
local shape =
b.any {
s1,
2018-05-08 22:23:07 +02:00
b.rotate(s1, degrees(120)),
b.rotate(s1, degrees(-120)),
b.scale(frame, sf, sf)
2018-02-07 02:26:51 +02:00
}
2018-05-08 22:23:07 +02:00
shape = b.rotate(shape, degrees(180))
2018-02-07 02:26:51 +02:00
2018-05-08 22:23:07 +02:00
local bound = b.scale(outer, sf, sf)
2018-02-07 02:26:51 +02:00
2018-07-21 13:29:46 +02:00
return b.choose(bound, shape, b.empty_shape)
2018-02-07 02:26:51 +02:00
end
2018-07-21 13:29:46 +02:00
local ratio = 24 / 8
2018-02-13 02:49:57 +02:00
local map = balls4
local total_sf = 1 * ratio * ratio
2018-07-21 13:29:46 +02:00
for i = 1, 6 do
map = make_ball(map, total_sf)
2018-02-07 02:26:51 +02:00
total_sf = ratio * total_sf
end
2018-07-21 13:29:46 +02:00
map = b.translate(map, 0, -19669)
map = b.scale(map, 2, 2)
map = b.change_map_gen_collision_tile(map, 'water-tile', 'grass-1')
map = b.change_tile(map, false, 'water')
map = b.fish(map, 0.0025)
2018-02-07 02:26:51 +02:00
return map