-
Notifications
You must be signed in to change notification settings - Fork 3
/
control.lua
27 lines (24 loc) · 907 Bytes
/
control.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function fix_resources_for_surface(surface, area)
resources = surface.find_entities_filtered{
area = area,
type = 'resource',
}
for _, resource in pairs(resources) do
if resource.prototype.infinite_resource then
-- set all new resources to exactly their normal amount
resource.initial_amount = resource.prototype.normal_resource_amount
resource.amount = resource.prototype.normal_resource_amount
end
end
end
script.on_configuration_changed(function()
for _, surface in pairs(game.surfaces) do
fix_resources_for_surface(surface)
end
end)
script.on_event(defines.events.on_chunk_generated, function(event)
fix_resources_for_surface(event.surface, event.area)
end)
script.on_event(defines.events.on_surface_created, function(event)
fix_resources_for_surface(game.surfaces[event.surface_index])
end)