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

mixed_ores config

This commit is contained in:
grilledham 2019-05-12 11:54:46 +01:00 committed by James Gillham
parent c98be136df
commit 23bac83a85

View File

@ -9,6 +9,8 @@ local binary_search = table.binary_search
local bnot = bit32.bnot
local perlin_noise = Perlin.noise
local mixed_ores = false
local tile_scale = 1 / 64
local spawn_zone = b.circle(102)
@ -34,6 +36,7 @@ local ores = {
[4] = 'grass-4'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 150},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -62,6 +65,7 @@ local ores = {
[4] = 'red-desert-3'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 150},
@ -93,6 +97,7 @@ local ores = {
[7] = 'dirt-7'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -120,6 +125,7 @@ local ores = {
[3] = 'sand-3'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -148,6 +154,7 @@ local ores = {
[4] = 'grass-4'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -176,6 +183,7 @@ local ores = {
[4] = 'red-desert-3'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -207,6 +215,7 @@ local ores = {
[7] = 'dirt-7'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -234,6 +243,7 @@ local ores = {
[3] = 'sand-3'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -262,6 +272,7 @@ local ores = {
[4] = 'grass-4'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -290,6 +301,7 @@ local ores = {
[4] = 'red-desert-3'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -321,6 +333,7 @@ local ores = {
[7] = 'dirt-7'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -348,6 +361,7 @@ local ores = {
[3] = 'sand-3'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -376,6 +390,7 @@ local ores = {
[4] = 'grass-4'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -404,6 +419,7 @@ local ores = {
[4] = 'red-desert-3'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -435,6 +451,7 @@ local ores = {
[7] = 'dirt-7'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -462,6 +479,7 @@ local ores = {
[3] = 'sand-3'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -490,6 +508,7 @@ local ores = {
[4] = 'grass-4'
},
['start'] = value(125, 0),
['non_mixed_value'] = value(0, 0.5),
['ratios'] = {
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 10},
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 10},
@ -583,17 +602,63 @@ local function init(seed)
end
end
local function non_mixed_ore_builder(ore_name, amount)
local resource = b.resource(b.full_shape, ore_name, amount)
return function(x, y, world)
if spawn_zone(x, y) then
return resource(x, y, world)
end
local oil_x, oil_y = x * oil_scale, y * oil_scale
local oil_noise = perlin_noise(oil_x, oil_y, oil_seed)
if oil_noise > oil_threshold then
return oil_resource(x, y, world)
end
local uranium_x, uranium_y = x * uranium_scale, y * uranium_scale
local uranium_noise = perlin_noise(uranium_x, uranium_y, uranium_seed)
if uranium_noise > uranium_threshold then
return uranium_resource(x, y, world)
end
local thorium_x, thorium_y = x * thorium_scale, y * thorium_scale
local thorium_noise = perlin_noise(thorium_x, thorium_y, thorium_seed)
if thorium_noise > thorium_threshold then
return thorium_resource(x, y, world)
end
local entity = resource(x, y, world)
local density_x, density_y = x * density_scale, y * density_scale
local density_noise = perlin_noise(density_x, density_y, density_seed)
if density_noise > density_threshold then
entity.amount = entity.amount * density_multiplier
end
entity.enable_tree_removal = false
return entity
end
end
local shapes = {}
for ore_name, v in pairs(ores) do
local tiles = v.tiles
local land = tile_builder(tiles)
local ratios = v.ratios
local weighted = b.prepare_weighted_array(ratios)
local amount = v.start
local ore
if mixed_ores then
local ratios = v.ratios
local weighted = b.prepare_weighted_array(ratios)
local amount = v.start
local ore = ore_builder(ore_name, amount, ratios, weighted)
ore = ore_builder(ore_name, amount, ratios, weighted)
else
local amount = v.non_mixed_value
ore = non_mixed_ore_builder(ore_name, amount)
end
local shape = b.apply_entity(land, ore)
shapes[#shapes + 1] = shape