Event on_chunk_generated
Posted: Sat Jun 15, 2019 6:42 pm
Hi guys, I have a question and hope you can help me:
How is the event on_chunk_generated called?
I expected it to be called once a chunk is generated for the first time. Not, if a chunk is updated.
I wrote the following code:
I was just standing after gameload und the counter for the chunks seemed to raise endlessly. I quit the game with a count of 400+
I expected it to stop somewhere. Because no more chunks should be generated without any movement of the player to the fog of war?
Actually, it seems that the counter raised every second.
I am aming for a chunkiteration, while my calculations are restricted to work in one chunk at a time only.
How is the event on_chunk_generated called?
I expected it to be called once a chunk is generated for the first time. Not, if a chunk is updated.
I wrote the following code:
Code: Select all
script.on_event(defines.events.on_chunk_generated, function(event)
local entities = game.surfaces[1].find_entities_filtered{area = event.area, name = global.Ore}
for i=1,#entities,1 do
table.insert(global.oreList, entities[i])
end
global.numChunks = global.numChunks + 1
-- DebugInfo
if global.TDebug == true then
game.print("Number of Chunks: "..tostring(global.numChunks))
end
end) -- .on_chunk_generated
I expected it to stop somewhere. Because no more chunks should be generated without any movement of the player to the fog of war?
Actually, it seems that the counter raised every second.
I am aming for a chunkiteration, while my calculations are restricted to work in one chunk at a time only.