Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 11/19/25 10:10
MRC.c and WFO
by 11honza11. 11/18/25 15:22
webGL
by Ice2642. 11/17/25 21:27
Camera always moves upwards?
by NeoDumont. 11/17/25 09:56
Future of ZorroHFT
by TipmyPip. 11/16/25 13:52
COT Download with Quandl does not work
by Petra. 11/15/25 09:35
Training with the R bridge does not work
by Petra. 11/15/25 09:31
Zorro 2.70
by jcl. 11/15/25 08:43
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, VoroneTZ, TipmyPip), 32,640 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
SkinnyApe, tritom, sheliepaley, Blueguy, blobplayintennis
19179 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