Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 16,302 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Store function pointer in skill #190060
03/24/08 00:16
03/24/08 00:16
Joined: Feb 2008
Posts: 39
R
RicheyMB2 Offline OP
Newbie
RicheyMB2  Offline OP
Newbie
R

Joined: Feb 2008
Posts: 39
I would like to be able to store a function in the skill of my entity. For example you may have a function called rotate which you store as skill99 then call rotate using skill99.

Basically I would like to do the following

my.skill99 = myFunctionCalledRotate;

Then within the action for the entity do

function myFunction();
myFunction = my.skill99;
myFunction();

I hope what I am trying to do makes sense. I will try to explain this better if need be.

Re: Store function pointer in skill [Re: RicheyMB2] #190061
03/24/08 04:48
03/24/08 04:48
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Maybe give it a try and see if it works. Shouldn't be a waste of time if you need that function anyway.


Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: Store function pointer in skill [Re: Nidhogg] #190062
03/24/08 08:45
03/24/08 08:45
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Code:
void myFunc ()
{
error("myFunc");
}

//save function pointer
my.skill1 = (void*)myFunc;

//create entity with function pointer
ent_create("bla.mdl", nullvector, (void*)my.skill1);

//execute function pointer
void (*func)(void);
func = (void*)my.skill1;
func();



Re: Store function pointer in skill [Re: HeelX] #190063
03/25/08 15:00
03/25/08 15:00
Joined: Feb 2008
Posts: 39
R
RicheyMB2 Offline OP
Newbie
RicheyMB2  Offline OP
Newbie
R

Joined: Feb 2008
Posts: 39
Thanks that was exactly what I was looking for you're very helpful.

Could you explain what the line void(*func)(void) is doing - it's way above my current skill level.

Re: Store function pointer in skill [Re: RicheyMB2] #190064
03/25/08 17:21
03/25/08 17:21
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
It defines a function pointer named "func" with the return value void and the parameter void. If you e.g. call a function which returns an int, it would be

int (*func)(void);

and it works like that:

int aabbccdd = func();


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1