Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
1 registered members (AndrewAMD), 599 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Entity Action with parameters #322327
05/06/10 04:52
05/06/10 04:52
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Im not sure if this is possible... all the examples of action within ent_create i have found dont even have brackets()

Is it possible for an action to have parameters?
Something like this:
Code:
EntityPointer = ent_createlocal("Car.mdl",Position,Action_With_Parameters(PointerParameter,IntParameter));



If it is possible... Would that be the correct way of doing it?

EDIT:
I found this in the manual,
Quote:
Actions are another special kind of functions. They don't have parameters and don't return a value, but will appear in the action pop-up list in WED's entity property panel. So actions can be assigned to entities through WED, and are automatically executed after level loading. Action names are limited to 20 characters. Besides that, there is no difference between functions and actions.
it seems that it is not possible to pass parameters to an action.
If it is not possible... Does anyone know a workaround for my problem so an entity function can work with parameters?

Last edited by Carlos3DGS; 05/06/10 05:12.

"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: Entity Action with parameters [Re: Carlos3DGS] #322332
05/06/10 07:02
05/06/10 07:02
Joined: Feb 2005
Posts: 3,687
Hessen, Germany
T
Tempelbauer Offline
Expert
Tempelbauer  Offline
Expert
T

Joined: Feb 2005
Posts: 3,687
Hessen, Germany
Quote:

Does anyone know a workaround for my problem so an entity function can work with parameters?

yes. you can use the skills (entity.skill1, entity.skill2, ...) of an entity. this are parameters that can be used (for healthpoints for example).
you could assign them after creation. if you need to wait until all params are set, you could use a while-loop that blocks the execution of the action until the params are passed.
you can use these skill-parameters for passing integers or pointers of any struct.

take a look in the manual for further information: http://www.conitec.net/beta/aentity-skill.htm

hope it helps

Re: Entity Action with parameters [Re: Tempelbauer] #322347
05/06/10 09:39
05/06/10 09:39
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
INIT_MOD(ENTITY* my_ent,par_1,par_2)
{
my = my_ent;
my.x = 200;
...
}

you = ent_create("my_model.mdl",my_pos,NULL);
INIT_MOD(you,parameter_1, parameter_2...);

or you can also directly after ent_create change parameters with you.x...

Re: Entity Action with parameters [Re: Tempelbauer] #322357
05/06/10 10:53
05/06/10 10:53
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Lets see if I understood this right...

Entity skills can hold pointers to other entities?
So would this code be correct?
EXAMPLE:

Code:
void Prepare_Entity(ENTITY*Created, ENTITY* PassedPointer, int PassedInt) //function called to pass parameters to entity
{
   Created.Skill1=PassedPointer; //passing a pointer to the new entity
   Created.skill2=PassedInt; //passing an int to the new entity
   set(Created,FLAG1); //tell the entity its parameters are loaded
}

action Entity_Action()
{
   while(1)
   {
      if(my.flag1!=0) //waits until flag 1 is set to know parameters have been passed to my skills
      {
         ...
         Do something with my awesome skill1 & skill2 that cointain a pointer to awesomeness and an awesome int lol;
         ...
      }
      wait(1);
   }
}

void main()
{
   ENTITY* NewEntity;
   ENTITY* ImportantEntity;
   int AwesomeInt;
   ...
   NewEntity=ent_create("Car.mdl",nullvector,Entity_Action); //create entity
   Prepare_Entity(NewEntity,ImportantEntity,AwesomeInt); //pass pointer and parameters to entity
   ...
}


If I understood you correctly and that code would achieve what I need it would be great news! A nice fix for my problem to be able to pass parameters to action functions with a clean workaround.


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: Entity Action with parameters [Re: Carlos3DGS] #322367
05/06/10 13:52
05/06/10 13:52
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
"Entity skills can hold pointers to other entities?"
No, not directly as they are two different kinds of objects. Nevertheless you can achieve the same with "handle":

my.skill1 = handle(you);


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Entity Action with parameters [Re: Superku] #322370
05/06/10 14:20
05/06/10 14:20
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Thankyou very much for your help wink

So I set the pointer into the skill using my.skill1 = handle(you); but how do I retrieve the pointer from skill in the action function?

EDIT:
Sorry for posting before searching "handle" in the manual
For anyone else searching this thread in the future I found this:
Quote:
EXAMPLE
if(entity)
{
my.skill48 = handle(entity); // store entity pointer
}
you = ptr_for_handle(my.skill48); // restore YOU;



Last edited by Carlos3DGS; 05/06/10 14:24.

"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: Entity Action with parameters [Re: Carlos3DGS] #322375
05/06/10 15:02
05/06/10 15:02
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
I will risk testing your patience with one more question...

Can I create an array of entities like this?
Quote:
ENTITY* List[4];

for(x=0;x<=3;x++)
{
List[x]=ent_create("Car.mdl",position,Action_Car);
}


And access the pointers directly like this?
Quote:
for(x=0;x<=3;x++)
{
List[x].skill1=x;
}


Is that possible? Would that method work?


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: Entity Action with parameters [Re: Carlos3DGS] #322378
05/06/10 15:09
05/06/10 15:09
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Yes you can.

Also it is really possible to store pointers to entities in skills. Like this:
my.skill1 = you;

To access this pointer, you will need a cast, like this:
dosomething((ENTITY*)my.skill1);

Re: Entity Action with parameters [Re: Lukas] #322379
05/06/10 15:38
05/06/10 15:38
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Can you give me a simple example of the "cast"?


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: Entity Action with parameters [Re: Lukas] #322381
05/06/10 15:40
05/06/10 15:40
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Yes, you can store Pointers directly without handle (a Pointer is nothing else a number). But if you want save and load your Game then this Pointers are no more the same. If you use handle and ptr_for_handle then you can save / load without problems, the handle is always the same.

Last edited by Widi; 05/06/10 15:46.
Page 1 of 3 1 2 3

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