This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
CrafterJakob's profile picture

rednet:347: positive number expected

Started by CrafterJakob, 18 September 2012 - 12:56 PM
CrafterJakob #1
Posted 18 September 2012 - 02:56 PM
So i was makeing a program named gmail using rednet and had lots of errors. I fixed a few of them, but i couldn't solve this one.

print("Gmail")
print("-------------")
print("a) Send")
print(":)/>/> Receive")
print("-------------")
print("Choose:")
ab = read()
if ab == "a" then
rednet.open("right")
print("Insert Computer ID:")
id = read()
print("Insert Text:")
txt = read()
rednet.send(id, txt)
print("Sent")
sleep(2)
shell.run("gmail")
else
rednet.open("right")
rednet.receive()
end
There is someting wrong at

rednet.send(id, txt)
I guess?
sjele #2
Posted 18 September 2012 - 03:01 PM
rednet.send(id, text) – Id requires too be a number. read() returns a string.

fix:

id = tonumber(read())
CrafterJakob #3
Posted 18 September 2012 - 03:11 PM
Where should I put
id = tonumber(read())
?
KaoS #4
Posted 18 September 2012 - 03:22 PM
by insert computer id


print("Gmail")
print("-------------")
print("a) Send")
print(":)/>/> Receive")
print("-------------")
print("Choose:")
ab = read()
if ab == "a" then
rednet.open("right")
print("Insert Computer ID:")
id = tonumber(read()) --this is the line where you need to turn it into a number
print("Insert Text:")
txt = read()
rednet.send(id, txt)
print("Sent")
sleep(2)
shell.run("gmail")
else
rednet.open("right")
rednet.receive()
end
CrafterJakob #5
Posted 18 September 2012 - 03:32 PM
tnx so much