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

Expected number?

Started by Mackan90096, 13 May 2015 - 02:09 PM
Mackan90096 #1
Posted 13 May 2015 - 04:09 PM
Okay. I'm making a program here. It uses the modem api to send messages.
Currently, I'm implementing a command that allows users to change their channel.
But, I get the error "Expected number" on line 108. I can't for my life figure out why.
Thanks for help.
- Mackan

Code
KingofGamesYami #2
Posted 13 May 2015 - 04:58 PM
Line 47:

      channel = tonumber(args[1])

If args[ 1 ] was not a number, channel is now nil, resulting in you passing nil, nil to modem.transmit on line 108.

Suggested Fix: Change line 47

      channel = tonumber(args[1]) or channel
Edited on 13 May 2015 - 03:04 PM
Mackan90096 #3
Posted 14 May 2015 - 12:03 PM
Ah, that fixed it! Thanks!