The concept of 'player' confuses me ??

Posted By: dracula

The concept of 'player' confuses me ?? - 02/03/09 15:08

I understand me (my). This is similar to 'this' in C++ and ActionScript. What is 'player' ?

(please don't refer me to the manual, I wouldn't ask if it was clear)

Thanks
Posted By: Quad

Re: The concept of 'player' confuses me ?? - 02/03/09 15:12

player is just a global entity pointer.
Posted By: EvilSOB

Re: The concept of 'player' confuses me ?? - 02/03/09 15:17

To the best of my knowledge, the "player" pointer as an engine defines pointer
for use (exclusively?) with the templates and some default.c functions.
Its equivalent is simply a global declare like
Code:
ENTITY* player;

Other than that, it doesnt really DO anything, or be affected by anything.

I try to avoid using it in lite-c, because it "feels" like an old legacy
pointer...

But I will still welcome other peoples opinions.
Posted By: heinekenbottle

Re: The concept of 'player' confuses me ?? - 02/03/09 15:25

Originally Posted By: EvilSOB
To the best of my knowledge, the "player" pointer as an engine defines pointer
for use (exclusively?) with the templates and some default.c functions.
Its equivalent is simply a global declare like
Code:
ENTITY* player;

Other than that, it doesnt really DO anything, or be affected by anything.

I try to avoid using it in lite-c, because it "feels" like an old legacy
pointer...

But I will still welcome other peoples opinions.


There is nothing wrong with using "player".

Just use "player = my;" in the action of whatever entity you chose and it'll work fine as a pointer.

So it is not just exclusive with the templates and default.c, it can be used like any other pointer.
Posted By: Espér

Re: The concept of 'player' confuses me ?? - 02/03/09 15:29

XD.. as the name sais.. i use it as PLAYER pointer..

So the Script knows my hero as "player" ^^

But there´s no difference when you call the pointer "hero", or "Shit-what-a-long-pointer"
Posted By: dracula

Re: The concept of 'player' confuses me ?? - 02/03/09 15:53

Thanks, I am going to study this for a while

drac.
Posted By: Gerrit

Re: The concept of 'player' confuses me ?? - 02/03/09 22:49

You can create your own pointers:

ENTITY* enemyOne;
ENTITY* enemyTwo;

etc. player is simply a predifined pointer. You can use me (or my) in an action but if you want to do something to or with an entity outside of the action the me and my words may not work.

So you can add the above mentioned statements in an action and then use that pointer in the other parts of the game..
Hope that sheds some light on the issue
Gerrit
Posted By: Ottawa

Re: The concept of 'player' confuses me ?? - 02/04/09 00:04

Hi!

To add to this discussion.

Let's say that you have 3 entities using the same action.
If you use "my" they will all do the same action.
Now if you give each one a name (from handle)
You can call them by name and only the one called will do something specific.
The others will not.

Ottawa smile
Posted By: dracula

Re: The concept of 'player' confuses me ?? - 02/04/09 08:54

Is the following correct ?

me = my ie same thing. This pointer is like a local variable in as much that 'me' is the entity in THAT particular function.

Player is a global pointer. This is similar to a global variable in as much that 'player', once defined, can exist in any function.

Correct ??

Now I need to understand 'you'

Thanks

ps wht would help, if someone was to write a simple working example that demonstrate the use of 'me', 'player' and 'you'. If I am confused, I suspect others are too frown
Posted By: EvilSOB

Re: The concept of 'player' confuses me ?? - 02/04/09 12:38

Thats all correct, except that player is always defined, but is empty
until you point it at something.

The you pointer is a bit trickier, it is 'like' the me/my pointer but it
is changed by many engine functions. Especially c_??? functions and particles.
Look in the manual under events for more help.

Overly simplified description of YOU, but here goes
YOU is assigned by an event to be the target of an event, that is if ME gets
shot, YOU is set to the bullet-entity. If ME walkes into a tree, YOU is set
to the Tree-Entity.
YOU is assigned by particle function somehow too, Im a bity blurry but heres
how I understand it. When you call effect(...), if ME is a valid entity,
then all the particle sub-functions can see that 'parent' entity as YOU.
See, I told you the YOU was a tricky one, and theres more to it than that,
its just thats all I can remember off the top of my head...

Code:
action setup_player()   //gets assigned to an entity in WED, or through an ent_create
{
   player = me;   //me was assigned by the engine to be the entity in WED or ent_create.
   // 'player' now is pointing to that entity from WED, and ANY other 
   // function in the script will also see that entity if you say 'player'.
   //
   while(me!=NULL)  //keep running until ME is destroyed and set to NULL.
   {
      if(key_w) my.x += 5;    //move me(move player) if w pressed  etc.
      wait(1);
   }
   printf("Player is dead");
}

action Missile_Pod()   //gets assigned to MANY entities in WED, or through an ent_create
{  
   while(my.skill5<100)    //damage level
   {
      if(key_space)
      {
          //creating a new entity, it will remember ME as YOU (see missile_act)
          ent_create("missile.mdl", my.x, missile_act);
          wait(-5);   //reload time
      }
      wait(1);
   }
   //explode effects
   ent_remove(me);
}

action missile_act()
{
   // ME = the missile.mdl entiry
   // YOU = THE Missile_pod ENTITY that fired this missile.
}


Hope this helps a bit.
Posted By: dracula

Re: The concept of 'player' confuses me ?? - 02/04/09 13:32

Thanks Evil, that does help.

Lets assume I had a really stupid friend. Could this friend of mine avoid using 'player' and 'you' ?

Thanks

drac.
Posted By: heinekenbottle

Re: The concept of 'player' confuses me ?? - 02/04/09 13:42

Originally Posted By: dracula
Thanks Evil, that does help.

Lets assume I had a really stupid friend. Could this friend of mine avoid using 'player' and 'you' ?

Thanks

drac.



you would not be easy to avoid, but it could be done. It would be better if your "friend" learned how to use you.

You is a pointer that is often assigned to point to an entity as a reaction to something.

For example, if your player scans an area and finds an entity, that entity is assigned "you." Or if an entity hits another entity during c_move, that entity then becomes "you."

You is a local pointer.


And there is no real reason to avoid player, its just a pointer like any other. I believe it is defined somewhere in acknex.h. You could avoid it by making your own pointers, but it still be the same thing.
Posted By: dracula

Re: The concept of 'player' confuses me ?? - 02/04/09 15:37

My "friend" says thanks.

(I really need to mix with people of a higher IQ)

drac.
© 2024 lite-C Forums