so im making a simple chat program, but im trying to make it so read() can find out the ID, i've put
write("")
ID = read()
rednet.send(ID,"message")
so how do i make it so the program reads the read() as example instead of "example"
(the change there is the " " being around it, the big question is how do i make it so the system ignores the " "?)
Anyone know how to alter the read?
Started by Cole, Dec 03 2014 10:16 PM
3 replies to this topic
#1
Posted 03 December 2014 - 10:16 PM
#2
Posted 03 December 2014 - 10:21 PM
I'm really not sure what you mean. If you type "example", the string will contain "example", likewise with example. I'm really not sure what you're trying to ask. Unless you want to get a number instead of a string? You'd just need to tonumber() the return value.
#3
Posted 04 December 2014 - 12:17 AM
Sounds like he's indeed asking about types, without understanding that strings/numbers are generally called, um, strings/numbers.
A basic example as to how you might convert the type of read()'s output:
If what the user types can't be represented as a number, then tonumber() will fail and return nil.
A basic example as to how you might convert the type of read()'s output:
ID = tonumber(read())
If what the user types can't be represented as a number, then tonumber() will fail and return nil.
#4
Posted 04 December 2014 - 05:38 PM
thanks, really helped. i didn't really know the tonumber() was a thing. thanks again!
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











