|
Voluntas Dagger
Registered User
Join date: 26 May 2007
Posts: 2
|
07-10-2007 09:24
So yeah, I realize this is a noobish question (and that the example in the thread title is complete garbage), but how do you convert a vector into a string? I want llSay to spit out the llGetPos.
Situation: I need be able to get the local position of a child prim attached to a root.
I'm wanting to know two values, a start position and an end position, so that I can then use llSetPos to move it back and forth on command.
I've been doing it the trial-and-error way, by setting the vector, testing it, then setting it slightly over etc. However, I've got about 40 prims I need to do this to, and it sure would save a lot of time if I knew how to move it manually there, then be able to llSay the llGetPos.
I searched a bit, but couldn't seem to find an answer. I assume it's because this question is ridiculously easy, but hey, that's what makes me a noob.
Thanks in advance!
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
07-10-2007 09:35
Just typecast the result:
llSay(0, (string)llGetPos());
Also, while just testing, it might be advantageous to replace the llSay with llOwnerSay.
|
|
Voluntas Dagger
Registered User
Join date: 26 May 2007
Posts: 2
|
llSay(0,"You rock, Qie Niangao!"  ;
07-10-2007 09:46
I didn't even know there was such a thing as typecasting! That's such a vaulable concept; I know I would have found that useful in a few other projects as well. Thanks a ton Qie 
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
casting
07-11-2007 09:33
Gee, you are a newb!
Casting is extremely useful, for example, if you use a listen to "get" a value from an avatar, that will be stored in a string, yet you may want to cast it into a numeric variable such as an integer or float. For example, say you request a numeric value and use a listen to store it in a string variable called message, you can cast it into a numeric variable, then perform math on it, and then cast it back into a string (for output using llSay() ).
the format is always (type)variable
example: string foo = "5"; integer value = (string)foo; foo +=1;
llSay (0,"new value=" + (string)value);
|
|
Ed Gobo
ed44's alt
Join date: 20 Jun 2006
Posts: 220
|
07-11-2007 23:35
From: Johan Laurasia Gee, you are a newb!
Casting is extremely useful, for example, if you use a listen to "get" a value from an avatar, that will be stored in a string, yet you may want to cast it into a numeric variable such as an integer or float. For example, say you request a numeric value and use a listen to store it in a string variable called message, you can cast it into a numeric variable, then perform math on it, and then cast it back into a string (for output using llSay() ).
the format is always (type)variable
example: string foo = "5"; integer value = (string)foo; foo +=1;
llSay (0,"new value=" + (string)value); How about: string foo = "5"; integer value = (integer) foo; ++value; llSay (0,"new value=" + (string)value);
|