Problems with defines.wire_connector_id.*

Place to get help with not working mods / modding interface.
xyzzycgn
Burner Inserter
Burner Inserter
Posts: 11
Joined: Tue Dec 24, 2024 7:37 pm
Contact:

Problems with defines.wire_connector_id.*

Post by xyzzycgn »

I've just stumbled upon a strange behavior concerning the values of defines.wire_connector_id.*

When using these defines I had some strange phenomenons. For digging a little bit deeper I wrote this tiny "mod"

Code: Select all

for _, f in pairs(defines.wire_connector_id) do
    log(f)
end

and expected to see the values from 0 to 8 as shown here https://lua-api.factorio.com/stable/runtime-api.json

Image

Instead I got that

Code: Select all

  46.961 Script @__testMod3__/control.lua:10: 1
  46.961 Script @__testMod3__/control.lua:10: 2
  46.961 Script @__testMod3__/control.lua:10: 1
  46.961 Script @__testMod3__/control.lua:10: 2
  46.961 Script @__testMod3__/control.lua:10: 3
  46.961 Script @__testMod3__/control.lua:10: 4
  46.961 Script @__testMod3__/control.lua:10: 5
  46.961 Script @__testMod3__/control.lua:10: 5
  46.961 Script @__testMod3__/control.lua:10: 6
First surprise - the values start with 1, but even stranger they're not unique.

Probably I missed something, but I can't figure out what - so could somebody please explain it?

Thx in advance
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3754
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Problems with defines.wire_connector_id.*

Post by boskid »

Those are just named constants, they are not required to be unique, similarily as inventory indexes are not unique.
xyzzycgn
Burner Inserter
Burner Inserter
Posts: 11
Joined: Tue Dec 24, 2024 7:37 pm
Contact:

Re: Problems with defines.wire_connector_id.*

Post by xyzzycgn »

Hi boskid,

thank you for the really quick answer. Ok - that looks like some apparently desired redundancy, but shouldn't this be reflected in the json-docu at https://lua-api.factorio.com/stable/runtime-api.json, too? Otherwise it's a little bit misleading ;)
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3754
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Problems with defines.wire_connector_id.*

Post by boskid »

I do not know what you are confused about there. Those defines are literally named like "pole_copper" (=5) for copper wire connector on power poles, or "power_switch_left_copper" (=5) and "power_switch_right_copper" (=6) for power switches. There are no reasons why they should be guarnateed unique and there is no reasonable expectation for them to be unique given that some of the constants are not applicable based on the context and their naming. Similarily there are inventory defines where there is no expectation that "character_main" (=1) should be different than "robot_cargo" (=1) or "turret_ammo" (=1), or "chest" (=1).
xyzzycgn
Burner Inserter
Burner Inserter
Posts: 11
Joined: Tue Dec 24, 2024 7:37 pm
Contact:

Re: Problems with defines.wire_connector_id.*

Post by xyzzycgn »

Oh - it's quite easy to become confused while searching for a mistake and trying to narrow down it by adding some additional logs
which only show the (non unique) numbers and not the (more or less - at least for insiders ;)) self-explanatory identifiers.

And if you're looking during search for the meaning of these numbers at the mentioned above json-docu (because the online docu of the API at
https://lua-api.factorio.com/latest/def ... nnector_id neither contains these values nor any meaningful explanation)
it's really misleading if the values in json-docu do not fit the reality in the running application codebase.

boskid wrote: Thu Mar 27, 2025 5:19 pm Similarily there are inventory defines where there is no expectation that "character_main" (=1) should be different than "robot_cargo" (=1) or "turret_ammo" (=1), or "chest" (=1).
Oh yes - by the way, I didn't expect the values ​​to be unique over all realms

And now let us end this discussion as I do not see that we'll agree.

Thx for your assistance
Post Reply

Return to “Modding help”