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

local tArgs = { ... } WTF ?

Started by gabriel2anjos, 12 May 2012 - 01:09 AM
gabriel2anjos #1
Posted 12 May 2012 - 03:09 AM
Hello! I'm writting some programs in lua in computercraft. Sometimes, when i'm looking some codes, i see this:


local tArgs = { ... }
if #tArgs < 1 then
printUsage()
return
end


It was taken from the gps program

Could someone explain me WHATTA HELL is this tArgs. I simply don't have idea…
One more little thing:

if not bOpen then
is the same as:

if bOpen == false then
???
OmegaVest #2
Posted 12 May 2012 - 03:19 AM
1: tArgs are just Dan200's name for the variables pulled from the program line. So, when you put in "gps host 141 64 2", the "host", "141", "64" and "2" would be in the tArgs table. However, the actual call for that information comes from the … .

2: not means the reverse of whatever is immediately after it. So, not bOpen ( a boolean ) would be the same thing as bOpen == false.
gabriel2anjos #3
Posted 12 May 2012 - 03:21 AM
Aaaah.
1- So the tArgs is just a name to the table?
2- The not act as a logical not, ok?
Xtansia #4
Posted 12 May 2012 - 03:50 AM
Also
if not variable then
Can also be used in place of
if variable == nil then
For variables that aren't booleans