
Untitled
By: a guest on
Jun 1st, 2012 | syntax:
Lua | size: 0.95 KB | hits: 14 | expires: Never
tArgs = {...}
nSel = 1
turtle.select(nSel)
local function printUsage()
print("Usages:")
print("build <length>")
print("build <length> <height>")
end
local nLength = tonumber(tArgs[1])
local nHeight = tonumber(tArgs[2])
if #tArgs > 2 or #tArgs < 1 or nLength == nil then
printUsage()
return
end
if nHeight == nil then
nHeight = 1
end
local function checkSlot()
while getItemCount(nSel) == 0 do
nSel = nSel + 1
if nSel > 9 then
return 0
end
turtle.select(nSel)
end
return 1
end
local function buildLength()
x = 0
ret = 1
while x < nLength do
if checkSlot() == 0 then
return 0
end
turtle.place()
turtle.back()
x = x + 1
end
return 1
end
y = 0
while y < nHeight do
if buildLength() == 0 then
print("Out of blocks")
return
end
turtle.turnRight()
turtle.turnRight()
turtle.up()
turtle.back()
turtle.back()
y = y + 1
end
print("Done building!")