Posted 16 February 2013 - 09:16 AM
                Ive been trying to create a program to create a wall with set hight and length
all it does is places blocks in a row continually and weirdly the turtle disappears but keeps building forwards
– thanks in advance
                
            Spoiler
s = 2 --Slot number varible
count = {...}
function outaBlocks() -- checks if blocks are left in the full machine
if s == 16 then
if turtle.getItemCount(16) == 0 then
print("I'm outa blocks I need more")
s = 2
return false
else
end
else
end
end
function checkBlockNo() -- checks blocks left in current slot defined by s
print("checking Number of blocks left")
if turtle.getItemCount(s) == 0 then
turtle.select(s+1)
s = s + 1
else
turtle.select(s)
end
end
function checkBlock() -- checks that the block in the current slot compared with slot 16
print("Comparing blocks")
if not turtle.compareTo(16) then
turtle.select(s+1)
s = s +1
else
turtle.select(s)
end
end
function checkFuel() -- checks fuel level and refuels from slot 1 if needed (code taken from sethBling's autowood program
turtle.select(s)
  if turtle.getFuelLevel() < 20 then
	turtle.select(1)
	turtle.refuel(1)
turtle.select(s)
  end
end
function digMove() --digs a block and places the required block
checkFuel()
  checkBlockNo()
   checkBlock()
outaBlocks()
turtle.dig()
turtle.forward()
turtle.turnRight()
  turtle.turnRight()
   turtle.place()
turtle.turnRight()
turtle.turnRight()
length = length - 1
print(length)
end
function down() -- moves the turtle down
turtle.digDown()
turtle.down()
length = tonumber(count[1])
turtle.placeUp()
turtle.turnRight()
  turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
  turtle.turnRight()
   turtle.place()
turtle.turnRight()
turtle.turnRight()
depth = depth - 1
end
while true do
if table.getn(count) ~= 2 then
  print("Need 2 arguments run with autowall <lenght> <depth>")
   return false
else
  length = tonumber(count[1])
  depth =  tonumber(count[2])
  print("Total Blocks required ")
  print(length * depth)
end
if depth ~= 0 then
  if length ~= 0 then
   digMove()
  else
   down()
end
else
  return false
end
end
all it does is places blocks in a row continually and weirdly the turtle disappears but keeps building forwards
– thanks in advance