Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Besh on Fri 02/12/2005 18:08:11

Title: About GetScriptFunctionAddress (SOLVED)
Post by: Besh on Fri 02/12/2005 18:08:11
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))
Title: Re: about GetScriptFunctionAddress
Post by: strazer on Fri 02/12/2005 19:39:32
I don't get it. What do you mean by 'address'? What do you want to do?
Title: Re: about GetScriptFunctionAddress
Post by: Pumaman on Fri 02/12/2005 19:42:06
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.
Title: Re: about GetScriptFunctionAddress
Post by: Besh on Sat 03/12/2005 09:21:57
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 !!
Title: Re: about GetScriptFunctionAddress
Post by: Pumaman on Sat 03/12/2005 12:22:46
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"
Title: Re: about GetScriptFunctionAddress
Post by: Besh on Mon 05/12/2005 09:18:10
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 !!