Quest allows you to access many things indirectly by name, as calculated from an expression. For example, you can use "GetAttribute" to query an attribute from an expression, you can use "do" to run a script based on an expression, and you can use GetObject to get an object based on expression that resolves to its name.
However, until now, functions have only been callable directly, in the source. With the new "JS" API, a little trick opens up that allows you to invoke a function based on an expression (which must resolve to its name). The limitations are that you can't process a return value and you can only pass a single string parameter.
This little function allows you to do it:
<function name="CallFunction" parameters="name,paramstring">
JS.ASLEvent(name, paramstring)
</function>
It takes two parameters: the name of the function to call and a single string parameter (which can contain whatever you like).
Here is a simple example that doesn't do much. Hopefully, you can use this trick for something a bit more useful:
<function name="func1" parameters="p">
msg("func1 called")
</function>
<function name="func2" parameters="p">
msg("func2 called")
</function>
<function name="func3" parameters="p">
msg("func3 called")
</function>
// In a script somewhere (e.g. the game start script)
CallFunction("func" + GetRandomInt(1,3), "")