|
Jher Quartermass
Registered User
Join date: 24 Sep 2004
Posts: 18
|
10-04-2004 19:07
Hi there,
Another scripting newbie question... I'd like to make an Altimeter script for a flying object. Something that displays the height as text over the top of the object. I've got some code to display text but I'm not quite certain how to figure out the altitude. llGetPos?
|
|
Pete Fats
Geek
Join date: 18 Apr 2003
Posts: 648
|
10-04-2004 19:49
vector pos = llGetPos(); llSetText("Current heigth: " + (string)pos.z, <1,1,1>, 1.0);
That should work.
|
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
10-05-2004 08:03
From: Pete Fats vector pos = llGetPos(); llSetText("Current heigth: " + (string)pos.z, <1,1,1>, 1.0);
That will give you your absolute height in the world, if you want your height above land you could use float height() { vector vPos = llGetPos(); return vPos.z - llGround(ZERO_VECTOR); } or, if you wanted to get fancy and get your height above ground or water: float height() { vector vPos = llGetPos(); if (llGround(ZERO_VECTOR) > llWater(ZERO_VECTOR)) return vPos.z - llGround(ZERO_VECTOR); else return vPos.z - llWater(ZERO_VECTOR); }
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|
|
Jher Quartermass
Registered User
Join date: 24 Sep 2004
Posts: 18
|
10-08-2004 16:15
Thanks folks!
|
|
Bilbo Goodliffe
all around good guy
Join date: 30 Dec 2005
Posts: 22
|
06-14-2006 17:36
From: Wednesday Grimm That will give you your absolute height in the world, if you want your height above land you could use float height() { vector vPos = llGetPos(); return vPos.z - llGround(ZERO_VECTOR); } or, if you wanted to get fancy and get your height above ground or water: float height() { vector vPos = llGetPos(); if (llGround(ZERO_VECTOR) > llWater(ZERO_VECTOR)) return vPos.z - llGround(ZERO_VECTOR); else return vPos.z - llWater(ZERO_VECTOR); } what if you wanted a tone at a user set altitude?
|
|
Artemis Cain
Take it or Leave it
Join date: 11 Apr 2005
Posts: 116
|
06-15-2006 06:11
From: Bilbo Goodliffe what if you wanted a tone at a user set altitude? I would suggest if (llGetPos() = whatever the height is) { play sound }
very nasty example code, I know... but I am only on my first cup of coffee! you could also have the user set this height have them say "setheight 1000" and that would set the comparison height for the if statement to 1000 meters. perhaps after my 3rd cup, I will actually code this the right way!
|