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

Merge pull request #84 from Valansch/dev_worms

Dev worms
This commit is contained in:
Triston 2017-10-10 06:41:45 -04:00 committed by GitHub
commit 1949a9eb86
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,36 @@
local Thread = require "locale.utils.Thread"
local worms_per_chunk = 50
local small_worm_spawn_distance = 100
local medium_worm_spawn_distance = 150
local big_worm_spawn_distance = 200
local worm_names = {"small-worm-turret","medium-worm-turret","big-worm-turret"}
local function spawn_worm(params)
local x = params.x
local y = params.y
local lvl = params.lvl
local worm_id = math.random(1, lvl)
if game.surfaces[1].can_place_entity{name = worm_names[worm_id], position = {x,y}} then
if math.sqrt(x*x+y*y) > small_worm_spawn_distance then
game.surfaces[1].create_entity{name = worm_names[worm_id], position = {x,y}}
end
end
end
function run_terrain_module(event)
game.print(game.tick)
local top_left = event.area.left_top
local distance = math.sqrt(top_left.x*top_left.x+top_left.y*top_left.y)
if distance > small_worm_spawn_distance - 32 then
local lvl = 1
if distance > medium_worm_spawn_distance then lvl = 2 end
if distance > big_worm_spawn_distance then lvl = 3 end
local worm_positions = {}
for i = 1, worms_per_chunk do
Thread.queue_action(spawn_worm, {x = top_left.x + math.random(0, 31), y = top_left.y + math.random(0, 31), lvl = lvl})
end
end
end

View File

@ -35,6 +35,7 @@ in this file and your run_*type*_module(event) function will be called.
--terrain--
--require "locale.gen_terrain.neko_bridged_rivers"
--require "locale.gen_terrain.neko_river_overlay"
--require "locale.gen_terrain.worms"
--ores--
--require "locale.gen_ores.neko_crazy_ores"