Posted 03 September 2013 - 07:31 AM
http://www.youtube.com/watch?v=ci3snCtF-wA
*You can jump to 2:07 in the video to skip all of my introduction talk and shout outs.
Allow your turtle to dig in a direction any number of spaces. Useful for spot mining. The turtle will capture whatever it digs if it can.
Usage:
dig <direction> [distance]
dig <distance> [direction]
Notes:
direction parameter maybe abbreviated to a single letter; ie, u = up, d = down, f = forward, b = back
The turtle can not actually dig "back" but it will move "back" if you give it "back" as a parameter.
Useful with http://www.computerc...mmand-stacking/ which allows you to do simple batches at the computer prompt.
Examples:
>dig f 5
The turtle will dig foward 5 paces and capture the materials.
>dig 6 b
The turtle will not actually dig backwards but it will move straight back 6 spaces if it can.
Downloads:
Turtlescritps.com: http://turtlescripts...ject/gjdhfg-Dig
Pastebin.com: http://pastebin.com/9j3Yk42D
Pastebin Code: 9j3Yk42D
The Code:
*You can jump to 2:07 in the video to skip all of my introduction talk and shout outs.
Allow your turtle to dig in a direction any number of spaces. Useful for spot mining. The turtle will capture whatever it digs if it can.
Usage:
dig <direction> [distance]
dig <distance> [direction]
Notes:
direction parameter maybe abbreviated to a single letter; ie, u = up, d = down, f = forward, b = back
The turtle can not actually dig "back" but it will move "back" if you give it "back" as a parameter.
Useful with http://www.computerc...mmand-stacking/ which allows you to do simple batches at the computer prompt.
Examples:
>dig f 5
The turtle will dig foward 5 paces and capture the materials.
>dig 6 b
The turtle will not actually dig backwards but it will move straight back 6 spaces if it can.
Downloads:
Turtlescritps.com: http://turtlescripts...ject/gjdhfg-Dig
Pastebin.com: http://pastebin.com/9j3Yk42D
Pastebin Code: 9j3Yk42D
The Code:
Spoiler
--[[
======================= A KreezCo Production =============================
== Written by: Kreezxil ==
== Orignal Code by: M_I_Z_E ==
== Many Parts of this code was barrowed from the original turtle ==
== programs that come with computer craft. ==
== http://www.computercraft.info/ ==
== YouTube channel Name: Adventures in Casual Gaming ==
== URL: http://www.youtube.com/user/kreezxil ==
== Original URL: http://www.youtube.com/user/MIZ3craft ==
== Please link to my channel and give proper credit if using my code. ==
== Thanks for watching! ==
==========================================================================
--]]
--[[ Begin Library
Libary by Kreezxil 7/29/2013
--]]
function refuel()
--Check fuel and refuel if nessesary
--Code source: sethbling http://www.youtube.com/watch?v=DSsx4VSe-Uk&feature=share&list=SP2Qvl4gaBge02Eh4AqtDSWg3sojt3jeRO
if turtle.getFuelLevel() < 200 then
turtle.select(1)
turtle.refuel(1)
end
end
function dig(direction, distance)
travel = 0
repeat
--[[ do we have fuel? --]]
refuel()
travel = travel + 1
if direction == "f" then
if turtle.dig() then
turtle.suck()
end
if distance > 0 then
turtle.forward()
end
elseif direction == "u" then
if turtle.digUp() then
turtle.suckUp()
end
if distance > 0 then
turtle.up()
end
elseif direction == "d" then
if turtle.digDown() then
turtle.suckDown()
end
if distance > 0 then
turtle.down()
end
elseif direction == "b" then
turtle.back()
end
until travel == distance
end
--[[ End Library --]]
local tArgs = { ... }
local dist = 1
--[[ test how many args were passed, if none set dist to 0 and assume
forward facing. --]]
if #tArgs < 1 then
--[[ print usage --]]
print("Usage: dig [direction] <distance>")
print()
print("Place fuel in slot 1")
print("Give command to dig")
return
else
--[[ dist = tonumber( tArgs[1] ) --]]
--[[ parses passed parameters and sets variables despite order of values --]]
print("Args Present: "..#tArgs)
for n=1,#tArgs do
if n == 3 then
--[[ in the future subsequent arguments will be accepted
as commandline mapping instructions
--]]
break
end
test = string.sub( tArgs[n], 1, 1)
test = string.lower( test )
if string.find("fdub",test) ~= nil then
direction = test
else
dist = tonumber(tArgs[n])
end
end
end
--[[ Process command directives --]]
paramError = 0
if dist == nil or tonumber(dist) < 0 then
print("Distance must be a number from 0 on up.")
paramError = paramError + 1
end
if string.find("fdub",direction) == nil then
print("Direction must be one of: forward, down, up, back, f, d, u, b")
paramError = paramError + 1
end
if paramError > 0 then
print("Number of parameter errors are " .. paramError)
print("Please think about your options.")
return
end
dig(direction,dist)
Edited on 02 December 2013 - 11:36 AM