Add signal_to_color_mapping support for "tool" items

Things that already exist in the current mod API
User avatar
PantherX
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Sat Sep 03, 2016 6:26 am
Contact:

Add signal_to_color_mapping support for "tool" items

Post by PantherX »

Previously it was possible to map lamp signal colors to science packs as the following worked:

Code: Select all

{type="item", name="automation-science-pack", color={r=0.71,g=0.05,b=0.09,a=1.00}}
However as science packs are defined as "tools" this color mapping no longer works. If you change the signal mapping to:

Code: Select all

{type="tool", name="automation-science-pack", color={r=0.71,g=0.05,b=0.09,a=1.00}}
The game throws an error saying "Invalid signal type: tool". Is it possible to have a way to get this working again so that science packs can output a colored signal to lamps?

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5221
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Add signal_to_color_mapping support for "tool" items

Post by Klonan »

PantherX wrote:
Sun Apr 26, 2020 5:39 am
Previously it was possible to map lamp signal colors to science packs as the following worked:

Code: Select all

{type="item", name="automation-science-pack", color={r=0.71,g=0.05,b=0.09,a=1.00}}
However as science packs are defined as "tools" this color mapping no longer works. If you change the signal mapping to:

Code: Select all

{type="tool", name="automation-science-pack", color={r=0.71,g=0.05,b=0.09,a=1.00}}
The game throws an error saying "Invalid signal type: tool". Is it possible to have a way to get this working again so that science packs can output a colored signal to lamps?
Does it give an error if you give this format:

Code: Select all

{type="item", name="automation-science-pack", color={r=0.71,g=0.05,b=0.09,a=1.00}}
Tool inherits from Item, it should be fine.

Previously it was possible to map lamp signal colors to science packs as the following worked:
Science packs have been tools for a very long time, when did this previously work?

User avatar
PantherX
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Sat Sep 03, 2016 6:26 am
Contact:

Re: Add signal_to_color_mapping support for "tool" items

Post by PantherX »

Thanks Klonan. It doesn't give an error when you specify type="item" however the color mapping doesn't work. If you wire up a lamp with a science pack that has a color mapped the lamp will just glow white regardless of the color specified. I'm not sure exactly when this changed. It definitely worked in 0.17, I only just noticed now that it has stopped working at some point. Other items are still mapping correctly, it just seems to be the science packs that are not and so I assumed it was something to do with them being a tool, but perhaps that's not the issue.

Here's an example from 0.18.21...

Code: Select all

{type = "item", name = "automation-science-pack", color = {r = 0.71, g = 0.05, b = 0.09, a = 1.00}},
{type = "item", name = "logistic-science-pack", color = {r = 0.18, g = 0.60, b = 0.11, a = 1.00}},
{type = "item", name = "chemical-science-pack", color = {r = 0.15, g = 0.65, b = 0.75, a = 1.00}},
{type = "item", name = "military-science-pack", color = {r = 0.23, g = 0.27, b = 0.31, a = 1.00}},
{type = "item", name = "production-science-pack", color = {r = 0.58, g = 0.11, b = 0.76, a = 1.00}},
{type = "item", name = "utility-science-pack", color = {r = 0.81, g = 0.69, b = 0.08, a = 1.00}},
{type = "item", name = "space-science-pack", color = {r = 0.96, g = 0.96, b = 0.96, a = 1.00}},
{type = "item", name = "burner-inserter", color = {r = 0.38, g = 0.31, b = 0.26, a = 0.92}},
{type = "item", name = "inserter", color = {r = 0.78, g = 0.51, b = 0.20, a = 0.92}},
{type = "item", name = "long-handed-inserter", color = {r = 0.76, g = 0.20, b = 0.13, a = 0.92}},
{type = "item", name = "fast-inserter", color = {r = 0.27, g = 0.45, b = 0.58, a = 0.92}},
{type = "item", name = "filter-inserter", color = {r = 0.45, g = 0.27, b = 0.54, a = 0.92}},
{type = "item", name = "stack-inserter", color = {r = 0.56, g = 0.63, b = 0.16, a = 0.92}},
{type = "item", name = "stack-filter-inserter", color = {r = 0.70, g = 0.70, b = 0.69, a = 0.92}},
Image

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5221
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Add signal_to_color_mapping support for "tool" items

Post by Klonan »

It works when I do it:

Image

User avatar
PantherX
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Sat Sep 03, 2016 6:26 am
Contact:

Re: Add signal_to_color_mapping support for "tool" items

Post by PantherX »

Argh, this is totally my bad! I had a final-fixes that was removing any mappings that didn't pass this test:

Code: Select all

if data.raw[signal.type][signal.name] then
Obviously because type=tool this wasn't working because it's of type=item in the color mapping table. I guess I'll have to loop over all the different types of prototypes to test this condition instead?

Post Reply

Return to “Already exists”