Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-18-2010, 09:43 PM
brasilboy109 brasilboy109 is offline
Exorian
Join Date: Aug 2010
Posts: 5
brasilboy109 is on a distinguished road
Health for HUD

everytime i get hurt nothing happenes but when i update the scripts it shows the correct ammount of hearts.... Idk how to update it

any ideas to make it better and or be able to update the health?


PHP Code:
// Scripted by *brasilboy109
//#CLIENTSIDE
function onCreated(){
timeout=0.05;

/* HEALTH SCRIPT V1.0 MADE BY BRASILBOY109 */
/* IMGAES MADE BY PAVILION75 */
}

function 
onTimeout(){
if(
player.hearts>=0.5){
  
showimg(500,"pavilion75-red-heart-half.png",1000,25);
  
changeimgzoom(500,1);
  
changeimgvis(500,4);
}

//health 1 image
if(player.hearts>=1){
  
showimg(501,"pavilion75-red-heart.png",1000,25);
  
changeimgzoom(501,1);
  
changeimgvis(501,4);
}


//health 1.5 image
if(player.hearts>=1.5){
  
//health 0.5 image
  
showimg(502,"pavilion75-red-heart-half.png",1050,25);
  
changeimgzoom(502,1);
  
changeimgvis(502,4);
}

//health 2 image
if(player.hearts>=2){
  
//health 0.5 image
  
showimg(503,"pavilion75-red-heart.png",1050,25);
  
changeimgzoom(503,1);
  
changeimgvis(503,4);
}
if(
player.hearts>=2.5){
  
//health 0.5 image
  
showimg(504,"pavilion75-red-heart-half.png",1100,25);
  
changeimgzoom(504,1);
  
changeimgvis(504,4);
}
if(
player.hearts>=3){
  
//health 0.5 image
  
showimg(505,"pavilion75-red-heart.png",1100,25);
  
changeimgzoom(505,1);
  
changeimgvis(505,4);

}if(
player.hearts>=3.5){
  
//health 0.5 image
  
showimg(506,"pavilion75-red-heart-half.png",1150,25);
  
changeimgzoom(506,1);
  
changeimgvis(506,4);
}if(
player.hearts>=4){
  
//health 0.5 image
  
showimg(507,"pavilion75-red-heart.png",1150,25);
  
changeimgzoom(507,1);
  
changeimgvis(507,4);
}if(
player.hearts>=4.5){
  
//health 0.5 image
  
showimg(508,"pavilion75-red-heart-half.png",1200,25);
  
changeimgzoom(508,1);
  
changeimgvis(508,4);
}if(
player.hearts>=5){
  
//health 0.5 image
  
showimg(509,"pavilion75-red-heart.png",1200,25);
  
changeimgzoom(5009,1);
  
changeimgvis(509,4);
}if(
player.hearts>=5.5){
  
//health 0.5 image
  
showimg(510,"pavilion75-red-heart-half.png",1250,25);
  
changeimgzoom(510,1);
  
changeimgvis(510,4);
}if(
player.hearts>=6){
  
//health 0.5 image
  
showimg(511,"pavilion75-red-heart.png",1250,25);
  
changeimgzoom(511,1);
  
changeimgvis(511,4);
  }
  
timeout=0.05;
  } 
Reply With Quote
  #2  
Old 09-18-2010, 10:16 PM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
lol.. well that's one way to do it..

To simply answer your first question, you have to hide the images as well.

hideimg(index); to hide a single showimg.
or
hideimgs(min index, max index); to do a range.

Other than that, your scripting is extremely distasteful, but I suppose it'll work and I don't care to tell you much more than that.

Also, use setTimer(.05); instead of timeout=.05;

Here's a hint for making it better:
PHP Code:
function onPlayerEnters() {
  
onTimeOut();
}
function 
onTimeOut() {
  
setTimer(.05);
  
hideimgs(300this.images);  //Clear the old images
  
this.images 300;  //Start a new image counter
  
temp.maxHearts 5//Max heart count
  
for (temp.i=0;temp.i<temp.maxHearts;temp.i++) { //Loop through the possible heart values
    
if (temp.i>player.hearts) break; //Dont exceed the players heart count
    
this.images++; //"Allocate" a new image
    
showimg(this.images"block.png"32+temp.i*4832); //Draw the heart at the proper position.
    
findimg(this.images).layer 5//Screen-relative layer
  
}

Ya. If something doesn't work or whatever, I did type this on my phone.. But I hope you appreciate that little snippet.
}

Last edited by 12171217; 09-18-2010 at 10:26 PM..
Reply With Quote
  #3  
Old 09-18-2010, 11:48 PM
brasilboy109 brasilboy109 is offline
Exorian
Join Date: Aug 2010
Posts: 5
brasilboy109 is on a distinguished road
Quote:
Originally Posted by 12171217 View Post
lol.. well that's one way to do it..

To simply answer your first question, you have to hide the images as well.

hideimg(index); to hide a single showimg.
or
hideimgs(min index, max index); to do a range.

Other than that, your scripting is extremely distasteful, but I suppose it'll work and I don't care to tell you much more than that.

Also, use setTimer(.05); instead of timeout=.05;

Here's a hint for making it better:
PHP Code:
function onPlayerEnters() {
  
onTimeOut();
}
function 
onTimeOut() {
  
setTimer(.05);
  
hideimgs(300this.images);  //Clear the old images
  
this.images 300;  //Start a new image counter
  
temp.maxHearts 5//Max heart count
  
for (temp.i=0;temp.i<temp.maxHearts;temp.i++) { //Loop through the possible heart values
    
if (temp.i>player.hearts) break; //Dont exceed the players heart count
    
this.images++; //"Allocate" a new image
    
showimg(this.images"block.png"32+temp.i*4832); //Draw the heart at the proper position.
    
findimg(this.images).layer 5//Screen-relative layer
  
}

Ya. If something doesn't work or whatever, I did type this on my phone.. But I hope you appreciate that little snippet.
}
Yea thanks that helped alot.
Reply With Quote
  #4  
Old 09-18-2010, 11:51 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
You should use
PHP Code:
function onCreated() { 
  
onTimeOut(); 

instead of
PHP Code:
function onPlayerEnters() { 
  
onTimeOut(); 

Timeouts don't cancel when you enter a level.
__________________
Reply With Quote
  #5  
Old 09-19-2010, 12:12 AM
MattKan MattKan is offline
the KattMan
Join Date: Aug 2010
Location: United States
Posts: 1,325
MattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to behold
Send a message via AIM to MattKan
How does he make it so that the hearts appear in the top right corner of the screen for all screen sizes?
Reply With Quote
  #6  
Old 09-19-2010, 12:50 AM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Quote:
Originally Posted by MattKan View Post
How does he make it so that the hearts appear in the top right corner of the screen for all screen sizes?
You can use function GraalControl.onResize and use the coordinates (x and y) you always want your image to show at.
Reply With Quote
  #7  
Old 09-19-2010, 01:01 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by MattKan View Post
How does he make it so that the hearts appear in the top right corner of the screen for all screen sizes?
Relative positioning using screenwidth and screenheight. I.e:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
// Centered Block
  
with (findimg(200)) {
    
screenwidth 2;
    
screenheight 2;
    
image "block.png";
    
layer 4;
  }
  
// Top Right Block
  
with (findimg(201)) {
    
screenwidth 64;
    
64;
    
image "block.png";
    
layer 4;
  }
  
// Bottom Right
  
with (findimg(202)) {
    
screenwidth 64;
    
screenheight 64;
    
image "block.png";
    
layer 4;
  }

__________________
Quote:
Reply With Quote
  #8  
Old 09-19-2010, 01:27 AM
brasilboy109 brasilboy109 is offline
Exorian
Join Date: Aug 2010
Posts: 5
brasilboy109 is on a distinguished road
so it'd be like???

PHP Code:
  //player hearts 0.5
  
showimg(201,"pavilion75-red-heart-heart.png",850,25);
  
changeimgzoom(201,1);
  
changeimgvis(201,4);
    
with (findimg(201)) { 
    
screenwidth 64
    
64
    
image "pavilion-red-heart.png"
    
layer 4
  } 
???
Reply With Quote
  #9  
Old 09-19-2010, 03:07 AM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
Quote:
Originally Posted by Soala View Post
You can use function GraalControl.onResize and use the coordinates (x and y) you always want your image to show at.
Here's an example. ( I couldn't understand how to do it when I first started scripting) =
PHP Code:

function GraalControl.onReSize()
{

  
findimgID).VAL;
  
findimgID).VAL;


Quote:
Originally Posted by brasilboy109 View Post
so it'd be like???

PHP Code:
  //player hearts 0.5
  
showimg(201,"pavilion75-red-heart-heart.png",850,25);
  
changeimgzoom(201,1);
  
changeimgvis(201,4);
    
with (findimg(201)) { 
    
screenwidth 64
    
64
    
image "pavilion-red-heart.png"
    
layer 4
  } 
???
an easier way would be
PHP Code:
//player hearts 0.5
  
with (findimg(201))
  { 
    
layer 4
    
screenwidth 64
    
64
    
image "pavilion-red-heart.png"
    
zoom 1;    
  } 
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote
  #10  
Old 09-19-2010, 03:50 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
it's been a while, but are screenwidth and GraalControl.width essentially the same thing? or does screenwidth/height always return the monitor resolution regardless of the size of the game window?
__________________

Last edited by salesman; 09-19-2010 at 04:03 PM..
Reply With Quote
  #11  
Old 09-19-2010, 04:03 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by salesman View Post
it's been a while, but are screenwidth and GraalControl.width essentially the same thing? or do screenwidth/screenheight always return the monitor resolution regardless of the size of the game window?
It's possible they are the same thing, but I've been using GraalControl.width ever since we got it. Maybe screenwidth returns the width of the Graal window (GraalControl possibly being smaller). Not sure about that though.
Reply With Quote
  #12  
Old 09-19-2010, 04:09 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Crow View Post
It's possible they are the same thing, but I've been using GraalControl.width ever since we got it. Maybe screenwidth returns the width of the Graal window (GraalControl possibly being smaller). Not sure about that though.
GraalControl.width/height usually refer to the size of the Graal window unless you have changed the width/height of the GraalControl so that you can draw something outside of the GraalControl but still in the main Graal window (by adding child controls to GUIContainer), i.e. a chat box at the bottom of the screen that doesn't overlay on the level viewport.
__________________
Skyld
Reply With Quote
  #13  
Old 09-20-2010, 03:03 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
I usually prefer using gui controls to make guis and just creating custom profiles for each of the controls I use.

edit: http://wiki.graal.net/index.php/Crea...iControls_List

Last edited by Cubical; 09-20-2010 at 03:06 AM.. Reason: http://wiki.graal.net/index.php/Creation/Dev/Script/Client/GuiControls_List
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.