LSL 101/String Concatenation

From Second Life Wiki
Jump to navigation Jump to search
← 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" + "." );