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

[Lua][Error] rednet:347: positive number expected [Solved]

Started by DeviousD, 09 April 2012 - 12:59 PM
DeviousD #1
Posted 09 April 2012 - 02:59 PM
I got a strange error. I am trying to make an overcomplicated system for repeating a message over great distance (to learn more about lua.)

The path the it must follow is included in the message (rp1: repeater1 computer id) Before sending using rednet.send the right ''address'' is extracted from the message through cutting out the right part of the message.

The code is here: http://pastebin.com/t3GwBn9L

It keeps giving me the this error: rednet:347: positive number expected. I am sure the number is positive it has been 'printed' one line above giving a positive number (1)
Could someone pls point me to my mistake.

thanks,
DeviousD
cant_delete_account #2
Posted 09 April 2012 - 06:43 PM
You're using the string API to give the rednet.send an id, it needs to be a int (positive number) not a string (text).
MysticT #3
Posted 09 April 2012 - 06:46 PM
I found two errors:
1)

rp1l = string.len(rp1)
rp2l = string.len(rp2)
rp3l = string.len(rp3)
rp4l = string.len(rp4)
rp1, rp2, rp3 and rp4 are all numbers, so why string.len() ?
2) targetid is a string, not a number, that's why you get the error. You see it gets printed right, but it's a string, rednet.send() needs a number.
DeviousD #4
Posted 09 April 2012 - 06:51 PM
thanks thesbros and MysticT using tonumber to convert it to a int worked fine (still learning) Solved