Advertisement

Query script function for default argument string and provide it back via script context

Started by April 29, 2014 01:54 AM
0 comments, last by WitchLord 10 years, 7 months ago

Now that it's possible to ask asCScriptFunction::GetParam() for the default argument of a param, if any, is it possible to make use of this to fill in default parameters when calling a script function from C++?

For example, in script I have:


void foo(int a, bool b = true)

From the application side, I'd like to be able to execute "foo(int)" and allow 'b' to use the default param. Is it feasible to do this with the current API?

I'm trying to reconcile the fact that the default value is returned as a string - what if the param type is not a string? Or, if I set the 0th argument via the script context, will the 1th take the default value?

Thank you.

The default argument is evaluated by the compiler, that's why it is a string. It's only returned in GetParam for informational purpose, e.g. for display in an IDE or for intellisense.

I didn't really mean for the application to attempt to evaluate the expression for use when calling the function from the application, but I suppose you might be able to do so with ExecuteString().

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement