Multi Circuit Repeater


Wireless Circuit Networks, per channel. https://buymeacoffee.com/mallyhubz

Content
a month ago
2.0
392
Circuit network

b Error when removing power

25 days ago
(updated 12 days ago)

I needed to move a power pole that was providing power to one of my circuit repeaters. While the repeater was without power, I received the following error:

9518.748 Error MainLoop.cpp:1468: Exception at tick 124398900: The mod Multi Circuit Repeater (1.0.21) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event Multi_Circuit_Repeater::on_tick (ID 0)
real number expected got userdata.
stack traceback:
[C]: in function 'get_object_by_id'
Multi_Circuit_Repeater/control.lua:351: in function 'UpdateTowerPowerStates'
Multi_Circuit_Repeater/control.lua:410: in function <Multi_Circuit_Repeater/control.lua:404>
9526.363 Info AppManager.cpp:353: Deleting active scenario.

I can easily recreate the error by placing and powering two repeaters, then remove power from one of them and wait about 15 seconds.

My fix is to use the same pattern already used in UnifiedRenderCleanup — check whether the stored value is a number or userdata before calling get_object_by_id. Here's my patched section (lines 349-354):

local id = storage.wct_overlays[radar.unit_number]
if id then
  if type(id) == "number" then
    local obj = rendering.get_object_by_id(id)
    if obj and obj.valid then obj.destroy() end
  elseif type(id) == "userdata" then
    if id.valid then id.destroy() end
  end
  storage.wct_overlays[radar.unit_number] = nil
end
18 days ago

I have got that error many times. Yesterday it occured when my nuclear fuel ran out at a power station.

In addition I was on Vulcanus when the game crashed with that error yesterday. Unfortunately the error does not specify which location the error came from so, I had to check all 5 ships, stations, and planets before realizing the source was on Nauvis.

New response