Page 1 of 1

Items with hard-coded behavior like copper cable, etc.?

Posted: Sat Jul 27, 2019 5:11 pm
by swni
Some items, like copper cable, red wire, and green wire, have special behavior when users hold them in hand and click on certain entities.

Looking in data.raw, the only thing unusual I see about these items is the attribute "wire_count = 1".

It looks to me like there is no way to control this behavior (such as, creating a new object "steel cable" that has the same special behavior copper cable has) by modifying data.raw. Is this correct? How does Factorio decide which items get these special behavior; is it by whichever item has the name "copper-cable", etc.?

Would it be possible to disable copper cable's special behavior by changing its name to something else (and updating recipes, etc.)?

Is there a list of all items that have some special hard-coded behavior that are determined by magic things like item names and can't be directly turned on / off by mods?

Thanks.

Re: Items with hard-coded behavior like copper cable, etc.?

Posted: Sat Jul 27, 2019 5:19 pm
by Bilka
swni wrote: Sat Jul 27, 2019 5:11 pm It looks to me like there is no way to control this behavior (such as, creating a new object "steel cable" that has the same special behavior copper cable has) by modifying data.raw. Is this correct? How does Factorio decide which items get these special behavior; is it by whichever item has the name "copper-cable", etc.?
It goes by name.
swni wrote: Sat Jul 27, 2019 5:11 pm Would it be possible to disable copper cable's special behavior by changing its name to something else (and updating recipes, etc.)?
An item prototype with the name "copper-cable" must exist. But you can remove it from all crafting recipes, rename it using locale etc.
swni wrote: Sat Jul 27, 2019 5:11 pm Is there a list of all items that have some special hard-coded behavior that are determined by magic things like item names and can't be directly turned on / off by mods?
I don't know of any such list, but let me know if there any item/behaviour that you'd like to know about.

Re: Items with hard-coded behavior like copper cable, etc.?

Posted: Sat Jul 27, 2019 8:01 pm
by swni
Thanks, that's helpful.

I was thinking of making a mod that randomizes item names (the names visible to user, not the internal names) and icons, but since I think there's no way to change the locale names of things from lua, I figured I could just change every other attribute instead. But then I'll need to make a whitelist of special items whose attributes I can't change and leave those special items alone (or else users will be stuck using train cars or something to make wires).

Re: Items with hard-coded behavior like copper cable, etc.?

Posted: Sat Jul 27, 2019 8:16 pm
by Bilka
swni wrote: Sat Jul 27, 2019 8:01 pm I was thinking of making a mod that randomizes item names (the names visible to user, not the internal names) and icons, but since I think there's no way to change the locale names of things from lua, ...
There is a way to do that :) You can set the localised_name of the items to another item name, for example you could set the steel chest to the copper plate name by adding localised_name = {"item-name.copper-plate"} to the steel chest prototype. That should be much easier to do than randomizing properties.

Re: Items with hard-coded behavior like copper cable, etc.?

Posted: Sat Jul 27, 2019 9:06 pm
by swni
Ahhhh excellent. That will be better. I will need some thought to deal with items that already have localized names.

On that note, I'm unclear what the following localised_name does:

Code: Select all

      localised_name = {
        "item-name.filled-barrel",
        {
          "fluid-name.heavy-oil"
        }
      }
since there seems to be no item named "filled-barrel". Can you actually specify localized names for non-existent items in a locale file and then use those names?

Re: Items with hard-coded behavior like copper cable, etc.?

Posted: Sat Jul 27, 2019 9:12 pm
by Bilka
swni wrote: Sat Jul 27, 2019 9:06 pm Can you actually specify localized names for non-existent items in a locale file and then use those names?
Yep. You can do basically anything in locale files, you can even make your own categories: https://wiki.factorio.com/Tutorial:Loca ... ile_format

Re: Items with hard-coded behavior like copper cable, etc.?

Posted: Sat Jul 27, 2019 10:04 pm
by swni
Thanks for your help!