Thermal Solar Power (Lite)


Streamlined fork of Thermal Solar Power by MarximusMaximus and others. Contains the basic thermal solar panel (+ large version for better performance), heat exchanger & heat pipe. A new heat loss mechanism has been added, along with various features, visual updates, settings and new mod compat. The mod is carefully balanced for vanilla, but can be configured.

Content
a month ago
1.1
1.65K
Fluids Power

g Crash on deconstruct with Realistic Reactors [ON HOLD]

9 months ago

Hi!

If Realistic Reactors is installed, deconstructing solar panels or heat pipes can throw up the following error. I haven't figured out exactly why or how because it's not always consistent, but it seems to happen more with larger networks of pipes and solar. In particular, I'm using large thermal solar panels with some piping in between (for #aesthetics), and I get this error almost every time I try to deconstruct the thermals or their pipes:

The mod Realistic Reactors (3.1.4) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event RealisticReactors::on_pre_player_mined_item (ID 11)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
[C]: in function 'index'
__RealisticReactors
/scripts/heat/math.lua:47: in function 'calculate_score'
RealisticReactors/scripts/heat/math.lua:59: in function <RealisticReactors/scripts/heat/math.lua:52>
(...tail calls...)
RealisticReactors/scripts/heat/math.lua:271: in function 'callback'
RealisticReactors/scripts/heat/math.lua:211: in function 'neighbour_cells'
RealisticReactors/scripts/heat/math.lua:265: in function 'inside_linked_entities'
RealisticReactors/scripts/heat/math.lua:315: in function 'get_linked_entities'
RealisticReactors/scripts/heat/network.lua:307: in function 'split_heat_network_cell'
RealisticReactors/scripts/heat/network.lua:526: in function 'remove_entity_from_network_cell'
RealisticReactors/scripts/heat/network.lua:607: in function 'remove_reactor'
RealisticReactors/scripts/events/destruct.lua:116: in function 'entity'
RealisticReactors/control.lua:61: in function <RealisticReactors/control.lua:59>

I realise this is technically Realistic Reactors crashing, and you're of course not obliged to do anything about this, but I thought I'd let you know!

9 months ago
(updated 9 months ago)

Thanks for the heads-up. I will look into whether there is anything I can fix on my end.

Not an expert, and I haven't been able to reproduce the error yet, but from what I can tell, RR may in certain contexts attempt to search for and remove entities from other mods using a risky function called destroy(), but seemingly without raising a destroy event to alert those mods of the change (and I am quite certain that it should!). The entity is thus rendered invalid, because it technically no longer exists to RR, but the other mod (in this case TSPL) still maintains its references to it. The RR mod seems to try and do something else to this now invalid object (not sure what), at which point it throws an error.

Since this mod already has a script that removes objects on the script_raised_destroy event, my best guess is that RR needs to add code that alerts other mods to destroyed entities. But I am not sure, since the code is difficult for me to comprehend.

9 months ago

I appreciate you looking into it! I alerted the mod author of Realistic Reactors, too, since I didn't have a good understanding of the problem either, but I do note that if I comment out RR's "on_pre_player_mined_item", then I can hand-mine the reactors away safely. Not sure if that is obvious, or if it helps you. I'll see if I get a response at the other end; thanks again!

9 months ago
(updated 9 months ago)

No problem, and thanks for the added info. I have not reproduced the error, but I looked a bit further into things, and maybe the issue is not what I first thought. Rather, the destroy() function seems to only be used on ghosts, which probably isn't the issue here (see events/destruct.lua line 29-52), and the destroy flag seems to be raised as it should (see events/init.lua line 24). So I have even less of an idea of what is going on! But from your experiment (which I would never have thought of) it does seem that the mod is trying to do something to the heat pipes and thermal panels (they belong to the heat-pipe and reactor prototypes, respectively) right before actually removing them, when it shouldn't.

I may take a deeper look soon, but I might be in over my head on this one. Feel free to update me on the issue, and also good luck with contacting the mod author.

8 months ago
(updated 8 months ago)

Just a small update: I am not looking further into the issue, since I highly doubt I can do anything about it. The RR mod seems to use some sort of custom heat network, and I am guessing it accidentally applies its logic to heat-carrying entities from this mod as well, which messes things up somehow. No idea what to do about it; I don't really even understand the code.

-- May the sun illuminate your face and your code be pristine (bug-free)! --

8 months ago

This is completely fair! It doesn't sound like there's a lot you can do, and I respect that. Thank you for your time <3

8 months ago

No problem!

New response