Posted 21 August 2013 - 05:07 AM
I was trying to create a program where you select an option using a number e.g [1] do something
[2] do something else
but when i created the program it won't detect what number you type so it skips the tests for input
i added the print ("End of program") so i knew when the program finished
my problem is if you type 1 for example the "if input == 1 then" test doesn't pick up the 1 and just skips to the end
[2] do something else
but when i created the program it won't detect what number you type so it skips the tests for input
term.clear()
term.setCursorPos(1,1)
turtle.refuel()
local a = 0
local b = 0
print ("[1] Build a house")
print ("[2] Build a bridge")
print ("[3] Unlock door")
print ("[4] Type name")
local input = read()
if input == 1 then
term.clear()
term.setCursorPos(1,1)
print ("Width:")
local width = read()
term.clear()
term.setCursorPos(1,1)
print ("Length:")
local length = read()
term.clear()
term.setCursorPos(1,1)
print ("height:")
local height = read()
term.clear()
term.setCursorPos(1,1)
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.turnLeft()
turtle.up()
turtle.forward()
turtle.select(2)
repeat
repeat
turtle.placeDown()
turtle.forward()
length = length - 1
a = a + 1
until length == 0
turtle.turnRight()
turtle.forward()
repeat
turtle.placeDown()
turtle.forward()
width = width - 1
b = b + 1
until width == 0
turtle.turnRight()
turtle.forward()
repeat
turtle.placeDown()
turtle.forward()
a = a - 1
until a == 0
turtle.turnRight()
turtle.forward()
repeat
turtle.placeDown()
turtle.forward()
b = b - 1
until b == 0
height = height - 1
until height == 0
end
print ("End of program")
i added the print ("End of program") so i knew when the program finished
my problem is if you type 1 for example the "if input == 1 then" test doesn't pick up the 1 and just skips to the end