mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Add checks for nil cursor stack (#341)
This commit is contained in:
@@ -153,7 +153,7 @@ end
|
|||||||
--- Stop selection if the selection tool is removed from the cursor
|
--- Stop selection if the selection tool is removed from the cursor
|
||||||
Event.add(defines.events.on_player_cursor_stack_changed, function(event)
|
Event.add(defines.events.on_player_cursor_stack_changed, function(event)
|
||||||
local player = game.players[event.player_index] --- @cast player -nil
|
local player = game.players[event.player_index] --- @cast player -nil
|
||||||
if player.cursor_stack.is_selection_tool then return end
|
if player.cursor_stack and player.cursor_stack.is_selection_tool then return end
|
||||||
Selection.stop(player)
|
Selection.stop(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ end)
|
|||||||
Event.add(defines.events.on_player_controller_changed, function(event)
|
Event.add(defines.events.on_player_controller_changed, function(event)
|
||||||
local player = game.players[event.player_index] --- @cast player -nil
|
local player = game.players[event.player_index] --- @cast player -nil
|
||||||
local inventory = player.get_main_inventory()
|
local inventory = player.get_main_inventory()
|
||||||
if player.cursor_stack.is_selection_tool and inventory then
|
if player.cursor_stack and player.cursor_stack.is_selection_tool and inventory then
|
||||||
player.hand_location = { inventory = inventory.index, slot = #inventory }
|
player.hand_location = { inventory = inventory.index, slot = #inventory }
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user