This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
JonaK's profile picture

[1.3-1.4] MineSuite

Started by JonaK, 12 December 2012 - 05:36 PM
JonaK #1
Posted 12 December 2012 - 06:36 PM
Minesuite is a collection of scripts that makes using your mining turtle easy!

Here's the code (also available via cc-get, though there are special installation instructions):
Spoiler


local function usage()
term.clear()
term.setCursorPos(1,1)
print("Please remember to put fuel in the selected slot, otherwise the commands may not work!")
print("")
print("Press Enter to continue")
read()
print("Your options are:")
print("")
print("mine {distance} -- Mines however many blocks specified forward")
print("")
print("Press Enter to continue")
read()
print("minedown {distance} -- Mines however many blocks specified down")
print("")
print("Press Enter to continue")
read()
print("mineup {distance} -- Mines however many blocks specified up")
print("")
print("Press Enter to continue")
read()
print("left {distance} -- Turns left and moves however many blocks specified")
print("")
print("Press Enter to continue")
read()
print("right {distance} -- Turns right and moves however many blocks specified")
print("")
print("Press Enter to continue")
read("")
print("forward {distance} -- Moves forward however many blocks specified")
print("")
print("Press Enter to continue")
read()
print("back {distance} -- Moves back however many blocks specified")
print("")
print("Press Enter to continue")
read()
print("up {distance} -- Moves up however many blocks specified")
print("")
print("Press Enter to continue")
read()
print("down {distance} -- Moves downhowever many blocks specified")
print("")
print("Press Enter to continue")
read()
print("The usage is 'ms [option] {args}'")
print("")
print("Press Enter to continue")
read()
term.clear()
term.setCursorPos(1,1)
end

local args={...}
if #args ~= 2 then
return usage()
end

if args[1] == "mine" then
for mf=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.dig()
turtle.forward()
end
for mb=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.back()
end
end

if args[1] == "minedown" then
for mdd=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.digDown()
turtle.down()
end
for mdu=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.up()
end
end

if args[1] == "mineup" then
for mdu=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.digUp()
turtle.up()
end
for mdd=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.down()
end
end

if args[1] == "left" then
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.turnLeft()
for lfwd=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.forward()
end
end

if args[1] == "right" then
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.turnRight()
for rfwd=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.forward()
end
end

if args[1] == "forward" then
for ffwd=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.forward()
end
end

if args[1] == "back" then
for bbck=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.back()
end
end

if args[1] == "up" then
for uup=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.up()
end
end

if args[1] == "down" then
for down=1,tonumber(args[2]) do
if turtle.getFuelLevel() < 5 then
turtle.refuel(1)
end
turtle.down()
end
end

The different options are:

mine – Digs forward X blocks then comes back.
minedown – Digs down X blocks then comes back.
mineup – Digs up X blocks then comes back.
left – Turns left then moves X blocks
right – Turns right then moves X blocks
forward – Moves forward X blocks.
back – Moves backwards X blocks
up – Moves up X blocks
and lastly,
down – Moves down X blocks.

Usage: ms {script} {distance}

To show help, just type ms.

You, the user, are allowed to distribute this script as long as you give me (the author) credit. If you want to link, link to this thread. Feel free to share it!
River_Chief #2
Posted 14 December 2012 - 02:18 PM
Nice, I'll give it a try.
Expenox #3
Posted 16 December 2012 - 07:19 AM
Nice, going to try it.