mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-06-13 16:56:49 +00:00
037cbabb32
Unfortunately we can't apply the config changes due to backwards compatibility. This'll be something we may need to PR into Forge. CraftTweaker support still needs to be added.
59 lines
1.3 KiB
Lua
59 lines
1.3 KiB
Lua
if not turtle then
|
|
printError( "Requires a Turtle" )
|
|
return
|
|
end
|
|
|
|
local tArgs = { ... }
|
|
if #tArgs < 1 then
|
|
print( "Usage: go <direction> <distance>" )
|
|
return
|
|
end
|
|
|
|
local tHandlers = {
|
|
["fd"] = turtle.forward,
|
|
["forward"] = turtle.forward,
|
|
["forwards"] = turtle.forward,
|
|
["bk"] = turtle.back,
|
|
["back"] = turtle.back,
|
|
["up"] = turtle.up,
|
|
["dn"] = turtle.down,
|
|
["down"] = turtle.down,
|
|
["lt"] = turtle.turnLeft,
|
|
["left"] = turtle.turnLeft,
|
|
["rt"] = turtle.turnRight,
|
|
["right"] = turtle.turnRight,
|
|
}
|
|
|
|
local nArg = 1
|
|
while nArg <= #tArgs do
|
|
local sDirection = tArgs[nArg]
|
|
local nDistance = 1
|
|
if nArg < #tArgs then
|
|
local num = tonumber( tArgs[nArg + 1] )
|
|
if num then
|
|
nDistance = num
|
|
nArg = nArg + 1
|
|
end
|
|
end
|
|
nArg = nArg + 1
|
|
|
|
local fnHandler = tHandlers[string.lower(sDirection)]
|
|
if fnHandler then
|
|
while nDistance > 0 do
|
|
if fnHandler() then
|
|
nDistance = nDistance - 1
|
|
elseif turtle.getFuelLevel() == 0 then
|
|
print( "Out of fuel" )
|
|
return
|
|
else
|
|
sleep(0.5)
|
|
end
|
|
end
|
|
else
|
|
print( "No such direction: " .. sDirection )
|
|
print( "Try: forward, back, up, down" )
|
|
return
|
|
end
|
|
|
|
end
|