pcall(some_function) will protect event handlers of other mods than the pcall'ing mod if some_function triggers an event.
Reproduction
Just start a new game and see the error being printed. Test Mod A:
Code: Select all
script.on_event(defines.events.on_player_created,function(e)
local A,B = pcall(function() game.players[e.player_index].force = 'neutral' end)
game.print('A:'..tostring(A))
game.print('B:'..tostring(B))
end)
Code: Select all
script.on_event(defines.events.on_player_changed_force,function(e)
error('This should not be protected?.')
end)
I'm not even sure this is really a bug. It just *feels* wrong. I kinda expected pcall to only protect code inside my own mod.