Unfortunately, I don’t know any programming language, I just look, think, change, analyze. The Lua textbook came to me not long ago, and that knowledge is not enough.
With the on_chunk_generated event, as I did not try to create a condition so that it happened only once, it did not work out.
The on_chunk_generated event generated a resource in the same place all the time, it turned into infinite, I refused it
Yesterday night sat crossing technology migration with the on_research_finished event
Added technology and now, when studying it, a resource appears in the starting area once. This is for those who play in the old save.
For a new game, the resource is generated like any other, you can select the settings in the settings as in any other.
script.on_event(defines.events.on_research_finished, function(event)
function reapply_research(force, research)
if force.technologies[research] and force.technologies[research].researched then
for ,effect in pairs(force.technologies[research].effects) do
local spawns_per_region={min=1, max=1}
local position = spawns_per_region
local area = {{ -2.8, -2.8}, {2.8, 2.8}}
local surface = game.surfaces[1].create_entity{ name = "termal", position = position, force=game.forces.player}
regen(event.area, event.surface)
end
force.print({"info.termal"})
end
end
for , force in pairs(game.forces) do
force.reset_technologies()
force.reset_recipes()
for _,research in pairs({"termal"}) do
reapply_research(force, research)
end
end
end)
the regen function "regen (event.area, event.surface)" - gives the resource type, name, quantity, etc.
In general, it turned out.