Reputation: 583
I have created a small program that asks for the length width and heights that you wish a mining turtle to mine. When I run it in the advanced computer though, It lets me prompt for the length, width and height but then I get an error. The error is as follows:
miner:39: attempt to index ? ( a nil value)
Here is my code:
term.clear()
term.setCursorPos(1,1)
write("Length:")
length = read()
print()
write("Confirm:")
ul = read()
print()
write("Width:")
width = read()
print()
write("Confirm:")
uw = read()
print()
write("Height:")
height = read()
print()
write("Confirm:")
uh = read()
print()
local totcount = ul + uw + uh
local subcount = 0
function Length()
repeat
turtle.dig()
turtle.forward()
length = length - 1
subcount = subcount + 1
until length == 0
length = ul
end
function Width()
repeat
turtle.dig()
turtle.forward()
width = width - 1
subcount = subcount + 1
until width == 0
width = uw
end
function Height()
turtle.digDown()
turtle.down()
height = height - 1
subcount = subcount + 1
end
function Turn()
turtle.turnRight()
end
repeat
Length()
Turn()
Width()
Turn()
Length()
Turn()
Width()
Turn()
Height()
until subcount == totcount
Upvotes: 1
Views: 1125
Reputation: 29453
It doesn't look any of your functions have end
, fix that first. If you properly indent your code you will see this.
You also have while count < length do
with an else
block. AFAIK this is not valid syntax (never seen it and just checked online ref manual and wiki). It is not clear whether you meant if count < length do
, but if really meant while
then replacing else
by end
doesn't look right either. Take a closer look at that section of code.
Upvotes: 2