1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-03 13:12:11 +02:00

Update surrounded_by_worms.lua

small edit allowing gamemode to set starting distance of worms via a global
This commit is contained in:
NekoBaron 2020-08-17 23:03:49 +01:00 committed by GitHub
parent 85146ba28e
commit 821ab3243b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,12 +20,16 @@ end
local function on_chunk_generated(event)
local surface = event.surface
local starting_distance = surface.map_gen_settings.starting_area * 200
if not global.worm_distance then
global.worm_distance = surface.map_gen_settings.starting_area * 200
end
--local starting_distance = surface.map_gen_settings.starting_area * 200
local left_top = event.area.left_top
local chunk_distance_to_center = math.sqrt(left_top.x ^ 2 + left_top.y ^ 2)
if starting_distance > chunk_distance_to_center then return end
if global.worm_distance > chunk_distance_to_center then return end
local highest_worm_tier = math.floor((chunk_distance_to_center - starting_distance) * 0.002) + 1
local highest_worm_tier = math.floor((chunk_distance_to_center - global.worm_distance) * 0.002) + 1
if highest_worm_tier > 4 then highest_worm_tier = 4 end
if not global.average_worm_amount_per_chunk then global.average_worm_amount_per_chunk = 1 end
@ -42,4 +46,4 @@ local function on_chunk_generated(event)
end
end
event.add(defines.events.on_chunk_generated, on_chunk_generated)
event.add(defines.events.on_chunk_generated, on_chunk_generated)