2 posts
Posted 09 December 2013 - 10:37 PM
The code:
http://pastebin.com/tXjJ7HFCIt just gives me an error that there's an unusual symbol on line 17. How could I fix this? Is there anything else wrong with the code? This is my first program for computer craft, so I'm pretty new to lua. Any suggestions would help, thanks.
52 posts
Posted 10 December 2013 - 12:03 AM
I know your mistake because your answer variable is a string therefore you must set your distance = to a string for it to work. this is how you do it. line 17 where it said distance you need to put :
until tostring("distance") == answer
52 posts
Posted 10 December 2013 - 12:12 AM
I know your mistake because your answer variable is a string therefore you must set your distance = to a string for it to work. this is how you do it. line 17 where it said distance you need to put :
until tostring("distance") == answer
there is a lot of things wrong with this code
local distance = 0
local answer = 0
local answer2 = 0
function intro()
print ("hello, how long would you like the tunnel to be?")
answer = read()
print ("how many strips?")
answer2 = read()
print ("starting...")
end
function strips()
repeat ----------------------repeat loop needs no end
dig()
distance = distance + 1
until distance == answer -------------- until tostring(distance) == answer
turn.back()
end ------------------ so this end is not suppose to be here
end
function dig()
turtle.dig()
turtle.forward()
turtle.digUp()
end
function next()
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.turnRight()
end
function turn.back() ---------------- nil function you need to have turnBack you can't have a period
turtle.turnRight()
turtle.turnRight()
end -- this end the function turnBack. are you sure you want to have an end it here?
if distance == 0 then
next()
else
turtle.moveforward()
distance = distance - 1
end
end ---------extra end get rid of it
intro()
strips()
Edited on 09 December 2013 - 11:16 PM
15 posts
Posted 10 December 2013 - 12:44 AM
I know your mistake because your answer variable is a string therefore you must set your distance = to a string for it to work. this is how you do it. line 17 where it said distance you need to put :
until tostring("distance") == answer
Actually, it'd be:
until tostring(distance) == answer
Though, doesn't explain the unusual symbol thing he was talking about. Not using tostring() doesn't give an error.
1583 posts
Location
Germany
Posted 10 December 2013 - 04:28 AM
I think turn.back() is the problem.
Declare a table called turn on the top of your code,then the turn.back() mistake is removed.
turn = {}
2 posts
Posted 10 December 2013 - 07:16 PM
Pastebin:
http://pastebin.com/jGG3PnbfAlright, so I made a post yesterday for a simple branch miner. Well, after some help and revision, I found a lot of flaws (not really surprised). But anyway, with this one I'm not getting errors (yet), but in the function "intro()," once I enter the amount for the length of the tunnel, it will completely skip the next 2 lines and go to "print ("starting…")," then mine 1 block in front and stop. Can anyone help?
P.S. Sorry if the fix is completely obvious. I'm very new to lua, and even newer to computer craft.
8543 posts
Posted 10 December 2013 - 08:25 PM
Threads merged. Please stick to one topic for all questions about a given piece of code/project.