From d4870fd6594175a4907ee09d999c28d21a4ae997 Mon Sep 17 00:00:00 2001 From: Someone Date: Thu, 9 May 2019 23:58:38 +0200 Subject: [PATCH] improved handling of cliffs. --- changelog.txt | 6 ++++++ control.lua | 9 ++++++--- info.json | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 79f4a5e..9edd287 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,10 @@ --------------------------------------------------------------------------------------------------- +Version: 0.17.2 +Date: 2019-05-09 + + Changed: + - improved handling of cliffs. +--------------------------------------------------------------------------------------------------- Version: 0.17.1 Date: 2019-03-17 diff --git a/control.lua b/control.lua index b882482..a842db7 100755 --- a/control.lua +++ b/control.lua @@ -7,9 +7,12 @@ script.on_event(defines.events.on_chunk_generated, function (event) -- dont spam uranium as it will halt normal miners :/ ores = {"stone", "iron-ore", "copper-ore", "coal"} - for x=event.area.left_top.x, event.area.right_bottom.x do - for y=event.area.left_top.y, event.area.right_bottom.y do - if event.surface.get_tile(x, y).collides_with("ground-tile") and #event.surface.find_entities_filtered{position={x+0.5, y+0.5}, type = "resource"} == 0 then + 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}}) diff --git a/info.json b/info.json index 807f327..d698572 100755 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "some-resourcespam", - "version": "0.17.1", + "version": "0.17.2", "title": "Some resource spam", "author": "someone1337", "homepage": "https://git.somenet.org/pub/jan/factorio_some-resourcespam.git", -- 2.43.0