Posted 08 April 2013 - 02:07 PM
Hi, I tried to write my first basic program today and it was intended to dig out a shallowish 16x16 chunk of land just to make underground base building easier. However I've ran into an error that I have no idea how to fix :\
Error is "chunkdigger:63: attempt to perform arithmetic __sub on nil and number"
I realize that this is incredibly amateurish code but this is the first programming I've ever done so…. Yeah :P/> Anyways, here's the raw code from pastebin:
Thanks and sorry for being newbish xD
Error is "chunkdigger:63: attempt to perform arithmetic __sub on nil and number"
I realize that this is incredibly amateurish code but this is the first programming I've ever done so…. Yeah :P/> Anyways, here's the raw code from pastebin:
Spoiler
--Variable chunk excavating depth program, doesn't include auto disposal of blocks however.
local function DigOneRow()
for i = 1,15 do
while (turtle.detect()) do
turtle.dig()
sleep(0.5)
end
turtle.forward()
end
end
local function DigTwoRows()
DigOneRow()
turtle.turnRight()
while (turtle.detect()) do
turtle.dig()
sleep(0.5)
end
turtle.forward()
turtle.turnRight()
DigOneRow()
turtle.turnLeft()
while (turtle.detect()) do
turtle.dig()
sleep(0.5)
end
turtle.forward()
turtle.turnLeft()
end
local function LastRowsInLayer()
DigOneRow()
turtle.turnRight()
while (turtle.detect()) do
turtle.dig()
sleep(0.5)
end
turtle.forward()
turtle.turnRight()
DigOneRow()
end
local function MoveToStartXZ()
turtle.turnRight()
DigOneRow()
turtle.turnRight()
end
local function DigOneLayer()
for i=1,7 do
DigTwoRows()
end
LastRowsInLayer()
MoveToStartXZ()
turtle.digDown()
turtle.Down()
end
local function UserDepthInput()
print("Hello. I am Shaft001. I can dig a 16x16 hole to the depth you desire. Please note that I have no checkFuel function so you must chock me full of fuel before starting! If digging a deep shaft, note that I do not have an automatic item storage function so you must periodically empty my inventory.")
print("Please enter a value, preferably under 20, but must be less than current Y value-4.")
print("Dig Depth:")
depth= read("")
print("Your selected depth is: "..depth)
end
local function InputtedDepthLayers()
local depth=depth
local depthup=depth-1
for i=1,depth do
DigOneLayer()
end
turtle.Up()
turtle.select(1)
turtle.placeDown()
for i=1,depthup do
turtle.Up()
end
end
InputtedDepthLayers()