From 412c38824b49b8f9af5e3f7d47a08baf9b665894 Mon Sep 17 00:00:00 2001 From: Someone Date: Sat, 1 Jun 2019 20:07:34 +0200 Subject: [PATCH] Code reformatted. --- control.lua | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/control.lua b/control.lua index a842db7..2335b75 100755 --- a/control.lua +++ b/control.lua @@ -1,22 +1,22 @@ --- Iterate over every tile in the new chunk and spam with random resources, if empty and possible. -script.on_event(defines.events.on_chunk_generated, function (event) - -- prevent one big continuous patch - if (event.area.left_top.x/32)%10 == 5 or (event.area.left_top.y/32)%10 == 5 then - return - end - - -- dont spam uranium as it will halt normal miners :/ - ores = {"stone", "iron-ore", "copper-ore", "coal"} - for x=event.area.left_top.x+0, event.area.right_bottom.x-1 do - for y=event.area.left_top.y+0, event.area.right_bottom.y-1 do - if event.surface.get_tile(x, y).collides_with("ground-tile") - and #event.surface.find_entities_filtered{area={{x,y}, {x+1, y+1}}, type="resource"} == 0 - and #event.surface.find_entities_filtered{area={{x-1, y-1}, {x+1, y+1}}, name="cliff"} == 0 - then - cnt = math.random(20, 50) - ore = math.random(1, 4) - event.surface.create_entity({name=ores[ore], amount=cnt, position={x, y}}) - end - end - end -end) +-- Iterate over every tile in the new chunk and spam with random resources, if empty and possible. +script.on_event(defines.events.on_chunk_generated, function (event) + -- prevent one big continuous patch + if (event.area.left_top.x/32)%10 == 5 or (event.area.left_top.y/32)%10 == 5 then + return + end + + -- dont spam uranium as it will halt normal miners :/ + ores = {"stone", "iron-ore", "copper-ore", "coal"} + for x=event.area.left_top.x+0, event.area.right_bottom.x-1 do + for y=event.area.left_top.y+0, event.area.right_bottom.y-1 do + if event.surface.get_tile(x, y).collides_with("ground-tile") + and #event.surface.find_entities_filtered{area={{x,y}, {x+1, y+1}}, type="resource"} == 0 + and #event.surface.find_entities_filtered{area={{x-1, y-1}, {x+1, y+1}}, name="cliff"} == 0 + then + cnt = math.random(20, 50) + ore = math.random(1, 4) + event.surface.create_entity({name=ores[ore], amount=cnt, position={x, y}}) + end + end + end +end) -- 2.43.0