12 posts
Posted 18 August 2012 - 08:53 PM
I Have been coding a wireless mining turtle lately and i went to test something out and i keep getting this error:
Bios:206:[string "Turtle"]:38: 'end' expected (to close 'if' at line 34)
From what i know this means i'm missing an end but i have checked my code multiple times and have found nothing. its probably something small i'm not noticing. Here's the code:
http://pastebin.com/xGqQVg30
318 posts
Location
Somewhere on the planet called earth
Posted 18 August 2012 - 08:57 PM
You have an if statment on line 34, it needs and end. Give me a sec and i'll try to see were i should put it.
Hmm. I can't see were it needs to go.
3790 posts
Location
Lincoln, Nebraska
Posted 19 August 2012 - 12:40 AM
End needs to go between lines 37 and 38 Did some changes here:
local function runScript()
write "Set Distance to Travel"
input = read()
pos = 0
m = tonumber(input)
h = 20
while pos < 3 do
m = tonumber(m)
h = tonumber(h)
sleep(5)
for i=1, h do
turtle.up()
end
for i=1, m do
turtle.forward()
end
while true do
if turtle.detectDown() == false then
turtle.down()
else
break
end
end
for i=1, 120 do
if turtle.detectDown() == true then
turtle.digDown()
turtle.down()
for i=1, 4 do
if turtle.detectDown() == true then
turtle.turnLeft()
for i=1, 6 do
turtle.select(i)
if turtle.compare() == true then
turtle.dig()
else
turtle.down()
end --end added here
end --end added here
else
turtle.down()
while true do
if turtle.detectDown == false then
turtle.down()
else
break
end
end
end
end
end
end
end
end
for i=1, 120 do
turtle.up()
end
for i=1, m do
turtle.back()
end
while true do
if turtle.detectDown() == false then
turtle.down()
else
break
end
end
OI = turtle.getItemCount(1)
-- gets amount of iron ore
OC = turtle.getItemCount(2)
-- gets amount of copper ore
OG = turtle.getItemCount(3)
-- gets amount of gold ore
D = turtle.getItemCount(7)
-- gets amount of diamond
L = turtle.getItemCount(8)
-- gets amount of Lapis
R = turtle.getItemCount(9)
-- gets amount of redstone
pO = tonumber(OI)
pI = tonumber(OC)
pU = tonumber(OG)
pY = tonumber(D)
pT = tonumber(L)
pR = tonumber(R)
c1 = pO-1
c2 = pI-1
c3 = pU-1
c7 = pY-1
c8 = pT-1
c9 = pR-1
lK = tonumber(c1)
lJ = tonumber(c2)
lH = tonumber(c3)
lG = tonumber(c7)
lF = tonumber(c8)
lD = tonumber(c9)
--drops all but one of each object
turtle.select(1)
turtle.drop(lK)
turtle.select(2)
turtle.drop(lJ)
turtle.select(3)
turtle.drop(lH)
turtle.select(7)
turtle.drop(lG)
turtle.select(8)
turtle.drop(lF)
turtle.select(9)
turtle.drop(lD)
--end --end not needed
h = h+1
pos = pos+1
m = m+1
--end --end not needed
rednet.open("right")
term.clear()
term.setCursorPos(1,1)
print("Awaiting Connection to Server...")
while true do -- better this way
x,y,z=rednet.receive()
if y=="Go" then
runScript()
end
end
Changes are noted. Just a quick run through, but you'll see where your errors are getting thrown from, at least.