Code: Select all
script.on_event(defines.events.on_chunk_generated, function(event)
if(event.surface == game.surfaces.Caves) then
local caves = game.surfaces.Caves
local area = event.area
local entitiesSpawned = caves.find_entities(area)
for _,v in pairs(entitiesSpawned) do
local rngNum = math.random(0.1, 1) -- not used yet
if(v.type == "resource" or v.type == "decorative") then
v.destroy()
return
end
if(v.type == "tree") then
caves.create_entity{name="stone-rock", position = v.position}
v.destroy()
end
game.player.print(v.type) -- properly prints out the types, although doesn't print tree, resource or deco, but it doesn't destroy them or spawn the rocks
end
end
end)
EDIT: me destroying things manually using the command prompt properly destroys things