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).
executeScriptGlobal return value
Moderators: CEGUI MVP, CEGUI Team
- lindquist
- CEGUI Team (Retired)
- Posts: 770
- Joined: Mon Jan 24, 2005 21:20
- Location: Copenhagen, Denmark
I agree that that interface currently is'nt optimal. I basically filled out the abstract ScriptModule to the point back then.
The least intrusive way I think would be to just detect the return value and if nil return 0 otherwise expect an integer.
Another thing I've been wanting to add is control of the return value for event subscribers.
The least intrusive way I think would be to just detect the return value and if nil return 0 otherwise expect an integer.
Another thing I've been wanting to add is control of the return value for event subscribers.
Return to “CEGUI Library Development Discussion”
Who is online
Users browsing this forum: No registered users and 3 guests