Posted 10 December 2012 - 06:08 AM
I am trying to make a remote printing program, kinda like a wifi printer. I am having trouble with the string to number conversion/comparison. I know I have multiple errors; some in the client, some in the server, but the most prominent is on line 30 which produces:
print:30: attempt to compare string with number expected, got string
print:30: attempt to compare string with number expected, got string
term.clear()
term.setCursorPos(1,1)
local printing = true
local page = true
repeat
rednet.send(49,"newPage")
local id,msg = rednet.receive(5)
if msg == "true" then
page = true
elseif msg == "false" then
page = false
else
print(msg)
print(" ")
page = false
end
if page == false then
printing = false
end
local line = 1
rednet.send(49,"getSize")
local id,w = rednet.receive(5)
local id,h = rednet.receive(5)
repeat
local l = read()
if l == "exit" then
rednet.send(49,"finish")
printing = false
line = h
elseif string.len(l) <= w then
rednet.send(49,l)
line = line + 1
rednet.send(49,"setLine," .. line)
else
print("Line is too long. Max is: " .. w)
end
until line == h
rednet.send(49,"endPage")
until printing == false
if page == false then
print("Out Of Paper.")
end