Last active
October 14, 2015 01:48
-
-
Save allaryin/4289126 to your computer and use it in GitHub Desktop.
A simple ComputerCraft pinwheel mining script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Allaryin's pinwheel miner | |
-- | |
-- v1 - Dec 14, '12 | |
-- v2 - Dec 15, '12 - attempts to deal with gravel | |
-- v3 - Dec 16, '12 - improved gravel & refueling | |
-- instructions | |
-- fuel goes in slot 1, torches go in slot 2 | |
-- place turtle on left of 2x2 tunnel to be dug | |
-- run script :) | |
print("pinwheel start @ " .. os.time()) | |
-- check torch level | |
-- 18 torches used | |
if turtle.getItemCount(2) < 18 then | |
print("! insufficient torches") | |
exit() | |
end | |
-- check fuel level | |
-- 46 fuel per arm length +1 is used | |
-- for a total of 277 | |
while turtle.getFuelLevel(1) < 277 do | |
print("- refueling") | |
turtle.select(1) | |
succ = turtle.refuel() | |
if succ ~= true then | |
print("! insufficient fuel") | |
exit() | |
end | |
end | |
print("fuel = " .. turtle.getFuelLevel()) | |
-- mine the 2x1 block in front of the turtle | |
function mine() | |
turtle.dig() | |
-- try to go forward | |
if turtle.forward() == false then | |
clearGravel() | |
end | |
turtle.digDown() | |
end | |
-- clear some gravel | |
function clearGravel() | |
repeat | |
turtle.dig() | |
sleep(0.25) | |
until turtle.forward() == true | |
end | |
-- dig | |
while turtle.up() == false do | |
turtle.digUp() | |
end | |
for len = 1,6 do | |
-- main hallway | |
mine() | |
turtle.turnRight(); mine() | |
turtle.turnLeft(); mine() | |
turtle.turnLeft(); mine() | |
turtle.turnRight(); mine() | |
turtle.turnRight(); mine() | |
-- dig arm | |
for arm = 1,18 do | |
mine() | |
end | |
-- return, placing torches | |
turtle.select(2) | |
for torch = 1,19 do | |
turtle.back() | |
if (torch % 8) == 1 then | |
turtle.place() | |
end | |
end | |
-- get ready for the next step | |
turtle.turnLeft() | |
end | |
-- reset | |
for k = 1,19 do | |
while turtle.back() == false do | |
turtle.turnLeft(); turtle.turnLeft() | |
turtle.dig() | |
turtle.turnLeft(); turtle.turnLeft() | |
end | |
end | |
turtle.turnLeft() | |
while turtle.down() == false do | |
turtle.digDown() | |
end | |
print("fuel = " .. turtle.getFuelLevel()) | |
print("pinwheel stop @ " .. os.time()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment