[boskid][2.0.35] active electric network uses network_id == 0

This subforum contains all the issues which we already resolved.
User avatar
hgschmie
Long Handed Inserter
Long Handed Inserter
Posts: 95
Joined: Tue Feb 06, 2024 5:18 am
Contact:

[boskid][2.0.35] active electric network uses network_id == 0

Post by hgschmie »

[This is a 1.1 save, migrated to 2.0. Using elevated rails & quality but not space age]

I have a compound entity which embeds a power switch which in turn is connected using a copper cable to a power network. When I inspect this in the debugger, the wire connection shows up like this:
Screenshot 2025-02-23 at 15.37.24.png
Screenshot 2025-02-23 at 15.37.24.png (139.43 KiB) Viewed 367 times
The reported network id is "0". The API docs state: Index of a CircuitNetwork or ElectricSubNetwork which is going through this wire connector. Returns 0 if there is no network associated with this wire connector right now.

But there is a network associated with it (it is my main electrical network and if I click on the big electric pole, it will show me all the stats for the network).

Is the documentation wrong? I have connections where network id is > 0. Or should I use different information to determine whether the wire connector is actually connected (e.g. real_connection_count)?
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3516
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.35] active electric network uses network_id == 0

Post by boskid »

If possible please attach a save file with reference to this entity in storage.pole so i can investigate state of save file and of specific entity.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3516
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.35] active electric network uses network_id == 0

Post by boskid »

Thanks for the report. Issue is now fixed for 2.0.36.

In this specific case issue was that LuaWireConnector returns incorrect value for the network_id when given copper wire connector: this value was 1 less than what LuaEntity::electric_network_id would report when it is connected to an electric network. In 2.0.36 this value will be increased by 1 so it matches value read by LuaEntity::electric_network_id and so a first electric network created in game will properly read network_id of 1. For a workaround you can use the LuaEntity::electric_network_id, but this workaround only works for electric poles, if you would happen to get a copper wire connector from a power switch then this workaround is not available.
User avatar
hgschmie
Long Handed Inserter
Long Handed Inserter
Posts: 95
Joined: Tue Feb 06, 2024 5:18 am
Contact:

Re: [boskid][2.0.35] active electric network uses network_id == 0

Post by hgschmie »

thank you for the fix. I will update the mod to require 2.0.36 or newer once that has been released.

I currently use the real_connections_count as an indicator that there are connections and that works well.
Post Reply

Return to “Resolved Problems and Bugs”