|
#Define problem
#347828
11/19/10 20:06
11/19/10 20:06
|
Joined: Apr 2010
Posts: 23
GieskeBon
OP
Newbie
|
OP
Newbie
Joined: Apr 2010
Posts: 23
|
Hi all,
I got a problem. Here's the code:
#define Health skill10 Health = 100; #define Mana skill11 Mana = 50;
PANEL* skill_panel = {
pos_x = 0; pos_y = 0; digits(50, 25, "Health = %0.f", *, 1, Health); digits(50, 50, "Mana = %0.f", *, 1, Mana);
flags = OVERLAY | SHOW; }
function main()
{ video_mode = 9; screen_color.blue = 180; mouse_mode = 4; }
The problem is when I start the program, Health and Mana are still 0. How does this come?
Greetings Dave
|
|
|
Re: #Define problem
[Re: GieskeBon]
#347834
11/19/10 20:52
11/19/10 20:52
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
You are doing wrong dude, cause you are using 'defines' you need to define exactly what entity has its health set to 100 and mana to 100, like this:
#define Health skill1
#define Mana skill2
PANEL* skill_panel =
{
digits(50,25,"Arial#24bi",1,player.skill1); // SHOW PLAYERS HEALTH
digits(50,50,"Arial#24bi",1,player.skill2); // SHOW PLAYERS MANA
flags = SHOW; // You do not need to use OVERLAY for digits!!!
}
function handle_camera()
{
vec_set(camera.x,vector(my.x - 150,my.y,my.z + 30));
vec_rotate(camera.pan,my.pan);
}
action hero() // PLAYERS ACTION
{
player = my; // I'm the player
my.Health = 100; // my health is 100
my.Mana = 100; // my mana is 100
while(my.Health > 0) // while I'm alive
{
handle_camera(); // call camera's function
wait(1);
}
}
function main()
{
fps_max = 75; // limit FPS at 75
video_mode = 9;
load_level(NULL); // load empty level
ent_create("guard.mdl",nullvector,hero); // put default guard model into the projects folder
}
You can not define it like this:
#define Health skill10 Health = 100;
#define Mana skill11 Mana = 50;
You can only define vars like that!!! Example:
var Health = 100;
var Mana = 50;
And in PANELS you need to call skills, not the define's name! Example:
PANEL* skill_panel =
{
//RIGHT!!
digits(50,25,"Arial#24bi",1,player.skill1); // SHOW PLAYERS SKILL1
//WRONG!!!
digits(50,25,"Arial#24bi",1,player.health);
flags = SHOW;
}
Good luck. And read manual carefully.
|
|
|
Re: #Define problem
[Re: 3run]
#347836
11/19/10 21:05
11/19/10 21:05
|
Joined: Apr 2010
Posts: 23
GieskeBon
OP
Newbie
|
OP
Newbie
Joined: Apr 2010
Posts: 23
|
Hey 3Run, Thanks for the quick reply. I found this at the manual under the 'skills' examples. Thats the reason why I did: #define Health skill10 Health = 100; About the PANEL*, I didn't know that! Even after reading it. But I will read it read it more carefully next time I will try it out. Thanks again
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|