Posted 07 February 2013 - 04:49 PM
Title: [Lua] [Error] Identifying program argument types
I was making a program to test out if I could identify if an arugment of a program, like [umbrella 1 this], could be determined and then the program would follow up with the appropriate action like, to print "Hey, yo man, that arguemnt is text!" Or something like that. Every time I try to identify the argument's type with type() it returns a nil value, instread of string or number.
I tried to set up two programs to do similar things, but for simplicity, I'll post my most recent one I've done.
It gives me the error
testman:4: attempt to index ? (a nil value)
Can type() not determine arugments' type for some reason? I looked around the forums and didn't see anything on this, so I'm turning to you guys. Please help?
I was making a program to test out if I could identify if an arugment of a program, like [umbrella 1 this], could be determined and then the program would follow up with the appropriate action like, to print "Hey, yo man, that arguemnt is text!" Or something like that. Every time I try to identify the argument's type with type() it returns a nil value, instread of string or number.
I tried to set up two programs to do similar things, but for simplicity, I'll post my most recent one I've done.
tArgs = { ... }
table1 = {1, "stringman", 1.5}
print(type(#tArg[1]))
sleep(1)
print(table1[1])
sleep(1)
print(table1[2])
sleep(1)
print(table1[3])
sleep(1)
print(type(table1[1]))
sleep(.5)
print(type(table1[2]))
sleep(.5)
print(type(table1[3]))
sleep(.5)
x = "string"
y = type(x)
print(y)
It gives me the error
testman:4: attempt to index ? (a nil value)
Can type() not determine arugments' type for some reason? I looked around the forums and didn't see anything on this, so I'm turning to you guys. Please help?