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

rs.setBundledOutput help needed!

Started by denni199, 30 January 2013 - 10:50 AM
denni199 #1
Posted 30 January 2013 - 11:50 AM
Title: rs.setBundledOutput help needed!

My little program wont seem to work:

local tArgs = {...}
num = tArgs[1]

rs.setBundledOutput("back", num)

I don't see the part where it fails.
I am typing in an argument when i am starting the program.

If i do it like this:

num = 1
rs.setBundledOutput("back", num)
It works.

The error im getting is:

Expected string, number
Cranium #2
Posted 30 January 2013 - 11:55 AM
Split to new topic.
Orwell #3
Posted 30 January 2013 - 12:04 PM
The reason is that arguments are being read as strings. So num is a string instead of a number. You can solve this by using tonumber():

local tArgs = {...}

local num = tonumber(tArgs[1])
rs.setBundledOutput("back", num)

tonumber() will return nil if the string couldn't be converted to a number, so you can add some logic to counter that. :)/> I tried to keep this example simple.
denni199 #4
Posted 30 January 2013 - 12:07 PM
The reason is that arguments are being read as strings. So num is a string instead of a number. You can solve this by using tonumber():

local tArgs = {...}

local num = tonumber(tArgs[1])
rs.setBundledOutput("back", num)

tonumber() will return nil if the string couldn't be converted to a number, so you can add some logic to counter that. :)/> I tried to keep this example simple.

OH!

I'm a dummy.
Thanks for the help :)/>