how do you display variable to a panel

Posted By: jpxtreme

how do you display variable to a panel - 01/17/11 10:24

i know this is a very basic question but I cannot seem to figure it out.

I have a panel in which I want to display the value of my variable viol_cntr. This variable counts how many violations the player has made through touching or going to an object.

I've tried to solve it using digits but the value won't increment to 1 it directly goes to 9. Maybe I've done it wrong please help me figure it out. Thanks!

PANEL* violations =
{
digits (210, 100, 1, *, 1, viol_cntr);
flags = VISIBLE;
}

function hit_event()
{
set(damageproperty,VISIBLE);
wait(-3);
reset(damageproperty,VISIBLE);
viol_cntr += 1;
}

action viol_damageprop()
{
my.emask |= ENABLE_IMPACT;
my.event = hit_event;
}
Posted By: Ascalon

Re: how do you display variable to a panel - 01/17/11 10:42

you need to set viol_cntr as a global variable

var viol_cntr;

that should work
Posted By: jpxtreme

Re: how do you display variable to a panel - 01/17/11 11:42

i already set it to var viol_cntr = 0;

but when i hit the object it won't add plus 1 instead it directly goes to 9. i don't know why is this happening.
Posted By: Superku

Re: how do you display variable to a panel - 01/17/11 13:18

It does not go to 9 directly, it probably goes way beyond 9. You only display a one digit number in your panel, change the definition as follows:

PANEL* violations =
{
digits (210, 100, 3, *, 1, viol_cntr);
flags = VISIBLE;
}

You will need to change the event function, too, because it is called at least once per frame when the player touches the object.

function hit_event()
{
my.event = NULL;
set(damageproperty,VISIBLE);
wait(-3);
reset(damageproperty,VISIBLE);
viol_cntr += 1;
my.event = hit_event;
}
Posted By: jpxtreme

Re: how do you display variable to a panel - 01/17/11 13:31

yehey! you solved my problem superku. thank you so much! how can i ever thank you. hope you'll be there for my future problems. thanks again!
© 2024 lite-C Forums