/c global.swap_inventory = global.swap_inventory or game.create_inventory(5) local function reset_cursor_direction(player) if not (player and player.valid) then return end local cursor = player.cursor_stack local hand_location = player.hand_location if hand_location then player.clear_cursor() local inv = player.get_inventory(hand_location.inventory) local stack = inv[hand_location.slot] cursor.transfer_stack(stack) player.hand_location = hand_location game.print(game.tick.." swapped to inventory and back to cursor") else global.swap_inventory[1].transfer_stack(cursor) cursor.transfer_stack(global.swap_inventory[1]) game.print(game.tick.." swapped to script inventory and back") end end reset_cursor_direction(game.player) local player = game.player local position = {player.position.x + 5, player.position.y + 5} player.build_from_cursor({ position = position, direction = defines.direction.north })