Disco Science


Makes science labs light up with the colours of the science packs they are consuming.

Tweaks
3 years ago
0.17 - 1.1
167K

FAQ

I got a warning from Disco Science while playing with another mod. What does it mean?

Disco Science plays custom animations on every science lab in a game. In order to avoid expensive search functions, it relies on notification events when entities are created and destroyed, and maintains a list of labs to animate. Factorio's API makes it pretty easy for mods to create entities without issuing a standard notification. In this case, DiscoScience's lab list can get out-of-sync.

The result is pretty harmless: some labs might not play animations while the are researching. However, since the lack of notification is generally considered an error, DiscoScience will inform you the first time it detects that its list is out-of-sync in a given session.

If you encounter one of these warnings, please file a bug and we can figure out where the error is coming from.

I'm using a mod which adds research ingredients, but labs only light up purple. Why don't the colours match?

Unfortunately there's no way for a mod to detect the colours of science ingredients (or any graphics) from other mods. DiscoScience supports the vanilla science packs out-of-the-box, but other mods need to register their colours with DiscoScience.

If you encounter unsupported (purple) ingredients, please check your game log for a line like this one:

8.689 Script @__DiscoScience__/core/researchColor.lua:61: Disco Science encountered the following ingredients with no registered color: 
more-science-pack-1
more-science-pack-2
more-science-pack-3
more-science-pack-4

Point the mod authors to this FAQ page.

My mod adds or changes research ingredient colours. How do I make it work with Disco Science?

You need to do two things:

  1. Add an optional dependency on DiscoScience 1.0.0 to your mod. This will ensure that your mod doesn't attempt to add anything before DiscoScience has initialised. Note: DiscoScience 1.0.0 depends is only compatible with Factorio 0.18 and above.

  2. Register your colours in on_init and on_configuration_changed. Note that if your colours depend on settings or the presence of other mods, you'll have to include the decision logic in the callback too.

    local updateDiscoScience = function()
        if remote.interfaces["DiscoScience"] and remote.interfaces["DiscoScience"]["setIngredientColor"] then
            remote.call("DiscoScience", "setIngredientColor", "automation-science-pack", {r = 1.0, g = 0.1, b = 0.1})
        end
    end
    script.on_configuration_changed(
        function ()
            updateDiscoScience()
        end
    )
    script.on_init(
        function ()
            updateDiscoScience()
        end
    )
    

That's it! Thanks for making your mod compatible with DiscoScience! Please let me know on the Discussion board if you encounter any problems.

My mod adds labs that use the vanilla lab graphics. How do I make them work with Disco Science?

You need to do three things:

  1. Add an optional dependency on DiscoScience 1.0.0 to your mod. This will ensure that your mod doesn't attempt to add anything before DiscoScience has initialised. Note: DiscoScience 1.0.0 depends is only compatible with Factorio 0.18 and above.

  2. Prepare your lab graphics in the data stage. This removes the built-in animation and light.

    if DiscoScience and DiscoScience.prepareLab then
        DiscoScience.prepareLab(data.raw["lab"]["sct-lab-t2"])
    end
    
  3. Register your labs in on_init and on_configuration_changed, passing their scale (usually 1).

    local updateDiscoScience = function()
        if remote.interfaces["DiscoScience"] and remote.interfaces["DiscoScience"]["setLabScale"] then
            remote.call("DiscoScience", "setLabScale", "sct-lab-t2", 1)
        end
    end
    script.on_configuration_changed(
        function ()
            updateDiscoScience()
        end
    )
    script.on_init(
        function ()
            updateDiscoScience()
        end
    )
    

That's it! Thanks for making your mod compatible with DiscoScience! Please let me know on the Discussion board if you encounter any problems.