1 -- Iterate over every tile in the new chunk and spam with random resources, if empty and possible.
2 script.on_event(defines.events.on_chunk_generated, function (event)
3 -- this mod is intended as an early game challenge. Therefore do nothing on non-nauvis.
4 if not event.surface.planet then return end
5 if not event.surface.planet.name ~= "nauvis" then return end
7 -- prevent one big continuous patch
8 if (event.area.left_top.x/32)%10 == 5 or (event.area.left_top.y/32)%10 == 5 then
12 -- dont spam uranium as it will halt normal miners :/
13 ores = {"stone", "iron-ore", "copper-ore", "coal"}
14 for x=event.area.left_top.x+0, event.area.right_bottom.x-1 do
15 for y=event.area.left_top.y+0, event.area.right_bottom.y-1 do
16 if event.surface.get_tile(x, y).collides_with("ground_tile")
17 and #event.surface.find_entities_filtered{area={{x,y}, {x+1, y+1}}, type="resource"} == 0
18 and #event.surface.find_entities_filtered{area={{x-1, y-1}, {x+1, y+1}}, name="cliff"} == 0
20 cnt = math.random(20, 50)
21 ore = math.random(1, 4)
22 event.surface.create_entity({name=ores[ore], amount=cnt, position={x, y}})