Jump to content




Anyone know how to alter the read?


  • You cannot reply to this topic
3 replies to this topic

#1 Cole

  • New Members
  • 2 posts

Posted 03 December 2014 - 10:16 PM

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 " "?)

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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:

ID = tonumber(read())

If what the user types can't be represented as a number, then tonumber() will fail and return nil.

#4 Cole

  • New Members
  • 2 posts

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