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

How would I send a number in letter form?

Started by diamondpumpkin, 15 March 2016 - 08:19 PM
diamondpumpkin #1
Posted 15 March 2016 - 09:19 PM
I'm attempting to send a message via rednet to a computer but it keeps give me an error (Number expected) because I'm trying to grab the id of the computer off a different file.

Code:
The id file:

53
1
Above isn't meant to be ran it's just there to hold computer information, in this case 53 is the computer id and 1 is the id of the thing I'm making.
For the sending:

rednet.open("top")
local h = fs.open("id","r")
local j = h.readLine(1)
local j1 = h.readLine(2)
rednet.send(j,"HI!","send"..j1)
The "j" part is the part that is bugging out, is there anyway to send it as a number? Like this works with messages but not computer ids, how would I make it work with computer ids?
Lyqyd #2
Posted 15 March 2016 - 09:20 PM
ReadLine doesn't take arguments, you get each line of the file in turn. When reading from a file, you'll always get a string. To convert a string to a number, pass it to tonumber() and use the return value.
diamondpumpkin #3
Posted 15 March 2016 - 09:23 PM
ReadLine doesn't take arguments, you get each line of the file in turn. When reading from a file, you'll always get a string. To convert a string to a number, pass it to tonumber() and use the return value.

Sweet thanks!