9 posts
Posted 28 September 2013 - 07:18 PM
Help I made a program to allow people to talk via rednet and it says expected number Heres My Code: print("Chatter 1.0! By Kpfromer")
write("Id:")
local id = read()
write("Message:")
local message = read()
rednet.send(id, message)
8543 posts
Posted 28 September 2013 - 09:33 PM
Split into new topic.
Go read the sticky posts.
read() returns strings. Use tonumber to convert id to a number.
9 posts
Posted 28 September 2013 - 09:52 PM
How? Can I Have An Example!
115 posts
Posted 28 September 2013 - 10:35 PM
How? Can I Have An Example!
print("Chatter 1.0! By Kpfromer")
write("Id:")
local id = tonumber(read())
write("Message:")
local message = read()
rednet.send(id, message)
1522 posts
Location
The Netherlands
Posted 29 September 2013 - 11:37 AM
How? Can I Have An Example!
print("Chatter 1.0! By Kpfromer")
write("Id:")
local id = tonumber(read())
write("\nMessage:")
local message = read()
rednet.send(id, message)
I would suggest that makes sure you have a number:
print("Chatter 1.0! By Kpfromer")
write("Id:")
local id
repeat
id = tonumber( read() ) -- if the read is not a number, then id will be nil.
until id
write("Message:")
local message = read()
rednet.send(id, message)