Posted 29 July 2013 - 12:09 AM
Title: A machine loop program malfunction.
Summary: I am a tekkit veteran, yet just getting into computercraft. I know lua moderately, and I am having trouble with returning a variable from a read() command.
Code:
I understand that it isn't converting the string to a number, if it is the tonumber(loopnum) that is the problem, could I have a quick response and solution?
Many thanks -Titan
Summary: I am a tekkit veteran, yet just getting into computercraft. I know lua moderately, and I am having trouble with returning a variable from a read() command.
Code:
attempt - 0
while attempt == 0 do
term.clear()
term.setCursorPos(1,1)
print("Industrial Ticker Program") //Yes I go overboard with presentation.
print("Enter desired ticker time: ")
loopnum = read()
tonumber(loopnum)
if loopnum > 2 then
print("Are you sure you want ")
term.setCursorPos(23,3) //Yes a little inconveinent. So far havent been successful at putting a var inside a print() command.
print (loopnum," second loops?")
print("type yes to confrim, or no to undo.")
local input = read()
if input == "yes" then
attempt = 1
end
end
end
Error message: "loop:20: attempt to compare string with number expected, got string."I understand that it isn't converting the string to a number, if it is the tonumber(loopnum) that is the problem, could I have a quick response and solution?
Many thanks -Titan