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

First Program Bugged

Started by MFWalter, 13 December 2012 - 11:32 AM
MFWalter #1
Posted 13 December 2012 - 12:32 PM
It maybe a bit ambitious but my first program on a mining turtle is supposed to dig a shaft in my branch mine, place torchs on the wall above it every 5 blocks, and then dig a second shaft back to hallway. I suspect there are some issues with my usage of modulous on torch placement, but I can't test it because on the line that calls my refueling function I keep getting an error '=' expected. That is line 24 in the code.

Local t = 0

function fuel()
if turtle.getFuelLevel() <= 10 then
turtle.refuel(1)
end
end

function shaft()
for l=1,21 do
while turtle.detect() == true do
turtle.dig()
sleep(.25)
end

while turtle.detectUp() == true do
turtle.digUp()
sleep(.25)
end
if t%5 == 0 then
turtle.select(16)
turtle.placeUp()
end
turtle.forward
fuel()
t = t + 1
end
end

shaft()

turtle.up()
turtle.turnLeft()

for n=1,3
while turtle.detect()
turtle.dig()
end
turtle.forward()
end

turtle.digDown()
turtle.down()

shaft()
Luanub #2
Posted 13 December 2012 - 02:51 PM
First off keep in mine Lua in case sensitive so on line 1 Local should be local. Also on line 24 your missing the () after the function call.
MFWalter #3
Posted 13 December 2012 - 07:55 PM
Yeah, I caught the local thing and I guess didn't update the worddoc before posting. Interesting that the () in what my turtle is showing as "Ln 23" would be the cause of a line 24 '=' expected error. It has found another error, but I'm gonna work some on that before asking for help again.

THANKS!
MFWalter #4
Posted 13 December 2012 - 07:58 PM
Yep missed 2 "do"s on lines 34 and 35, but got them and it runs now! My turtle took off and started placing torchs in weird places, didn't dig as far as I expected, etc, but he did move forward and dig things! WOOT!