Another alternative: you can use scripts as "function thunks", that is have scripts that call the functions for you. Then pass the scripts to your function. You'll have to use invoke instead of a direct call, but there is no way in Quest that I know of to call a function indirectly.
Your example this way:
<function name="function_0" parameters="function_parameter">
invoke(function_parameter)
</function>
<function name="function_1">
msg("This is function_1")
</function>
<function name="function_2">
msg("This is function_2")
</function>
<command>
<pattern>test</pattern>
<script>
if (GetRandomInt(0,1) = 0) {
s => { function_1() }
} else {
s => { function_2() }
}
function_0(s)
</script>
</command>
In this case, "{ function_1() }" is an anonymous script that calls a function. And "=>" is the way you assign such a script to a variable. It could be any sort of script you like. For example, this is valid (though a bit stupid):
s => {
msg("Greetings, sir")
if (player.clothed) {
msg("Glad to see you are ready for the day.")
}
}
That will make "s" contain the script body you assign it. It's not a very common thing - you can just as easily create scripts as attributes and reference them the same way.
If they don't have to be functions, then you can just hang scripts off an object and pass them directly. It will invoke the script.
Delegates are just special script-like things that take parameters and/or return values. They can't hold a function as such either.