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

lua:1: attempt to call number with os.computerID()

Started by Donnie, 26 November 2012 - 08:44 AM
Donnie #1
Posted 26 November 2012 - 09:44 AM
Ok, I am trying to see what the computerID of a certan computer is. When I go into the lua shell, I type:

print(os.computerID())
and it returns:

lua:1: attempt to call number
What am I doing wrong? I need the computerID to send a rednet message to another computer. All help is appreciated, thanks.
Kingdaro #2
Posted 26 November 2012 - 09:55 AM
It's actually os.getComputerID().
ChunLing #3
Posted 26 November 2012 - 02:33 PM
But hey, now we know that we can just get the ID without the function call. I guess someone didn't mark that as private.
Lyqyd #4
Posted 26 November 2012 - 02:40 PM
os.computerID() is a function that does the same thing as os.getComputerID(), and running the exact line in the OP does not result in an error.
ChunLing #5
Posted 26 November 2012 - 03:01 PM
Oh, I guess that's so (I always use os.computerID() rather than os.getComputerID now that I think of it). But what's with the error? Must be a typing error, like an extra "()" in there somewhere.

Just use the id program, type "id" into the shell.
Dlcruz129 #6
Posted 28 November 2012 - 07:04 PM
Ok, I am trying to see what the computerID of a certan computer is. When I go into the lua shell, I type:

print(os.computerID())
and it returns:

lua:1: attempt to call number
What am I doing wrong? I need the computerID to send a rednet message to another computer. All help is appreciated, thanks.

os.computerID() returns a number. Try:

print(tostring(os.computerID()))
Doyle3694 #7
Posted 28 November 2012 - 09:29 PM
and you can print numbers
KaoS #8
Posted 28 November 2012 - 11:21 PM
Donnie what I think we are all trying to say is that there is no error there. it actually works. perhaps you typed it wrong or loaded your computercraft mod wrong… other than that you may have overwritten os.computerID earlier in your code, try using that code on a fresh computer
ChunLing #9
Posted 29 November 2012 - 07:53 AM
My guess is that it was actually "print(os.computerID()())", which would call os.computerID to get a number, and then attempt to call that number.