Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, TedMar, dr_panther), 1,049 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
passing pointer to action/function? #432302
11/04/13 16:05
11/04/13 16:05
Joined: Apr 2012
Posts: 62
wrekWIRED Offline OP
Junior Member
wrekWIRED  Offline OP
Junior Member

Joined: Apr 2012
Posts: 62
I'm making an entity with multiple body parts. Basically the parent body creates it's child part.

something like this.
Code:
action body_action()
action child_action()

ENTITY* body = ent_create(body, pos, body_action);

//main body action
action body_action()
{
   //msc codes here
   code...

   //create child entity
   ent_create(part1, pos_parentoffset, child_action(me)); //point me as parent entity

   //rest of the child entity code
   code...
}

//child body action
action child_action(ENTITY* parent_ent)
{
   //msc codes here
   code...

   while(1)
   {
       //parent_ent pointing to main body
       vec_set(my.x, parent_ent.x);
       wait(1);
   }
}



now the code just throws undeclared identifier for parent_ent. Reason for each body processing it's child part it because I'm spawning multiple entities of the same type each creating it's own parts and each part updates base on it's own parent entity.

What am I doing wrong it this case?

Last edited by wrekWIRED; 11/04/13 16:08.
Re: passing pointer to action/function? [Re: wrekWIRED] #432304
11/04/13 16:15
11/04/13 16:15

M
Malice
Unregistered
Malice
Unregistered
M



You can not pass arguments in that way But YOU is always pass as the creator to the created action.

me-> create
created -> parent always is YOU in first run



Code:
//main body action
action body_action()
{
   //msc codes here
   code...

   //create child entity
   ent_create(part1, pos_parentoffset, child_action); //point me as parent entity

   //rest of the child entity code
   code...
}

//child body action
action child_action()
{
   //msc codes here
   code...
   ENTITY* parent_ENT = you;

   while(1)
   {
       //parent_ent pointing to main body
       vec_set(my.x, parent_ent.x);
       wait(1);
   }
}



EDIT___

Last edited by Malice; 11/04/13 16:17.
Re: passing pointer to action/function? [Re: ] #432305
11/04/13 16:25
11/04/13 16:25
Joined: Apr 2012
Posts: 62
wrekWIRED Offline OP
Junior Member
wrekWIRED  Offline OP
Junior Member

Joined: Apr 2012
Posts: 62
I see. My child action actually have multiple var parameters aside for the main body pointer it self. How do I pass parameters to each child actually call?

Re: passing pointer to action/function? [Re: wrekWIRED] #432306
11/04/13 16:43
11/04/13 16:43
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Just set the arguments with skills (you have to wait 1 frame until they were set in the child function)
Eaisiest way indeed.

Re: passing pointer to action/function? [Re: Ch40zzC0d3r] #432307
11/04/13 16:56
11/04/13 16:56
Joined: Apr 2012
Posts: 62
wrekWIRED Offline OP
Junior Member
wrekWIRED  Offline OP
Junior Member

Joined: Apr 2012
Posts: 62
I was hoping to save skills for other purpose. But I don't think I can use them all anyway.

Thanks guys.


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

Gamestudio download | chip programmers | 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