executeScriptGlobal return value

Discussion regarding the development of CEGUI itself - as opposed to questions about CEGUI usage that should be in the help forums.

Moderators: CEGUI MVP, CEGUI Team

User avatar
gcarlton
Just can't stay away
Just can't stay away
Posts: 149
Joined: Wed Jan 12, 2005 12:06

executeScriptGlobal return value

Postby gcarlton » 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).

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Postby lindquist » Sat Apr 01, 2006 12:38

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.


Return to “CEGUI Library Development Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests