Posted 20 March 2013 - 10:26 AM
Hello folks. I'm about a week in to CC and Lua, having a problem I don't understand.
I'm trying to loop through a text file of computerIDs (to send the same command to multiple machines over rednet).
Everything I've read says Lua converts numbers and strings invisibly, but when I use the result of fs.readLine() in rednet.send I get a string error.
The turtleIDs file is just one ID per line:
50
48
…
etc
Example:
Returns:
50
rednet:53: Expected number
If I remove the rednet.send(), it sucessfully prints the numbers.
So far I can see that string.byte will do this, but seems complicated to implement for multi-digit numbers. I have a hunch I'm missing something basic about the language here, so asking the pros :)/>/>
Any help would be great. Also I know the while true loop is poor logic, but lets call this an alpha.
I'm trying to loop through a text file of computerIDs (to send the same command to multiple machines over rednet).
Everything I've read says Lua converts numbers and strings invisibly, but when I use the result of fs.readLine() in rednet.send I get a string error.
The turtleIDs file is just one ID per line:
50
48
…
etc
Example:
idFile = fs.open("miningTurtleIDs","r")
while true do
turtleID = idFile.readLine()
if turtleID == nil then break end
print(turtleID)
rednet.send(turtleID,"blappity blah")
end
idFile.close()
Returns:
50
rednet:53: Expected number
If I remove the rednet.send(), it sucessfully prints the numbers.
So far I can see that string.byte will do this, but seems complicated to implement for multi-digit numbers. I have a hunch I'm missing something basic about the language here, so asking the pros :)/>/>
Any help would be great. Also I know the while true loop is poor logic, but lets call this an alpha.