|
Programmer Wiefel
Registered User
Join date: 8 Mar 2008
Posts: 9
|
07-05-2008 05:54
Hi,
Im making a robot with a health bar displayed above its head as " HP[||||||||||] ", every line displayed as a 10th of its health. To make this run, I created the whole health part of the script (Like damage from velocity, etc) then I have this:
if(health=10000-9001) { llSetText("HP[||||||||||]", <0, 1.0, 0>, 1.0); }
I want the set text to display whenever the health is set in between 10,000 and 9001, instead of subtracting those numbers like it seems to be doing. How can I do this?
ty
|
|
Tabliopa Underwood
Registered User
Join date: 6 Aug 2007
Posts: 719
|
07-05-2008 07:26
With C-like syntax "equals" and "is equal to" aren't expressed the same way unlike say BASIC.
if x = 1 then language = "BASIC" end if
if (x == 1) { language = "C"; }
|
|
Salvador Nakamura
http://www.sl-index.com
Join date: 16 Jan 2007
Posts: 557
|
07-05-2008 07:49
i also think you might want to do something like this; myhealth=health/1000 hp_string="HP["; health_string="|"; for(i=1; i < myhealth; ++i) { health_string = health_string+"|"; } hp_string=hp_string+health_string+"]";
.
_____________________
SL-Index , providing an easy and affordable start in secondlife Rentals, Easy Setup Scripts, Freebies & Value Boxes www: http://sl-index.com HQ: http://slurl.com/secondlife/Immintel/212/14/100
|
|
Nexii Malthus
[Cubitar]Mothership
Join date: 24 Apr 2006
Posts: 400
|
07-05-2008 10:19
It would be best to handle a small function which you can call to update the hover text health display: UpdateHoverHealth(){ string strHealth = "["; float Diff = Health / 10000; integer x = (integer)(Diff * 10); integer y = 10 - x; while( x-- ) strHealth += "|"; while( y-- ) strHealth += " "; strHealth += "]"; llSetText( strHealth, < 0.0, 1.0 , 0.0 >, 1.0 ); }
_____________________
 Geometric Library, for all your 3D maths needs. https://wiki.secondlife.com/wiki/Geometric Creator of the Vertical Life Client
|