You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
miner/mine.lua

54 lines
1.0 KiB

local robot = require("robot")
local nav = require("navigator")
local chest = require("chest")
local miner = require("miner")
local component = require("component")
local inventory = component.inventory_controller;
ORES = {
'minecraft:iron_ore',
'minecraft:gold_ore',
'minecraft:coal',
'minecraft:diamond',
'minecraft:redstone',
'minecraft:dye', -- Lapis
}
print("Mining...")
while true do
-- mine, starts facing east, goes east and scans south
miner.mine(32)
-- ends facing "west"
robot.turnRight()
-- store items
print("Storing ores")
chest.store(ORES)
robot.turnLeft()
nav.forward(2)
robot.turnRight()
print("Storing the rest")
chest.store()
robot.turnRight()
nav.forward(2)
-- restock
robot.turnLeft()
chest.take('minecraft:torch', 1)
local can_continue = chest.take('minecraft:iron_pickaxe', 2)
robot.turnRight()
if not can_continue then
break
end
robot.select(2)
inventory.equip()
-- ends facing east
end