LSL 101/String Concatenation
< LSL 101
Jump to navigation
Jump to search
Revision as of 11:24, 21 May 2009 by Omei Turnbull (talk | contribs)
← Functions That Return a Value | ↑̲ LSL 101 ̲↑ |
String concatenation allows us to combine two or more strings into a single string, as if they were simply pasted together. Here's an example where we use string concatenation to put the region name into a complete sentence.
<lsl>default {
state_entry() { // Let the object's owner know the script is working llOwnerSay( "Congratulations! Your script has started to execute." ); } touch_start( integer num_detected ) { // Let the object's owner know the script is working llOwnerSay( "Welcome to " + llGetRegionName() + "." ); }
}</lsl>
The + sign, when used with strings, indicates concatenation. This is analogous to the use of + in integer addition
As in the previous example, the server executes llGetRegionName and reduces the line to the equivalent of
llOwnerSay( "Welcome to " + "Ganymede" + "." );