Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,459 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ent given as argument -> set skills? #110064
01/30/07 19:02
01/30/07 19:02
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Hi!

Im using a simple code, such as this:
Code:

action bullet
{
....
myFunction(you)
....
}

function myFunction(ent)
{
while(ent) // <- no problem, works
{
if(ent._fireflag) // <- here I get error when compiling: unknown _arg1 parameter!
....




If I use you=ent; before and then try to set or read skills everything works fine.
If I just check if the ent exist if(ent) I get no errors


Can anyone please tell me what's wrong with my code?
Or how I can solve it.


nipx

Re: ent given as argument -> set skills? [Re: nipx] #110065
01/30/07 20:40
01/30/07 20:40
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
Try this:

Code:

action bullet
{
....
myFunction(you)
....
}

function myFunction(ent)
{
ent = my;
while(my)
{
if(my._fireflag)
....




Re: ent given as argument -> set skills? [Re: demiGod] #110066
01/30/07 21:12
01/30/07 21:12
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
I know about me but I use me also in the same function for the the entity itself.

Its a bit more complex and I explained badly, maybe I should move to the scripting or MP section...

Anyway:
The player joins the game-> create a global ent on the server, that just send it's skills to every client -> on every client(means local) a dummy is created by the global ent -> this dummy moves with the skills given by the global ent

So the dummy-ent can move it needs to read it's "mother" ent's skill.
Because the ent was created by the global ent, you is set to it!

==>>
Code:

action aLocalDummy
{
//you is pointer to mother ent!!
while(you)
{
//read the skills given by player input
vecMovement.x = you._movement_x;
.....
.....
//now move me with the vec "given" by you (mother ent)
c_move(me, vecMovement...
.....
}
}



Works fine when my.passable=on; because it doesnt perform any collision detection then. When passable=off; you is set to an other ent
-> you isnt the pointer to my "mother" ent anymore-> I can throw away my code


Hope you got it and can help me now



nipx

Re: ent given as argument -> set skills? [Re: nipx] #110067
01/31/07 10:08
01/31/07 10:08
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
Sorry but i cant help much more with MP questions, maybe in that forum you will have some luck.
However and considering your brief description i thing you will need a temporary pointer in your scheme..

Re: ent given as argument -> set skills? [Re: nipx] #110068
01/31/07 10:33
01/31/07 10:33
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Be careful: when you use something like while (you), "YOU" should be a singleton pointer! If other entities (more parent entities) are assigning to the you pointer, you might get wrong results.

I suggest doing it that way:

  • when the parent creates the child, save directly after ent_create the parent-child association by storing the parent pointer into the child. E.g you = ent_create(...); you.skill10 = my;
  • as replacement for your main loop of the child object, just place a while loop with (1) argument (infinite loop)
  • in the end of the loop before the wait(1); just proof at first if the parent skill is != 0. If it is ==0, the child is a newborn without the parent association. You can circumvent this by waiting one frame before the main loop of your child starts. If it is != 0, a pointer has been stored in it.
  • fill it into an entity pointer: you = my.skill10; Now proof you against NULL to see wether the parent entity is present or not. If it is == NULL, the association exists, but no target in the memory. So, the parent is lost (or removed). If == NULL, you can branch and use break; to leave the loop. If YOU != NULL, the parent entity is available and you can proceed on this.


Thats all. This is a very defensive way, because you store in each child the link to the parent. YOU is a very generic pointer. You should NOT use it in general for constant or global references and associations.

Cheers,
Christian

Last edited by HeelX; 01/31/07 10:36.
Re: ent given as argument -> set skills? [Re: HeelX] #110069
02/01/07 19:54
02/01/07 19:54
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Quote:

storing the parent pointer into the child. E.g you = ent_create(...); you.skill10 = my;




This is possible?? I've just read about storing strings in skills but pointers too?

Cool I'll follow your suggestions, so it will be more or less easy. (I hope )


Thx a lot -> *5 stars*


nipx


edit: for speed reasons:
Is it faster to set (when required) you to the motherEnt

or

always use my._motherEnt (global ent stored in this skill) instead of seting you to it

?


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