Jump to content

Displaying Floating Number With llOwnerSay


Cookie Bertone
 Share

You are about to reply to a thread that has been inactive for 640 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I want to display the height of the sun so I can get a light to switch on and off automatically.  I can get the light to work fine and it switches on when it gets dark but I want it to tell me what the sun height is each time the timer expires and for some probably silly reason it tells me there is a type mismatch.

I have defined:

vector sun_position;
float sun_height;

I then get the height by doing this:

sun_position = llGetSunDirection();
sun_height = sun_position.z;

And then I try to get it to tell me the height:

llOwnerSay("Sun height is: "+sun_height);

Sorry for asking what I consider to be a noob question but I have spent a long time not using LSL and the answer to this question has escaped me.

Link to comment
Share on other sites

The variable sun_height is defined as a float. You cannot add a number to a string, as in "Sun height is: "+sun_height. You can, however, convert sun_height to a string by using typecasting and then add it to another string: "Sun height is: "+(string)sun_height.

Edited by KT Kingsley
Link to comment
Share on other sites

llOwnerSay() takes only string variables. Your sun_height variable is a float. You change between variable types by "typecasting"...

https://wiki.secondlife.com/wiki/Typecast

The string concatenation operator (+) must also go between strings, not inside them. You also don't want to place your variable name inside string quotes.

llOwnerSay( ("Sun height is :" + (string) sun_height) should do the job.

Edited by Madelaine McMasters
  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 640 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...