Page 1 of 1

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

Posted: Sun Feb 23, 2025 11:41 pm
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 365 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)?

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

Posted: Mon Feb 24, 2025 6:32 am
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.

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

Posted: Mon Feb 24, 2025 10:06 am
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.

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

Posted: Mon Feb 24, 2025 6:16 pm
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.