executeScriptGlobal return value
Posted: Sat Apr 01, 2006 04:43
I'm starting to use lua and cegui together. I've found executeScriptGlobal requires the function to return an integer, otherwise it throws an exception. I find this behaviour somewhat constricting - for instance, many functions I would like to call do not return any value, and I don't like the idea of modifying the lua scripts to do so, just to discard that number after I call it.
There are several ways to generalise this behaviour.
1. Add a bool 2nd argument which is whether a return value is expected.
2. Allow nothing to be returned, in which case the integer is a default value, perhaps specified as a 2nd argument.
3. Have variations for functions that require several different types of returns (void, int and string are the obvious ones).
4. Have a general function which converts the 1st return value to a string, allowing the user to extract it as they see fit.
5. Return a vector of strings for all possible return values.
6. At the very least, throw a certain type of exception that can be caught and discarded (although that is a very fudgy solution).
There are several ways to generalise this behaviour.
1. Add a bool 2nd argument which is whether a return value is expected.
2. Allow nothing to be returned, in which case the integer is a default value, perhaps specified as a 2nd argument.
3. Have variations for functions that require several different types of returns (void, int and string are the obvious ones).
4. Have a general function which converts the 1st return value to a string, allowing the user to extract it as they see fit.
5. Return a vector of strings for all possible return values.
6. At the very least, throw a certain type of exception that can be caught and discarded (although that is a very fudgy solution).