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

Merge branch 'develop' into develop_decos

This commit is contained in:
Triston 2017-11-13 15:52:11 -05:00 committed by GitHub
commit 6e98aac3fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 1177 additions and 10 deletions

View File

@ -112,7 +112,7 @@ function decompress(pic)
x = x + 1
end
end
end
end
return {width = width, height = height, data = uncompressed}
end
@ -221,8 +221,8 @@ end
function throttle_x(builder, x_in, x_size)
return function(x, y, world_x, world_y)
if x % x_size < x_in then
return builder(x, y, world_x, world_y)
if x % x_size < x_in then
return builder(x, y, world_x, world_y)
else
return false
end
@ -231,8 +231,8 @@ end
function throttle_y(builder, y_in, y_size)
return function(x, y, world_x, world_y)
if y % y_size < y_in then
return builder(x, y, world_x, world_y)
if y % y_size < y_in then
return builder(x, y, world_x, world_y)
else
return false
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
require "locale.gen_combined.grilledham_map_gen.builders"
local pic = require "locale.gen_combined.grilledham_map_gen.data.UK"
local pic = decompress(pic)
local map = picture_builder(pic)
-- this changes the size of the map
map = scale(map, 2, 2)
-- this moves the map, effectively changing the spawn point.
map = translate(map, 0, 10)
-- this sets the tile outside the bounds of the map to deepwater, remove this and it will be void.
map = change_tile(map, false, "deepwater")
function run_combined_module(event)
local area = event.area
local surface = event.surface
MAP_GEN_SURFACE = surface
local tiles = {}
local entities = {}
local top_x = area.left_top.x
local top_y = area.left_top.y
-- place tiles over the edge of chunks to reduce tile artefacts on chunk boundaries.
for y = top_y - 1, top_y + 32 do
for x = top_x - 1, top_x + 32 do
-- local coords need to be 'centered' to allow for correct rotation and scaling.
local tile, entity = map(x + 0.5, y + 0.5, x, y)
if type(tile) == "boolean" and not tile then
table.insert( tiles, {name = "out-of-map", position = {x, y}} )
elseif type(tile) == "string" then
table.insert( tiles, {name = tile, position = {x, y}} )
end
if entity then
table.insert(entities, entity)
end
end
end
-- set tiles.
surface.set_tiles(tiles, true)
-- set entities
for _, v in ipairs(entities) do
if surface.can_place_entity(v) then
surface.create_entity(v)
end
end
end

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,52 @@
require "locale.gen_shared.perlin_noise"
-- list of {x, y, ore_type, size, richness, rng_seed}
local ctrs = {
{1, -15, "iron-ore", 0.3, 400, 113},
{15, 15, "copper-ore", 0.3, 400, 80},
{4, 21, "coal", 0.25, 640, 31},
{10, 0, "stone", 0.5, 100, 17},
{-17, 7, "uranium-ore", 0.6, 100, 203}
}
local function harmonic(x, y)
local max_idx = 0
local max = -1
local richness = 0
for i, e in ipairs(ctrs) do
local noise = perlin:noise(x/32, y/32, ctrs[i][6])
local h_coeff = 1/(1 + .05*math.sqrt((x/32 - ctrs[i][1])*(x/32 - ctrs[i][1]) + (y/32 - ctrs[i][2])*(y/32 - ctrs[i][2])))
if noise > max and noise > h_coeff*ctrs[i][4] + (1-h_coeff) then
max = noise
max_idx = i
richness = (40*(1-h_coeff) + 0.5*h_coeff) * ctrs[i][5]
end
end
return max, max_idx, richness
end
--generate ores for entire chunk
function run_ores_module(event)
local area = event.area
local surface = event.surface
if math.abs(area.left_top.x / 32) < 3 and math.abs(area.left_top.y / 32) < 3 then
return
end
local entities = surface.find_entities_filtered{type="resource", area=area}
for _, entity in ipairs(entities) do
entity.destroy()
end
local eties = {}
for i = 0,31 do
for j = 0,31 do
local pos = {area.left_top.x + i, area.left_top.y + j}
local max, max_idx, richness = harmonic(pos[1], pos[2])
if -1 ~= max then
local ety = {name = ctrs[max_idx][3], position = pos, force="neutral", amount=richness}
if surface.can_place_entity(ety) then
surface.create_entity(ety)
end
end
end
end
end

View File

@ -12,8 +12,9 @@ in this file and your run_*type*_module(event) function will be called.
--require "locale.gen_combined.borg_planet_v2"
--require "locale.gen_combined.dimentions"
--require "locale.gen_combined.dagobah_swamp"
--require "locale.gen_combined.UK"
--grilledham's maps
--grilledham's map gen
--MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.mobius_strip"
--MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.antfarm"
--MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.creation_of_adam"
@ -25,6 +26,7 @@ in this file and your run_*type*_module(event) function will be called.
--MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.goat"
--MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.biome_test"
MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.GoT"
--require "locale.grilledham_map_gen.presets.UK"
--shapes--
--require "locale.gen_shape.left"
@ -51,7 +53,8 @@ MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.GoT"
--ores--
--require "locale.gen_ores.neko_crazy_ores"
--require "locale.gen_ores.fluffy_rainbows"
require "locale.gen_ores.rso.rso_control"
--require "locale.gen_ores.rso.rso_control"
--require "locale.gen_ores.harmonic_gen"
--everything else. You may use more than one of these, but beware they might not be compatible
miscs = {}
@ -85,6 +88,9 @@ local on_chunk_generated = function(event)
end
else
run_combined_module(event)
for _,v in pairs(miscs) do
v.on_chunk_generated(event)
end
if run_ores_module ~= nil then
run_ores_module(event)
end