Hi all,
I'm looking for a way to register some c++ functions and objects that use pointers to manipulate data over time (think UI or animation code). Something along this lines:
void createToggle( const string &name, bool *ptr );
void createSlider( const string &name, float *ptr );
void animateValue( float *ptr, float start, float end, float time );
I've been exploring the generic convention api hoping to find something to help me and had a look on the forum, but I can't figure out how to do it.
So let's say that I have this script:
float someGlobalValue;
void main(){
addSlider( "value", someGlobalValue );
}
Is there any way I can register the function and obtain the right pointer from the c++ side? Obviously getting the address using asIScriptGeneric isn't going to work (or maybe I'm missing something). And as far as I know the only way to get this variable address would be to use something like this:
int index = module->GetGlobalVarIndexByName( name.c_str() );
if( index >= 0 ){
return mod->GetAddressOfGlobalVar( index );
}
I'm totally fine with limiting the system to work only with global variables, if it makes the whole thing easier, but I can't find a way to recover the name of the argument either (from what I can tell asIScriptFunction::GetParam returns the name of the argument as it is in the declaration, not the one passed to the function).
Any advice would be greatly appreciated! (and a solution that could work regardless of the type of the object would be totally amazing (primitive, values and references) )