@@ -59,27 +59,29 @@ script.on_event(defines.events.on_marked_for_deconstruction, function(event)
5959 -- player has a upgrade planner and other has deconstruction planner,
6060 -- we can't determine it, so we have to discard deconstruction order.
6161 for _ , p in pairs (game .players ) do
62- local stack = p .cursor_stack
63- if stack .valid_for_read then
64- if stack .name == " upgrade-planner" then
65- if upgrade or deconstruction or module then
66- -- debugDump("Upgrade planner used", true)
67- return
68- end
69- upgrade = true
70- elseif stack .name == " deconstruction-planner" then
71- if upgrade or module then
72- -- debugDump("Deconstruction/Module planner used", true)
73- return
74- end
75- deconstruction = true
76- elseif stack .name == " module-inserter" then
77- if upgrade or deconstruction then
78- -- debugDump("Deconstruction/Upgrade planner used", true)
79- return
62+ if p .connected then
63+ local stack = p .cursor_stack
64+ if stack and stack .valid_for_read then
65+ if stack .name == " upgrade-planner" then
66+ if upgrade or deconstruction or module then
67+ -- debugDump("Upgrade planner used", true)
68+ return
69+ end
70+ upgrade = true
71+ elseif stack .name == " deconstruction-planner" then
72+ if upgrade or module then
73+ -- debugDump("Deconstruction/Module planner used", true)
74+ return
75+ end
76+ deconstruction = true
77+ elseif stack .name == " module-inserter" then
78+ if upgrade or deconstruction then
79+ -- debugDump("Deconstruction/Upgrade planner used", true)
80+ return
81+ end
82+ player = p
83+ module = true
8084 end
81- player = p
82- module = true
8385 end
8486 end
8587 end
0 commit comments