Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

SLS Newb

Pezz Pontoppidan
Registered User
Join date: 30 Apr 2006
Posts: 5
04-30-2006 21:51
I'm running through the wiki but can't find out how to take a var and output it say with: llSetText.

For the sake of simplicity lets say I have:

integer y = 10;

and i want to use 'y' in llSetText.

I've tried:

llSetText(y,<0,1,0>,1);

but this returns a syntax error

What have I overlooked here?
Pezz Pontoppidan
Registered User
Join date: 30 Apr 2006
Posts: 5
04-30-2006 21:57
From: Pezz Pontoppidan
I'm running through the wiki but can't find out how to take a var and output it say with: llSetText.

For the sake of simplicity lets say I have:

integer y = 10;

and i want to use 'y' in llSetText.

I've tried:

llSetText(y,<0,1,0>,1);

but this returns a syntax error

What have I overlooked here?


Maybe y should be a string?

ok, so i fixed it by using (string)y

now my questions is, using multiple vars with text seperating it.

I know in C++ I would use (string)y << "Text" << (string)x
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
04-30-2006 22:34
The Wiki is your friend. Most of these kinds of questions you can find answers to there much quicker than in the forums. :)

http://secondlife.com/badgeo/wakka.php?wakka=HomePage

LSL is more like C than C++, but acts a little like BASIC in some respects. String concatenation is one of those. Use the + operator to concatenate strings.

MyString = "Dogs " + "Cats."; // MyString gets "Dogs Cats."
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
04-30-2006 22:41
Hi Pezz

replace "<<" with "+"

cast anything that is not a string by prefacing it with ";(string)"

so change "llSetText(y,<0,1,0>,1);" to "llSetText((string)y,<0,1,0>,1);"

About using strings:
http://secondlife.com/badgeo/wakka.php?wakka=string


About using llSetText:
http://secondlife.com/badgeo/wakka.php?wakka=llSetText

Ed
Ayrn Wake
Registered User
Join date: 7 Jan 2006
Posts: 39
05-01-2006 03:39
How I would personally handle it:

CODE

integer x = 1;
integer y = 2;
integer z = 3;
string xyz = (string)x + ", " + (string)y + " & " + (string)z;
llSetText (xyz, <1,1,1>, 1.0);


Saves you typecasting when you set the text, and makes it slightly easier to read, so if you ever need to format that string in a different way you just alter that variable rather than messing about with functions. Ok, easy in this context, but can be a pain when you've more complex things going on.
Laharl Fassbinder
Registered User
Join date: 12 Oct 2004
Posts: 68
05-01-2006 19:37
Hover the mouse over the llSetText command.. see that it asks for STRING text?
means that the text MUST be a string, and between "". if its not, then you must show the command that it is a string. using (string)y.

if it asked for FLOAT, you would have to use (float)y, and so on.




So it will look like llSetText((string)y, <1,1,1>, 1);

if you want to add more text WITH the "y", you could do this:

llSetText((string)y + " additional text", <1,1,1>, 1);