mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
Red planet is now threaded
This commit is contained in:
parent
c0a6303493
commit
98820ddeb2
@ -4,6 +4,7 @@
|
||||
-- Use water only in starting area as map setting!!!
|
||||
|
||||
require "locale.gen_shared.perlin_noise"
|
||||
local Thread = require "locale.utils.Thread"
|
||||
|
||||
wreck_item_pool = {}
|
||||
wreck_item_pool = {{name="iron-gear-wheel", count=32},{name="iron-plate", count=64},{name="rocket-control-unit", count=1} ,{name="coal", count=4},{name="rocket-launcher", count=1},{name="rocket", count=32},{name="copper-cable", count=128},{name="land-mine", count=64},{name="railgun", count=1},{name="railgun-dart", count=128},{name="fast-inserter", count=8},{name="stack-filter-inserter", count=2},{name="belt-immunity-equipment", count=1},{name="fusion-reactor-equipment", count=1},{name="electric-engine-unit", count=8},{name="exoskeleton-equipment", count=1},{name="rocket-fuel", count=10},{name="used-up-uranium-fuel-cell", count=3},{name="uranium-fuel-cell", count=2}}
|
||||
@ -37,9 +38,7 @@ local resource_amount_distance_multiplicator = (((c + 1) / 75) / 75) + 1
|
||||
function run_combined_module(event)
|
||||
if not global.perlin_noise_seed then global.perlin_noise_seed = math.random(1000,1000000) end
|
||||
local surface = game.surfaces[1]
|
||||
local tiles = {}
|
||||
local decoratives = {}
|
||||
local tree_to_place = {"dry-tree","dry-hairy-tree","tree-06","tree-06","tree-01","tree-02","tree-03"}
|
||||
|
||||
local entities = surface.find_entities(event.area)
|
||||
for _, entity in pairs(entities) do
|
||||
if entity.type == "simple-entity" or entity.type == "resource" or entity.type == "tree" then
|
||||
@ -47,10 +46,45 @@ function run_combined_module(event)
|
||||
end
|
||||
end
|
||||
|
||||
Thread.queue_action("run_planet_init", {} )
|
||||
--run_planet_init()
|
||||
for x = 0, 31, 1 do
|
||||
Thread.queue_action("run_planet", {area = event.area, surface = event.surface, x = x})
|
||||
--run_planet( {area = event.area, surface = event.surface, x = x})
|
||||
end
|
||||
--run_planet_place_tiles( {surface = event.surface} )
|
||||
Thread.queue_action("run_planet_place_tiles", {surface = event.surface})
|
||||
|
||||
end
|
||||
|
||||
|
||||
global.planet_tiles_hold = {}
|
||||
global.planet_decoratives_hold = {}
|
||||
|
||||
function run_planet_init(params)
|
||||
global.planet_tiles_hold = {}
|
||||
global.planet_decoratives_hold = {}
|
||||
end
|
||||
|
||||
function run_planet_place_tiles(params)
|
||||
local surface = params.surface
|
||||
surface.set_tiles(global.planet_tiles_hold)
|
||||
for _,deco in pairs(global.planet_decoratives_hold) do
|
||||
surface.create_decoratives{check_collision=false, decoratives={deco}}
|
||||
end
|
||||
end
|
||||
|
||||
function run_planet( params )
|
||||
local tree_to_place = {"dry-tree","dry-hairy-tree","tree-06","tree-06","tree-01","tree-02","tree-03"}
|
||||
local area = params.area
|
||||
local surface = params.surface
|
||||
|
||||
local x = params.x
|
||||
local pos_x = area.left_top.x + x
|
||||
|
||||
for y = 0, 31, 1 do
|
||||
local pos_x = event.area.left_top.x + x
|
||||
local pos_y = event.area.left_top.y + y
|
||||
local pos_y = area.left_top.y + y
|
||||
local seed = surface.map_gen_settings.seed
|
||||
local tile = surface.get_tile(pos_x,pos_y)
|
||||
local tile_to_insert = "concrete"
|
||||
|
||||
@ -77,7 +111,6 @@ function run_combined_module(event)
|
||||
end
|
||||
|
||||
local seed_increment_number = 10000
|
||||
local seed = global.perlin_noise_seed
|
||||
|
||||
local noise_terrain_1 = perlin:noise(((pos_x+seed)/400),((pos_y+seed)/400),0)
|
||||
noise_terrain_1 = noise_terrain_1 * 100
|
||||
@ -170,19 +203,19 @@ function run_combined_module(event)
|
||||
if noise_water_1 + noise_water_2 > 0 and noise_water_1 + noise_water_2 < 15 and noise_terrain_1 < -60 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 + noise_terrain_5 then
|
||||
tile_to_insert = "water"
|
||||
local a = pos_x + 1
|
||||
table.insert(tiles, {name = tile_to_insert, position = {a,pos_y}})
|
||||
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {a,pos_y}})
|
||||
local a = pos_y + 1
|
||||
table.insert(tiles, {name = tile_to_insert, position = {pos_x,a}})
|
||||
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {pos_x,a}})
|
||||
local a = pos_x - 1
|
||||
table.insert(tiles, {name = tile_to_insert, position = {a,pos_y}})
|
||||
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {a,pos_y}})
|
||||
local a = pos_y - 1
|
||||
table.insert(tiles, {name = tile_to_insert, position = {pos_x,a}})
|
||||
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {pos_x,a}})
|
||||
if noise_water_1 + noise_water_2 < 2 or noise_water_1 + noise_water_2 > 13 then
|
||||
if math.random(1,15) == 1 then
|
||||
table.insert(decoratives, {name="green-carpet-grass", position={pos_x,pos_y}, amount=1})
|
||||
table.insert(global.planet_decoratives_hold, {name="green-carpet-grass", position={pos_x,pos_y}, amount=1})
|
||||
end
|
||||
if math.random(1,15) == 1 then
|
||||
table.insert(decoratives, {name="brown-cane-cluster", position={pos_x,pos_y}, amount=1})
|
||||
table.insert(global.planet_decoratives_hold, {name="brown-cane-cluster", position={pos_x,pos_y}, amount=1})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -190,19 +223,19 @@ function run_combined_module(event)
|
||||
if tile_to_insert ~= "water" then
|
||||
if noise_water_1 + noise_water_2 > 16 and noise_water_1 + noise_water_2 < 25 and noise_terrain_1 < -55 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 + noise_terrain_5 then
|
||||
if math.random(1,35) == 1 then
|
||||
table.insert(decoratives, {name="brown-carpet-grass", position={pos_x,pos_y}, amount=1})
|
||||
table.insert(global.planet_decoratives_hold, {name="brown-carpet-grass", position={pos_x,pos_y}, amount=1})
|
||||
end
|
||||
end
|
||||
if noise_water_1 + noise_water_2 > -10 and noise_water_1 + noise_water_2 < -1 and noise_terrain_1 < -55 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 + noise_terrain_5 then
|
||||
if math.random(1,35) == 1 then
|
||||
table.insert(decoratives, {name="brown-carpet-grass", position={pos_x,pos_y}, amount=1})
|
||||
table.insert(global.planet_decoratives_hold, {name="brown-carpet-grass", position={pos_x,pos_y}, amount=1})
|
||||
end
|
||||
end
|
||||
if noise_decoratives_1 > 0.5 and noise_decoratives_1 <= 0.8 then
|
||||
if math.random(1,12) == 1 then table.insert(decoratives, {name="red-desert-bush", position={pos_x,pos_y}, amount=1}) end
|
||||
if math.random(1,12) == 1 then table.insert(global.planet_decoratives_hold, {name="red-desert-bush", position={pos_x,pos_y}, amount=1}) end
|
||||
end
|
||||
if noise_decoratives_1 > 0.4 and noise_decoratives_1 <= 0.5 then
|
||||
if math.random(1,4) == 1 then table.insert(decoratives, {name="red-desert-bush", position={pos_x,pos_y}, amount=1}) end
|
||||
if math.random(1,4) == 1 then table.insert(global.planet_decoratives_hold, {name="red-desert-bush", position={pos_x,pos_y}, amount=1}) end
|
||||
end
|
||||
end
|
||||
|
||||
@ -233,18 +266,18 @@ function run_combined_module(event)
|
||||
|
||||
if tile_to_insert ~= "water" then
|
||||
if noise_terrain_1 < 8 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 and noise_terrain_1 > -5 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
|
||||
if math.random(1,45) == 1 then
|
||||
table.insert(decoratives, {name="red-desert-rock-medium", position={pos_x,pos_y}, amount=1})
|
||||
if math.random(1,180) == 1 then
|
||||
table.insert(global.planet_decoratives_hold, {name="red-desert-rock-medium", position={pos_x,pos_y}, amount=1})
|
||||
end
|
||||
if math.random(1,20) == 1 then
|
||||
table.insert(decoratives, {name="red-desert-rock-tiny", position={pos_x,pos_y}, amount=1})
|
||||
if math.random(1,80) == 1 then
|
||||
table.insert(global.planet_decoratives_hold, {name="red-desert-rock-tiny", position={pos_x,pos_y}, amount=1})
|
||||
end
|
||||
else
|
||||
if math.random(1,375) == 1 then
|
||||
table.insert(decoratives, {name="red-desert-rock-medium", position={pos_x,pos_y}, amount=1})
|
||||
if math.random(1,1500) == 1 then
|
||||
table.insert(global.planet_decoratives_hold, {name="red-desert-rock-medium", position={pos_x,pos_y}, amount=1})
|
||||
end
|
||||
if math.random(1,45) == 1 then
|
||||
table.insert(decoratives, {name="red-desert-rock-tiny", position={pos_x,pos_y}, amount=1})
|
||||
if math.random(1,180) == 1 then
|
||||
table.insert(global.planet_decoratives_hold, {name="red-desert-rock-tiny", position={pos_x,pos_y}, amount=1})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -306,39 +339,35 @@ function run_combined_module(event)
|
||||
|
||||
if noise_red_desert_rocks_1 + noise_red_desert_rocks_2 + noise_red_desert_rocks_3 + noise_terrain_4 >= 10 and noise_red_desert_rocks_1 + noise_red_desert_rocks_2 + noise_red_desert_rocks_3 < 20 and noise_terrain_1 > 7 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
|
||||
if math.random(1,5) == 1 then
|
||||
table.insert(decoratives, {name="red-desert-rock-medium", position={pos_x,pos_y}, amount=1})
|
||||
table.insert(global.planet_decoratives_hold, {name="red-desert-rock-medium", position={pos_x,pos_y}, amount=1})
|
||||
end
|
||||
else
|
||||
if tile_to_insert ~= "water" and tile_to_insert ~= "sand" then
|
||||
if math.random(1,15) == 1 then
|
||||
table.insert(decoratives, {name="red-desert-rock-small", position={pos_x,pos_y}, amount=1})
|
||||
table.insert(global.planet_decoratives_hold, {name="red-desert-rock-small", position={pos_x,pos_y}, amount=1})
|
||||
else
|
||||
if math.random(1,8) == 1 then
|
||||
table.insert(decoratives, {name="red-desert-rock-tiny", position={pos_x,pos_y}, amount=1})
|
||||
table.insert(global.planet_decoratives_hold, {name="red-desert-rock-tiny", position={pos_x,pos_y}, amount=1})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if tile_to_insert ~= "water" then
|
||||
if noise_decoratives_2 > 0.6 then
|
||||
if math.random(1,9) == 1 then table.insert(decoratives, {name="red-asterisk", position={pos_x,pos_y}, amount=1}) end
|
||||
if math.random(1,9) == 1 then table.insert(global.planet_decoratives_hold, {name="red-asterisk", position={pos_x,pos_y}, amount=1}) end
|
||||
else
|
||||
if noise_decoratives_2 > 0.4 then
|
||||
if math.random(1,17) == 1 then table.insert(decoratives, {name="red-asterisk", position={pos_x,pos_y}, amount=1}) end
|
||||
if math.random(1,17) == 1 then table.insert(global.planet_decoratives_hold, {name="red-asterisk", position={pos_x,pos_y}, amount=1}) end
|
||||
end
|
||||
end
|
||||
if noise_decoratives_3 < -0.6 then
|
||||
if math.random(1,2) == 1 then table.insert(decoratives, {name="brown-fluff-dry", position={pos_x,pos_y}, amount=1}) end
|
||||
if math.random(1,2) == 1 then table.insert(global.planet_decoratives_hold, {name="brown-fluff-dry", position={pos_x,pos_y}, amount=1}) end
|
||||
else
|
||||
if noise_decoratives_3 < -0.4 then
|
||||
if math.random(1,5) == 1 then table.insert(decoratives, {name="brown-fluff-dry", position={pos_x,pos_y}, amount=1}) end
|
||||
if math.random(1,5) == 1 then table.insert(global.planet_decoratives_hold, {name="brown-fluff-dry", position={pos_x,pos_y}, amount=1}) end
|
||||
end
|
||||
end
|
||||
end
|
||||
table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y}})
|
||||
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {pos_x,pos_y}})
|
||||
end
|
||||
end
|
||||
|
||||
surface.set_tiles(tiles,false)
|
||||
surface.create_decoratives{check_collision=false, decoratives=decoratives}
|
||||
end
|
||||
|
@ -121,4 +121,6 @@ return
|
||||
["yago2003"] = "",
|
||||
["saneman"] = "",
|
||||
["mesohorknee"] = "",
|
||||
["brl_chacal"] = "",
|
||||
["spechok"] = "",
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user