I'm trying to fix up a mod from 0.14 to 0.15, and am getting a "Exception at tick XXXX: Received event 0 has not been defined." I've been using a whole bunch of 'print's to try to track this down, and it's not working as well as I'd like. (Specifically, I've instrumented all of the `raise_event`s, and none of them are throwing the event ID 0).
Under normal circumstances I'd just fire up GDB and trace back up to whatever function sent that event, but -- I have no idea if/how a debugger can be used for Factorio mods.
So yeah, does anyone have any methods for debugging on this? Or am I just stuck with huge piles of 'print's?
Is there a way to backtrace an event?
-
- Fast Inserter
- Posts: 122
- Joined: Fri Jun 17, 2016 8:17 pm
- Contact:
Re: Is there a way to backtrace an event?
Event id 0 is on_tick
Post your code and I can peek at it.
Post your code and I can peek at it.
-
- Fast Inserter
- Posts: 122
- Joined: Fri Jun 17, 2016 8:17 pm
- Contact:
Re: Is there a way to backtrace an event?
I'm trying to retrofit mknejp's Wireless Charging (+ Wireless Charging Lib).
I believe the offending call is in Wireless Charging/src/main.lua:81
given that commenting out that particular line results in it not throwing the error. This seems weird though, because shouldn't that be the valid way of de-registering the on-tick event? Did something about that change in 0.15?
For comparison, the on_charging_started uses a to register the charging-handling code, and that seems to work fine.
I believe the offending call is in Wireless Charging/src/main.lua:81
Code: Select all
function on_charging_stopped(event)
.....
if(next(charging_accumulator_grids) == nil) then
script.on_event(defines.events.on_tick, nil) --this line causes the issue
end
For comparison, the on_charging_started uses a
Code: Select all
script.on_event(defines.events.on_tick, on_tick)
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Is there a way to backtrace an event?
I'm not sure what you're trying to do here, but, that does look... wrong.
Are you trying to delete the on_tick event on the fly? if so, a better solution would be to put that check in the on_tick event, and drop out if you're don't need to do anything.
Are you trying to delete the on_tick event on the fly? if so, a better solution would be to put that check in the on_tick event, and drop out if you're don't need to do anything.
Re: Is there a way to backtrace an event?
Deleting events on the fly is valid (although easy to get wrong and cause desyncs).bobingabout wrote:I'm not sure what you're trying to do here, but, that does look... wrong.
Are you trying to delete the on_tick event on the fly? if so, a better solution would be to put that check in the on_tick event, and drop out if you're don't need to do anything.
Can you post the mod(s) and how you get the error to happen? Looking at where that error comes from there might be a problem with how the game fires events. If I'm reading this correctly: if during an event loop a mod un-registers from an event through a remote call it will produce this error.
If you want to get ahold of me I'm almost always on Discord.