|
Vincente Shepherd
Registered User
Join date: 12 Jun 2007
Posts: 12
|
07-16-2007 08:13
Heya folks - this is probably a really simple one, but it's been nagging me.
I'm in the process of building some aircraft, and would like to include an altimeter as one of its functions. I'd like the readout to be 'said' by the touched object, and for it to give the current distance above ground level. How would this be scripted?
Ultimately I'd like a velocity readout as well, but I'm content to tackle on thing at a time!
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
07-16-2007 08:23
Something like this: touch_start(integer total_number) { float currentHeight = llGetPos().z - llGround(ZERO_VECTOR); llSay(0,"Current Height: " + (string)currentHeight );
|
|
Vincente Shepherd
Registered User
Join date: 12 Jun 2007
Posts: 12
|
07-16-2007 08:45
Thanks for getting back to me!
I'm probably missing some fundemental basic of scripting, but when I attempt to save it there is apparently a syntax error in llGetPos().z
For the sake of seeing whether it's a stupid mistake on my part, the entirity of my script is:
default { touch_start(integer total_number) { float currentHeight = llGetPos().z - llGround(ZERO_VECTOR); llSay(0,"Current Height: " + (string)currentHeight ); } }
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
07-16-2007 08:49
What is the error you are getting?
|
|
Vincente Shepherd
Registered User
Join date: 12 Jun 2007
Posts: 12
|
07-16-2007 08:52
(5, 32) : ERROR : Syntax error
The pipe is flashing between llGetPos() and .z - llGround(ZERO_VECTOR);
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
07-16-2007 08:59
Try this instead: touch_start(integer total_number) { vector pos = llGetPos() float currentHeight = pos.z - llGround(ZERO_VECTOR); llSay(0,"Current Height: " + (string)currentHeight ); }
|
|
Vincente Shepherd
Registered User
Join date: 12 Jun 2007
Posts: 12
|
07-16-2007 09:02
AHA! That's perfect! Thank you ever so much - I owe you a pint, or an airship.
|