About GetScriptFunctionAddress (SOLVED)

Started by Besh, Fri 02/12/2005 18:08:11

Previous topic - Next topic

Besh

How Can I get, if it's possible, the address of a member function? ??? (e.g. Character.LockView())
and the address of a user function? ??? (e.g. myfunc(int, int))
"Spread our codes to the stars,
You can rescue us all"
- Muse

strazer

I don't get it. What do you mean by 'address'? What do you want to do?

Pumaman

To get the address of the OO functions, use "Character::LockView", but remember to pass the Character pointer in as the first parameter.

You cannot get the address of a user function since they are script and not native code, but you can call one with the QueueRunScriptFunction command.

Besh

I can't get the address of "Character::LockView", the returned pointer is NULL !!


code for script function:

// PlaySound script function
void (*sfPlaySound)(int);

// init PlaySound script function
sfPlaySound = ((void(*)(int)) pEngine->GetScriptFunctionAddress("PlaySound"));

// use PlaySound script function
sfPlaySound(3);

This works fine!!


but for OO function, I've try:

// cLockView script function
void (*sfcLockView)(AGSCharacter*, int);

// init sfcLockView script function
sfcLockView = ((void(*)(AGSCharacter*, int)) pEngine->GetScriptFunctionAddress("Character::LockView"));

sfcLockView is NULL !!
"Spread our codes to the stars,
You can rescue us all"
- Muse

Pumaman

Oh sorry, for member functions you have to add ^ then the number of parameters it takes. So for LockView, you'd want:

"Character::LockView^1"

Besh

Code for OO function (eg: Character.LockView(int)):

// cLockView script function
void (*sfcLockView)(AGSCharacter*, int);

// init cLockView script function
sfcLockView = ((void(*)(AGSCharacter*, int)) pEngine->GetScriptFunctionAddress("Character::LockView^1"));

// use of cLockView script function
sfcLockView(character_pointer, view_number);

Now all works fine,Ã,  Ã, ;D
Thank you very Much !!
"Spread our codes to the stars,
You can rescue us all"
- Muse

SMF spam blocked by CleanTalk