Function within a function
Re: Function within a function
lua_isnumber is for the C api... you want if type(thing) == "number"
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Function within a function
Multi purpose ammobuy alias
Code: Select all
Pattern: ^ammobuy\s?(\w*)\s?(\d*)$
Usage 1: ammobuy type num -- buys num of type
Usage 2: ammobuy type -- buys up to ammoUpperLimit of this type
Usage 3: ammobuy num -- buys more of last type bought
Usage 4: ammobuy -- buys up to ammoUpperLimit of last type bought
Obviously you can change the word ammobuy to whatever you want. Also this requires the previously defined ammoBuy function.
Re: Function within a function
thanks!! i haven't had the chance to try it yet but it looks awesome.
although, i need to ask, why did you set the local variable to -1 at the start? is it just an arbitrary number?
although, i need to ask, why did you set the local variable to -1 at the start? is it just an arbitrary number?
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Function within a function
Yes, just something definitive to test against later on. You could of set it to nil, false, whatever you want, but I figured that sense it was going to be a number at some point that I would keep it a number throughout, and 0 always tests true in Lua unlike other languages.