 |
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Fri Feb 01, 2008 5:50 am
Lua + Functions |
i'm gonna assume i can do return 'value' to return a value but how do i access my named params in a function that i've set to lua language?
ie, what i'd normally access via $query etc |
|
_________________ The Drake Forestseer |
|
|
 |
Dharkael Enchanter

Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Fri Feb 01, 2008 10:19 am |
I haven't discovered a way to directly access the named params using their names in lua
but you can use
zs.param(1), zs.param(2) etc to refer to named params, the params are in the same order you enter them in the params list.
If you have named parameters, zs.numparams is always at least equal to the number of named parameters.
Even if the when the alias ,function whatever is called with less arguments than those named,the zs.param(i) will still return the number 0.
That is if you have two named parameters $arg1,$arg2 but in calling the function you only pass one argument.
Then zs.param(1) will have that argument, zs.param(2) will have the number 0.
That number zero thing is kind of lame because it makes it hard to detect that an argument was not passed because zero might be a valid
value passed. |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Feb 01, 2008 5:43 pm |
The zs.param function can also accept the name of the argument. So if you have an argument like $myarg, then you should be able to do zs.param("myarg") to get the value.
The issue with returning 0 instead of nil is on the bug list. |
|
|
|
 |
|
|
|