Posted 19 April 2017 - 07:28 AM
I tried to make a turtle that would let the user specify a rectangle's dimensions, then the turtle would replace all blocks beneath it with a desired block. I'm still a bit new to this, but I can't see what is going wrong.
turtle.select(1)
print("Slots 1- 12 hold placing materials.")
print("Slots 13 - 15 must have torches.")
print("Slot 16 holds the material type to place")
print("\nEnter the forward value:")
x = read()
print("\nEnter the sideways value:")
y = read()
inventoryID = 1
depth = 0
turnNum = 0
torchID = 1
repeat
turtle.select(inventoryID)
–Ensuring materials are present–
if turtle.getItemDetail(inventoryID) == turtle.getItemDetail(16) then
if inventoryID == 13 then
print("Out of materials.")
break
end
end
–Ensuring the select switches when needed–
if turtle.getItemDetail(inventoryID) == turtle.getItemDetail(15) then
inventoryID = inventoryID + 1
turtle.select(inventoryID)
end
if turtle.detectDown() == true then
turtle.digDown()
turtle.select(15)
turtle.drop()
turtle.select(inventoryID)
end
turtle.placeDown()
turtle.forward()
depth = depth + 1
if (depth % 6) == 0 then
if (turnNum % 6) == 0 then
turtle.placeDown()
turtle.select(torchID)
if (turtle.getItemCount) == 1 then
torchID = torchID + 1
end
end
end
if depth == (x) then
if (turnNum % 2) == 1 then
turtle.placeDown()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
depth = 0
elseif (turnNum % 2) == 0 then
turtle.placeDown()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
depth = 0
end
turnNum = turnNum + 1
end
until turnNum == y
turtle.select(1)
print("Slots 1- 12 hold placing materials.")
print("Slots 13 - 15 must have torches.")
print("Slot 16 holds the material type to place")
print("\nEnter the forward value:")
x = read()
print("\nEnter the sideways value:")
y = read()
inventoryID = 1
depth = 0
turnNum = 0
torchID = 1
repeat
turtle.select(inventoryID)
–Ensuring materials are present–
if turtle.getItemDetail(inventoryID) == turtle.getItemDetail(16) then
if inventoryID == 13 then
print("Out of materials.")
break
end
end
–Ensuring the select switches when needed–
if turtle.getItemDetail(inventoryID) == turtle.getItemDetail(15) then
inventoryID = inventoryID + 1
turtle.select(inventoryID)
end
if turtle.detectDown() == true then
turtle.digDown()
turtle.select(15)
turtle.drop()
turtle.select(inventoryID)
end
turtle.placeDown()
turtle.forward()
depth = depth + 1
if (depth % 6) == 0 then
if (turnNum % 6) == 0 then
turtle.placeDown()
turtle.select(torchID)
if (turtle.getItemCount) == 1 then
torchID = torchID + 1
end
end
end
if depth == (x) then
if (turnNum % 2) == 1 then
turtle.placeDown()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
depth = 0
elseif (turnNum % 2) == 0 then
turtle.placeDown()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
depth = 0
end
turnNum = turnNum + 1
end
until turnNum == y