troelsbjerre / Bottleneck

Factorio mod that tell you which assemblers are starved of ingredients
Other
26 stars 21 forks source link

Mod should disable itself when FactorioMaps is generating a map #60

Open OvermindDL1 opened 4 years ago

OvermindDL1 commented 4 years ago

When the FactorioMaps mod is generating a map bottleneck needs to disable itself as it doesn't make sense for the indicators to be on the satellite view of the FactorioMaps generation, especially as it's only near a single player and not the others or on anything else that isn't near a player. Currently Bottleneck, if left on, is generating a lot of dots as noise on the FactorioMaps map such as at: https://overminddl1.com/Factorio/maps/Space1/#1/nauvis/19/70/-44/0/4

FactorioMaps has an API for detecting if it's generating a map or not specifically to be able to disable things like these when it is generating.

L0laapk3 commented 4 years ago

Hey there! I'm the dev of factoriomaps. I thought I'd join in and help a little bit with the API to make the process a little easier.

I originally was going to make a pull request, but decided to let you take care of your mods elements the way you want to.

I've got a template compat/factoriomaps.lua file for you:

Compat = Compat or { }

local function disable_bottleneck_on_factoriomaps()
    print("Starting factoriomaps-bottleneck integration script")

    -- destroy all elements not suitable for map view here. Note that screenshots are taken at the end of this tick.
end

function Compat.handle_factoriomaps()
    if remote.interfaces.factoriomaps then
        script.on_event(remote.call("factoriomaps", "get_start_capture_event_id"), disable_bottleneck_on_factoriomaps)
    end
end

You would then call Compat.handle_factoriomaps() in your on_init and on_load events.