Panel Over Entity

Posted By: iam_ufo973

Panel Over Entity - 11/16/08 08:54

Hi
After a long time i started using 3dgs again. but facing a problem in my script where i want to display the value of a variable(Ex Health) over an entity. Can somebody help me please.
Thanx
Posted By: jigalypuff

Re: Panel Over Entity - 11/16/08 09:09

this was in one of the aum magazines, try looking in those
Posted By: iam_ufo973

Re: Panel Over Entity - 11/16/08 09:10

which one?
Posted By: iam_ufo973

Re: Panel Over Entity - 11/16/08 10:02

Ok i got the script to show global variable over entity but what about local variables is there any way you can show local variables. Example there is only one action attached to all enemies and you want to display there health over there head? Any Idea?
Posted By: Helghast

Re: Panel Over Entity - 11/16/08 10:36

make temporary global variables, which you keep swapping with local variables..?
Posted By: Uhrwerk

Re: Panel Over Entity - 11/17/08 02:27

Local variables can't be shown in panels for good reasons: They are only valid local and therfore it can neither be guaranteed, that at least any of these local variables exists, nor can be distinguished between multiple instances of the same local variable. So Helghast's suggestion is the way to go.
Posted By: Xarthor

Re: Panel Over Entity - 11/17/08 18:45

maybe use text_draw for local vars (skills)?

This may work:
- define a local string (outside the while loop of the enemy)
- get the world coordinates of the position you want the text to be shown at
- translate the coordinates to screen coordinates using vec_to_screen
- inside the while loop, translate the skill to string using str_for_num function
- draw the sting using draw_text and the screen coordinates plus the string
Posted By: iam_ufo973

Re: Panel Over Entity - 11/19/08 13:33

Xarthor it works perfect thank you very much. it was almost impossible to show local variables over entities but you solved it in a very easy way laugh
But the str_for_num doesn't work it gives error can you give me an small example please.
Posted By: Xarthor

Re: Panel Over Entity - 11/19/08 19:45

Code:
action enemy_act()
{
  VECTOR my_pos;
  STRING* my_health;

  while(me)
  {
    if(vec_for_screen(my.x,camera))
    {
      vec_set(my_pos,my.x);
      my_pos.z += 50; // z-offset
      vec_to_screen(my_pos,camera);
      str_for_num(my_health,my.skill22); // replace my.skill22 with your health skill
      draw_text(my_health,my_pos.x,my_pos.y,vector(255,255,255));
    }
    wait(1);
  }
}

Attention: not tested
Posted By: iam_ufo973

Re: Panel Over Entity - 11/20/08 08:23

It gives the following error!


Posted By: Xarthor

Re: Panel Over Entity - 11/20/08 08:54

Yes thats because you are using C-Script and my code is Lite-C.
Try this one instead:
Code:
action enemy_act
{
  var my_pos[3];
  string my_health;

  while(me)
  {
    if(vec_for_screen(my.x,camera))
    {
      vec_set(my_pos,my.x);
      my_pos.z += 50; // z-offset
      vec_to_screen(my_pos,camera);
      str_for_num(my_health,my.skill22); // replace my.skill22 with your health skill
      draw_text(my_health,my_pos.x,my_pos.y,vector(255,255,255));
    }
    wait(1);
  }
}

Posted By: jigalypuff

Re: Panel Over Entity - 11/20/08 12:31

should`nt it be player.x not playerx?
Posted By: Helghast

Re: Panel Over Entity - 11/25/08 11:47

dont save the script as .WDL, save it as a .C file instead!

that'll make it work ^_^


regards,
Posted By: Ottawa

Re: Panel Over Entity - 11/28/08 00:18

Hi!

We were looking at a similar problem under "E1513....by ngisiger"
The solution (2 of them)

STRING* my_health;

was to remove the * or place this line outside the ACTION.

Hope this helps smile

I've looked at the manual and found the answer
to this situation under

beginner's mistakes

Mistake 4: Using pointers the wrong way

Good reading smile

Ottawa
© 2024 lite-C Forums