This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Beardmoresam's profile picture

Turtle Mineshaft Program Error... Help Please?

Started by Beardmoresam, 26 February 2012 - 07:00 PM
Beardmoresam #1
Posted 26 February 2012 - 08:00 PM
Hi, I am pretty new to coding in Lua so I thought I'd start with something simple… and then I got this error: bios:206: [string "mineshaft"]:3: '=' expected

My code (done in notepad ++):

–Create a mineshaft
print("Creating your mineshaft, Press any key to stop")
While true do
turtle.digdown()
turtle.down()
turtle.turnright()
turtle.dig()
turtle.forward()
turtle.turnleft()
turtle.dig()
turtle.forward()
turtle.turnleft()
turtle.dig()
turtle.forward()
turtle.turnright()
turtle.dig()
turtle.forward()
turtle.turnright()
turtle.dig()
turtle.turnleft()
turtle.back()
sleep(1)
end
if event == "key" then
break
end
Liraal #2
Posted 26 February 2012 - 08:03 PM
lua's case sensitive, your functions should be turnLeft(), digDown() etc.
Beardmoresam #3
Posted 26 February 2012 - 08:18 PM
Thanks a million, I was silly not to notice that xD
Beardmoresam #4
Posted 26 February 2012 - 08:30 PM
Ok, so now I have fixed that, I have two issues:
1) my attempt at the press any key to stop even doesn't work even when I put it into the loop (probably missing something obvious again xD)
2) the turtle doesn't stop digging when it reaches bedrock, if just carries on digging a 2 wide, 1high tunnel (basically it carries on without descending as it should at the begining of the loop), how on earth do I tell the turtle to stop if it can't mine the block bellow it at the begining of the loop?? xD

Thanks

Script as it is now:
–Create a mineshaft
print("Creating your mineshaft, Press any key to stop")
while true do
turtle.digDown()
turtle.down()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
turtle.dig()
turtle.turnLeft()
turtle.back()
sleep(0)
if event == "key" and param1 then
break
end
end
Beardmoresam #5
Posted 26 February 2012 - 08:32 PM
This looks promising but I'm not sure about the try down bit:
local function tryDown()
if not turtle.down() then
if turtle.digDown() then
if not collect() then
return false
end
end
if not turtle.down() then
return false
end
end