Posted 08 April 2012 - 10:30 PM
Ok so, I'm new to programming in general and only started lua recently, so I'm probably way out my league when trying this, but…
I was writing this program, and I have been getting lists of errors, the most recent error would be
bios:206: [string "treeagain"]:137: 'end' expectd (to close 'for' at line 81)
Basically, the program is meant to be able towork like excavate, but the dimesions programable and it goes up. There probably is a program like it already, but I was just trying my hand at it.
If someone could help me with the errors it would be most appreciated
I was writing this program, and I have been getting lists of errors, the most recent error would be
bios:206: [string "treeagain"]:137: 'end' expectd (to close 'for' at line 81)
Basically, the program is meant to be able towork like excavate, but the dimesions programable and it goes up. There probably is a program like it already, but I was just trying my hand at it.
If someone could help me with the errors it would be most appreciated
[Sorry don't know how to make spoilers]
[spoiler][code]--Fourth Attempt at a
--Rubber Tree Decimator!
--function function_name()
--this is used to make functions(note to myself)
--Declaring Variables
x = 0
y = 0
z = 0
a = ""
b = ""
c = ""
PosX = 0 --These aren't used for anything
PosY = 0
PosZ = 0
--Prompting User
print("Input length of cube")
a = read()
x = tonumber(a)
print("")
print("--------")
print("")
print("Input width of cube")
b = read()
z = tonumber( :P/>/>
print("")
print("--------")
print("")
print("Input height of cube")
c = read()
z = tonumber©
--Writing Functions to be used
function Forward()
if turtle.detect() == true then
turtle.dig()
end
itemcount = turtle.getItemCount(9)
if itemcount == 64 then
for i=1, 9, 1 do
turtle.select(i)
turtle.drop()
end
end
turtle.forward()
end
function RightTurn()
turtle.turnRight()
Forward()
turtle.turnRight()
end
function LeftTurn()
turtle.turnLeft()
Forward()
turtle.turnLeft()
end
function GoUp()
if turtle.detectUp() == true then
turtle.digUp()
end
turtle.up()
turtle.turnRight()
turtle.turnRight()
end
--Meat and Potatoes of the Program
--Initial Forward
turtle.dig()
turtle.forward()
--Looping Methods (functions)
for Y = 1, y, 1 do
--Inner Loop
for Z = 1, z, 1 do
--Inner Nested Loop
for X = 1, x, 1 do
Forward()
end
-- Inner Nested end
--Deciding Left or Right
If not z%2 == 0 and not y%2 == 0 == true then
RightTurn() -- this is where it says the error is i think
end
If z%2 == 0 and y%2 == 0 == true then
RightTurn()
end
If not z%2 ==0 and y%2 == 0 == true then
LeftTurn()
end
If z%2 == 0 and not y%2 == 0 == true then
LeftTurn()
end
end
--Inner Loop End
GoUp()
end
--Outer Loop End
--Return to Start
--Even or Odd paths
--Even
If y%2 == 0 then
--Even
If z%2 == 0 then
turtle.turnLeft()
for Z = 1, z, 1 do
Forward()
end
turtle.turnLeft()
for X = 1, x, 1 do
Forward()
end
end
--Odd
If not z%2 == 0 then
turtle.turnRight()
for Z = 1, z, 1 do
Forward()
end
turtle.turnRight()
end
end
--Even
else
--Even
If z%2 == 0 then
turtle.turnRight()
for Z = 1, z, 1 do
Forward()
end
turtle.turnRight()
end
--Odd
If z%2 == 0 then
turtle.turnLeft()
for Z = 1, z, 1 do
Forward()
end
turtle.turnLeft()
for X = 1, x, 1 do
Forward()
end
end
end
while not turtle.detectDown() do
turtle.down()
end