SE K2 BZ Adjustments

by JanJB99

This Mod adjust the way Krastorio2 Space Exploration and Very BZ (including ALL BZ Mods) are working together. The Major difference is, that only Iron, Copper, Stone, Coal and Aluminum spawn on Nauvis while every other ore needs to be obtained differently until it can be imported from foreign Planets.

Content
10 months ago
1.1
273
Mining Fluids Manufacturing

g [FIXED] Stuttering due to resource removal on chunk generation event

11 months ago
(updated 11 months ago)

I experience quite a lot of stuttering, every second or so, when I tried this mod. So I took a look at the code and made the following changes, which seem to fix it. Feel free to use these changes.

As far as I can tell, the issue stems from the fact that the current code removes the resources from the entire chunk, instead of only removing resources from the chunk that was generated, so I added the surface and area parameters to the remove_ores_on_Nauvis function and removed the loop over all surfaces inside this function.

-- control.lua
local function remove_ores_on_Nauvis(surface, resources, area)
    if surface.name ~= "nauvis" then
        return
    end

    for _, resource_name in pairs(resources) do
        for _, entity in pairs(surface.find_entities_filtered {
            type = "resource",
            name = resource_name,
            area = area
        }) do
            entity.destroy()
        end
    end
end

script.on_init(function()
    for _, surface in pairs(game.surfaces) do
        remove_ores_on_Nauvis(surface, resources_to_remove, nil)
    end
end)

script.on_event(defines.events.on_chunk_generated, function(event)
    remove_ores_on_Nauvis(event.surface, resources_to_remove, event.area)
end)
11 months ago
(updated 11 months ago)

Would it not be easier to create a map setting that dissables the ores from spawning on Nauvis then to remove the ores by a script?

10 months ago

I can confirm the script changes above improve the performance significantly. This particularly helps when using the Blueprint's Sandbox mod. Prior to this script switching to the blueprint sandbox caused the game to slow to an absolute crawl.

10 months ago

Thank you very much and sorry for taking so long!

I added the updates to the mod script and additionally edited the SpaceEx default Map Preset.

Its live with 0.3.0

New response