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

Tunnel Program Help

Started by Sibire, 14 March 2012 - 09:35 PM
Sibire #1
Posted 14 March 2012 - 10:35 PM
Okay so I apparently have a picky turtle expecting an "=" on line 10… Problem is I've no idea how to fix it…

local digsleft = 0
local maxdigs = 16
local digs = 0 
local slots = 16
local exc = 0
local tun = 0

lua

print("Activating Submarine Tunnel Construction…")
end

turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.select(1)
turtle.place(1)
turtle.down(1)
turtle.place(1)
turtle.right(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.left(1)
turtle.place(1)
turtle.up(1)
turtle.place(1)
turtle.up(1)
turtle.left(1)
turtle.forward(1)
turtle.right(1)
turtle.place(1)
turtle.left(1)
turtle.forward(1)
turtle.right(1)
turtle.place(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.place(1)
turtle.right(1)
turtle.forward(1)
turtle.left(1)
turtle.place(1)
turtle.up(1)
turtle.select(3)
turtle.place(1)
turtle.up(1)
turtle.place(1)
turtle.left(1)
turtle.forward(1)
turtle.right(1)
turtle.place(1)
turtle.down(1)
turtle.place(1)
end

slots = slots -1
end

if slots == 8 then
turtle.select(2)
print ("Switching To Slot #2…")
end

digs = digs + 1
digsleft = digsleft - 1
end

if digs == maxdigs then
turtle.dig(1)
turtle.forward(1)
exc = exc + 1


if exc == maxdigs then
turtle.right(1)
turtle.forward(1)
turtle.right(1)
tun = tun + 1


turtle.dig(1)
turtle.forward(1)
exc = exc + 1


if exc == maxdigs then
turtle.right(1)
turtle.up(1)
turtle.right(1)
tun = tun + 1

turtle.dig(1)
turtle.forward(1)
exc = exc + 1

if exc == maxdigs then
turtle.left(1)
turtle.forward(1)
turtle.left(1)
tun = tun + 1

if tun == 4 then

turtle.right(1)
turtle.forward(1)
turtle.right(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
print("Done.")
end

exit()

Casper7526 #2
Posted 14 March 2012 - 11:08 PM
If thats your full code… why do you have

lua

print("Activating Submarine Tunnel Construction…")
end

lua shouldn't be there and the end shouldn't be there because your not ending a control block.

On second glance, you have multiple "ends" that shouldn't be there.

And end is only used to end an if statement or loop basically.
Sibire #3
Posted 15 March 2012 - 12:52 AM
Alright. Well I've cropped it up a bit but now it's an "'<eof>'" error on line 57…
local maxdigs = 16
local digs = 0
local slots = 16
local exc = 0
local tun = 0

print("Activating Submarine Tunnel Construction…")
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.select(1)
turtle.place(1)
turtle.down(1)
turtle.place(1)
turtle.right(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.left(1)
turtle.place(1)
turtle.up(1)
turtle.place(1)
turtle.up(1)
turtle.left(1)
turtle.forward(1)
turtle.right(1)
turtle.place(1)
turtle.left(1)
turtle.forward(1)
turtle.right(1)
turtle.place(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.place(1)
turtle.right(1)
turtle.forward(1)
turtle.left(1)
turtle.place(1)
turtle.up(1)
turtle.select(3)
turtle.place(1)
turtle.up(1)
turtle.place(1)
turtle.left(1)
turtle.forward(1)
turtle.right(1)
turtle.place(1)
turtle.down(1)
turtle.place(1)
slots = slots -1
digs = digs + 1
end

if slots == 8 then
turtle.select(2)
print ("Switching To Slot #2…")
end

if digs == maxdigs then
turtle.dig(1)
turtle.forward(1)
exc = exc + 1
end

if exc == maxdigs then
turtle.right(1)
turtle.forward(1)
turtle.right(1)
tun = tun + 1
end

turtle.dig(1)
turtle.forward(1)
exc = exc + 1
if exc == maxdigs then
turtle.right(1)
turtle.up(1)
turtle.right(1)
tun = tun + 1
end

turtle.dig(1)
turtle.forward(1)
exc = exc + 1
if exc == maxdigs then
turtle.left(1)
turtle.forward(1)
turtle.left(1)
tun = tun + 1
end

if tun == 4 then
turtle.right(1)
turtle.forward(1)
turtle.right(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
print("Done.")
end
Sibire #4
Posted 15 March 2012 - 01:30 AM
Alright I've managed to get it to start up but it won't do anything after line 23 due to calling a nil…
local digs = 0
local slot = 16
local exc = 0
local tun = 0
if slot == 8 then
turtle.select(2)
print ("Switching To Slot #2...")
end
print("Activating Submarine Tunnel Construction...")
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.select(1)
turtle.place(1)
turtle.down(1)
turtle.place(1)
turtle.turnright(1)
turtle.forward(3)
turtle.turnleft(1)
turtle.place(1)
turtle.up(1)
turtle.place(1)
turtle.up(1)
turtle.turnleft(1)
turtle.forward(1)
turtle.turnright(1)
turtle.place(1)
turtle.turnleft(1)
turtle.forward(1)
turtle.turnright(1)
turtle.place(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.place(1)
turtle.turnright(1)
turtle.forward(1)
turtle.turnleft(1)
turtle.place(1)
turtle.up(1)
slots = slots -1
digs = digs + 1
if digs == 16 then
turtle.dig(1)
turtle.forward(1)
exc = exc + 1
if exc == 16 then
turtle.turnleft(1)
turtle.forward(1)
turtle.turnleft(1)
turtle.dig(1)
turtle.forward(1)
exc = exc + 1
if exc == 16 then
turtle.turnright(1)
turtle.up(1)
turtle.turnright(1)
turtle.dig(1)
turtle.forward(1)
exc = exc + 1
if exc == 16 then
turtle.turnright(1)
turtle.forward(1)
turtle.turnright(1)
end
end
end
end
print("Returning.")
turtle.turnright(1)
turtle.forward(1)
turtle.turnright(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
turtle.up(1)
print("Done.")
Espen #5
Posted 15 March 2012 - 01:49 AM
Case sensitivity is important.
It's not turtle.turnleft or turtle.turnright, but turtle.turnLeft() and turtle.turnRight().
Sibire #6
Posted 15 March 2012 - 04:11 AM
… :D/>/> Oh…
So now I've only got to get it to repeat this…
turtle.place(1)
turtle.down(1)
turtle.place(1)
turtle.turnRight(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.turnLeft(1)
turtle.place(1)
turtle.up(1)
turtle.place(1)

turtle.up(1)
turtle.turnLeft(1)
turtle.forward(1)
turtle.turnRight(1)
turtle.place(1)
turtle.turnLeft(1)
turtle.forward(1)
turtle.turnRight(1)
turtle.place(1)
turtle.down(1)
turtle.down(1)
turtle.down(1)
turtle.place(1)
turtle.turnRight(1)
turtle.forward(1)
turtle.turnLeft(1)
turtle.place(1)
turtle.turnLeft(1)
turtle.forward(1)
turtle.forward(1)
turtle.turnRight(1)
turtle.up(1)
digs = digs + 1
Espen #7
Posted 15 March 2012 - 11:23 AM
None of your code repeats, because you didn't use any loop or iterator to repeat any code.
You just run through multiple if-statements once and then that's it.
I'd suggest to take a look at some programming tutorials first, because knowing how loops work or what functions are, etc., is essential and will help you with your programs in general. For example: http://lua.gts-stolberg.de/en/index.php
Sibire #8
Posted 15 March 2012 - 10:51 PM
Alright. Loop works. Thanks for the help guys! :D/>/>