mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
fixed bug
This commit is contained in:
parent
95f4758670
commit
0c70213fb9
@ -5,21 +5,19 @@ map_gen_rows_per_tick = 8 -- Inclusive integer between 1 and 32. Used for map_ge
|
|||||||
--require "map_gen.shared.generate_not_threaded"
|
--require "map_gen.shared.generate_not_threaded"
|
||||||
require "map_gen.shared.generate"
|
require "map_gen.shared.generate"
|
||||||
|
|
||||||
local function no_resources(x, y, world_x, world_y, tile, entity)
|
local function no_resources(x, y, world_x, world_y, tile, entity, surface)
|
||||||
local surface = MAP_GEN_SURFACE
|
for _, e in ipairs(surface.find_entities_filtered({type = "resource", area = {{world_x, world_y}, {world_x + 1, world_y + 1}}})) do
|
||||||
for _, e in ipairs(surface.find_entities_filtered({ type = "resource", area = {{world_x, world_y }, {world_x + 1, world_y + 1 } } })) do
|
|
||||||
e.destroy()
|
e.destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
return tile, entity
|
return tile, entity
|
||||||
end
|
end
|
||||||
|
|
||||||
local function less_resources(x, y, world_x, world_y, tile, entity)
|
local function less_resources(x, y, world_x, world_y, tile, entity, surface)
|
||||||
local surface = MAP_GEN_SURFACE
|
for _, e in ipairs(surface.find_entities_filtered({type = "resource", area = {{world_x, world_y}, {world_x + 1, world_y + 1}}})) do
|
||||||
for _, e in ipairs(surface.find_entities_filtered({ type = "resource", area = {{world_x, world_y }, {world_x + 1, world_y + 1 } } })) do
|
|
||||||
if e.name == "crude-oil" then
|
if e.name == "crude-oil" then
|
||||||
-- e.amount = .995 * e.amount
|
-- e.amount = .995 * e.amount
|
||||||
else
|
else
|
||||||
e.amount = 0.33 * e.amount
|
e.amount = 0.33 * e.amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -27,9 +25,8 @@ local function less_resources(x, y, world_x, world_y, tile, entity)
|
|||||||
return tile, entity
|
return tile, entity
|
||||||
end
|
end
|
||||||
|
|
||||||
local function no_enemies(x, y, world_x, world_y, tile, entity)
|
local function no_enemies(x, y, world_x, world_y, tile, entity, surface)
|
||||||
local surface = MAP_GEN_SURFACE
|
for _, e in ipairs(surface.find_entities_filtered({force = "enemy", position = {world_x, world_y}})) do
|
||||||
for _, e in ipairs(surface.find_entities_filtered({ force = "enemy", position = { world_x, world_y } } )) do
|
|
||||||
e.destroy()
|
e.destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -45,57 +42,56 @@ arms = change_tile(arms, true, "water")
|
|||||||
|
|
||||||
local arms2 = rotate(arms, degrees(45))
|
local arms2 = rotate(arms, degrees(45))
|
||||||
|
|
||||||
local shape = compound_or{ translate(arms2,480,0), translate(arms2, -480, 0), mediumn_dot, arms }
|
local shape = compound_or{translate(arms2, 480, 0), translate(arms2, -480, 0), mediumn_dot, arms}
|
||||||
shape = apply_effect(shape, no_resources)
|
shape = apply_effect(shape, no_resources)
|
||||||
--shape = apply_effect(shape, less_resources)
|
--shape = apply_effect(shape, less_resources)
|
||||||
shape = apply_effect(shape, no_enemies)
|
shape = apply_effect(shape, no_enemies)
|
||||||
|
|
||||||
|
|
||||||
local shape2 = compound_and{ big_dot, invert(small_dot) }
|
local shape2 = compound_and{big_dot, invert(small_dot)}
|
||||||
shape2 = choose(big_dot, shape2, compound_or{arms, rotate(arms, degrees(45))})
|
shape2 = choose(big_dot, shape2, compound_or{arms, rotate(arms, degrees(45))})
|
||||||
--shape2 = apply_effect(shape2, less_resources)
|
--shape2 = apply_effect(shape2, less_resources)
|
||||||
|
|
||||||
local start = apply_effect(mediumn_dot, no_resources)
|
local start = apply_effect(mediumn_dot, no_resources)
|
||||||
|
|
||||||
local iron = circle_builder(16)
|
local iron = circle_builder(16)
|
||||||
iron = translate(iron, 0,-96)
|
iron = translate(iron, 0, -96)
|
||||||
--iron = rotate(iron, degrees(0))
|
--iron = rotate(iron, degrees(0))
|
||||||
iron = resource_module_builder(iron, "iron-ore", function(x,y) return 700 end)
|
iron = resource_module_builder(iron, "iron-ore", function(x, y) return 700 end)
|
||||||
|
|
||||||
local copper = circle_builder(12)
|
local copper = circle_builder(12)
|
||||||
copper = translate(copper, 0,-96)
|
copper = translate(copper, 0, -96)
|
||||||
copper = rotate(copper, degrees(72))
|
copper = rotate(copper, degrees(72))
|
||||||
copper = resource_module_builder(copper, "copper-ore", function(x,y) return 600 end)
|
copper = resource_module_builder(copper, "copper-ore", function(x, y) return 600 end)
|
||||||
|
|
||||||
local stone = circle_builder(8)
|
local stone = circle_builder(8)
|
||||||
stone = translate(stone, 0,-96)
|
stone = translate(stone, 0, -96)
|
||||||
stone = rotate(stone, degrees(144))
|
stone = rotate(stone, degrees(144))
|
||||||
stone = resource_module_builder(stone, "stone", function(x,y) return 1500 end)
|
stone = resource_module_builder(stone, "stone", function(x, y) return 1500 end)
|
||||||
|
|
||||||
local coal = circle_builder(10)
|
local coal = circle_builder(10)
|
||||||
coal = translate(coal, 0,-96)
|
coal = translate(coal, 0, -96)
|
||||||
coal = rotate(coal, degrees(216))
|
coal = rotate(coal, degrees(216))
|
||||||
coal = resource_module_builder(coal, "coal", function(x,y) return 850 end)
|
coal = resource_module_builder(coal, "coal", function(x, y) return 850 end)
|
||||||
|
|
||||||
local oil = circle_builder(5)
|
local oil = circle_builder(5)
|
||||||
oil = throttle_xy(oil, 1, 3, 1, 3)
|
oil = throttle_xy(oil, 1, 3, 1, 3)
|
||||||
oil = translate(oil, 0,-96)
|
oil = translate(oil, 0, -96)
|
||||||
oil = rotate(oil, degrees(288))
|
oil = rotate(oil, degrees(288))
|
||||||
oil = resource_module_builder(oil, "crude-oil", function(x,y) return 60000 end)
|
oil = resource_module_builder(oil, "crude-oil", function(x, y) return 60000 end)
|
||||||
|
|
||||||
start = builder_with_resource(mediumn_dot, compound_or{iron, copper, stone, coal, oil})
|
start = builder_with_resource(mediumn_dot, compound_or{iron, copper, stone, coal, oil})
|
||||||
|
|
||||||
start = apply_effect(start, no_resources)
|
start = apply_effect(start, no_resources)
|
||||||
|
|
||||||
local pattern =
|
local pattern =
|
||||||
{
|
{
|
||||||
{shape, shape2},
|
{shape, shape2},
|
||||||
{shape2, shape}
|
{shape2, shape}
|
||||||
}
|
}
|
||||||
|
|
||||||
local map = grid_pattern_builder(pattern, 2, 2, 480,480)
|
local map = grid_pattern_builder(pattern, 2, 2, 480, 480)
|
||||||
map = choose(mediumn_dot, start, map)
|
map = choose(mediumn_dot, start, map)
|
||||||
|
|
||||||
map = change_map_gen_collision_tile(map,"water-tile", "grass-1")
|
map = change_map_gen_collision_tile(map, "water-tile", "grass-1")
|
||||||
|
|
||||||
return map
|
return map
|
||||||
|
@ -8,8 +8,7 @@ local function value(base, mult)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function no_resources(x, y, world_x, world_y, tile, entity)
|
local function no_resources(x, y, world_x, world_y, tile, entity, surface)
|
||||||
local surface = MAP_GEN_SURFACE
|
|
||||||
for _, e in ipairs(surface.find_entities_filtered({ type = "resource", area = {{world_x, world_y }, {world_x + 1, world_y + 1 } } })) do
|
for _, e in ipairs(surface.find_entities_filtered({ type = "resource", area = {{world_x, world_y }, {world_x + 1, world_y + 1 } } })) do
|
||||||
e.destroy()
|
e.destroy()
|
||||||
end
|
end
|
||||||
|
@ -7,26 +7,25 @@ require "map_gen.shared.generate"
|
|||||||
|
|
||||||
local inner_circle = invert(circle_builder(48))
|
local inner_circle = invert(circle_builder(48))
|
||||||
local outer_circle = circle_builder(64)
|
local outer_circle = circle_builder(64)
|
||||||
local square = invert(rectangle_builder(1000,1000))
|
local square = invert(rectangle_builder(1000, 1000))
|
||||||
square = rotate(square, degrees(45))
|
square = rotate(square, degrees(45))
|
||||||
square = translate(square, math.sqrt(2) * 500,0)
|
square = translate(square, math.sqrt(2) * 500, 0)
|
||||||
|
|
||||||
local circle = compound_and({ inner_circle, outer_circle, square })
|
local circle = compound_and({inner_circle, outer_circle, square})
|
||||||
|
|
||||||
local line1 = rectangle_builder(77,16)
|
local line1 = rectangle_builder(77, 16)
|
||||||
line1 = rotate(line1, degrees(45))
|
line1 = rotate(line1, degrees(45))
|
||||||
line1 = translate(line1,66.5,12.6875)
|
line1 = translate(line1, 66.5, 12.6875)
|
||||||
|
|
||||||
local line2 = rectangle_builder(45, 16)
|
local line2 = rectangle_builder(45, 16)
|
||||||
local line2 = rotate(line2, degrees(-45))
|
local line2 = rotate(line2, degrees(-45))
|
||||||
line2 = translate(line2, 55.5,-23.6875)
|
line2 = translate(line2, 55.5, -23.6875)
|
||||||
|
|
||||||
--line2 =change_tile(line2, true, "water")
|
--line2 =change_tile(line2, true, "water")
|
||||||
|
local half = compound_or({line2, line1, circle})
|
||||||
local half = compound_or({ line2,line1,circle})
|
|
||||||
|
|
||||||
half = translate(half, -79.1875, 0)
|
half = translate(half, -79.1875, 0)
|
||||||
local map = compound_or({ half, flip_xy(half) })
|
local map = compound_or({half, flip_xy(half)})
|
||||||
|
|
||||||
map = scale(map, 11, 11)
|
map = scale(map, 11, 11)
|
||||||
|
|
||||||
@ -53,61 +52,59 @@ end
|
|||||||
|
|
||||||
local init = false
|
local init = false
|
||||||
local safe_distance = 480
|
local safe_distance = 480
|
||||||
local function effect(x, y, world_x, world_y, tile, entity)
|
local function effect(x, y, world_x, world_y, tile, entity, surface)
|
||||||
local surface = MAP_GEN_SURFACE
|
|
||||||
|
|
||||||
if not init then
|
if not init then
|
||||||
init = true
|
init = true
|
||||||
game.forces["player"].chart(surface, { {-32, -32}, {31, 31} })
|
game.forces["player"].chart(surface, {{-32, -32}, {31, 31}})
|
||||||
end
|
end
|
||||||
|
|
||||||
if world_x == 0 and world_y == 0 then
|
if world_x == 0 and world_y == 0 then
|
||||||
for _, e in ipairs(surface.find_entities({ {-5, -5}, {5, 5} })) do
|
for _, e in ipairs(surface.find_entities({{-5, -5}, {5, 5}})) do
|
||||||
e.destroy()
|
e.destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
local e = surface.create_entity({ name = "rocket-silo", position = {0, 0}, force = "player" })
|
local e = surface.create_entity({name = "rocket-silo", position = {0, 0}, force = "player"})
|
||||||
e.destructible = false
|
e.destructible = false
|
||||||
e.minable = false
|
e.minable = false
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|
||||||
if max_axis_distance(world_x, world_y, -2144, 0) < safe_distance then
|
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
|
for _, e in ipairs(surface.find_entities_filtered({ force = "enemy", position = { world_x, world_y } } )) do
|
||||||
e.destroy()
|
e.destroy()
|
||||||
end
|
end
|
||||||
elseif max_axis_distance(world_x, world_y, 2144, 0) < safe_distance then
|
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
|
for _, e in ipairs(surface.find_entities_filtered({ force = "enemy", position = { world_x, world_y } } )) do
|
||||||
e.destroy()
|
e.destroy()
|
||||||
end
|
end
|
||||||
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.
|
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 dist1 = distance(world_x, world_y, -2144, 0)
|
||||||
local dist2 = distance(world_x, world_y, 2144, 0)
|
local dist2 = distance(world_x, world_y, 2144, 0)
|
||||||
local amount = math.min(dist1, dist2)
|
local amount = math.min(dist1, dist2)
|
||||||
|
|
||||||
local name = e.name
|
local name = e.name
|
||||||
if name == "iron-ore" then
|
if name == "iron-ore" then
|
||||||
amount = 800 + 0.4 * amount
|
amount = 800 + 0.4 * amount
|
||||||
elseif name == "copper-ore" then
|
elseif name == "copper-ore" then
|
||||||
amount = 700 + 0.35 * amount
|
amount = 700 + 0.35 * amount
|
||||||
elseif name == "coal" then
|
elseif name == "coal" then
|
||||||
amount = 600 + 0.3 * amount
|
amount = 600 + 0.3 * amount
|
||||||
elseif name == "stone" then
|
elseif name == "stone" then
|
||||||
amount = 400 + 0.2 * amount
|
amount = 400 + 0.2 * amount
|
||||||
elseif name == "uranium-ore" then
|
elseif name == "uranium-ore" then
|
||||||
amount = 300 + 0.15 * amount
|
amount = 300 + 0.15 * amount
|
||||||
elseif name == "crude-oil" then
|
elseif name == "crude-oil" then
|
||||||
amount = 50000 + 50 * amount
|
amount = 50000 + 50 * amount
|
||||||
end
|
|
||||||
|
|
||||||
e.amount = amount
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--]]
|
e.amount = amount
|
||||||
|
end
|
||||||
|
|
||||||
|
--]]
|
||||||
return tile, entity
|
return tile, entity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user