Error when I use check function

Posted by Larkin on Fri 22 Aug 2008 03:22 PM — 4 posts, 17,347 views.

#0
I tried the built-in version of check first and then the module version (with a require call). Both gave the same error message about the format argument being incorrect.

On the command line:
/print(check(Save("")))


Error message:
Run-time error
World: Lusternia
Immediate execution
[string "Check function"]:1: bad argument #2 to 'format' (number expected, got boolean)
stack traceback:
        [C]: in function 'format'
        [string "Check function"]:1: in function 'check'
        [string "Command line"]:1: in main chunk
USA #1
Save() doesn't return anything.

check() is best used for the functions whose prototypes say they return a long. i.e.

check(AddTrigger("Bad Label", "*", "Not gunna happen", 1,0,0,"",""))

will cause an eInvalidObjectLabel error to occur.
#2
Yeah, I figured it out when I actually looked at the check function. I guess I was figuring it would be handling return types more generically, using the type method to see what it should print...
Australia Forum Administrator #3
It can't handle them more generically because all types of numbers in the COM interface just become numbers in Lua.

Plus, some functions (like ColourNameToRGB) actually return a long, it just isn't a status code.