Difference between revisions of "MySay"

From Second Life Wiki
Jump to navigation Jump to search
m (minor readability improvements)
Line 9: Line 9:
|func_footnote=
|func_footnote=
<lsl>
<lsl>
mySay(string objectName, string msg) {
mySay(string objectName, string msg)
     string name = llGetObjectName();
{
     string nameBeforeChange = llGetObjectName();
 
     llSetObjectName(objectName);
     llSetObjectName(objectName);
     llSay(0, "/me " + msg);
     llSay(PUBLIC_CHANNEL, "/me " + msg);
     llSetObjectName(name);
 
}</lsl>
     llSetObjectName(nameBeforeChange);
}
</lsl>
See also: [[mySayOwner]], [[:Category:LSL_Chat]]
See also: [[mySayOwner]], [[:Category:LSL_Chat]]
|examples=
|examples=
Line 26: Line 30:


<lsl>
<lsl>
mySay(string objectName, string msg) {
mySay(string objectName, string msg)
     string name = llGetObjectName();
{
     while (name == "") {
     string nameBeforeChange = llGetObjectName();
         name = llGetObjectName();
 
    }
     while (nameBeforeChange == "")
         nameBeforeChange = llGetObjectName();
 
     llSetObjectName(objectName);
     llSetObjectName(objectName);
     llSay(0, "/me " + msg);
     llSay(PUBLIC_CHANNEL, "/me " + msg);
     llSetObjectName(name);
 
     llSetObjectName(nameBeforeChange);
}
}
</lsl>
</lsl>

Revision as of 10:23, 30 September 2012

Summary

Function: string mySay( string objectName, string msg );

Cleaner chat on a user's screen. Gives a less-cluttered, more professional looking output.
Returns a string

• string objectName
• string msg

<lsl> mySay(string objectName, string msg) {

   string nameBeforeChange = llGetObjectName();
   llSetObjectName(objectName);
   llSay(PUBLIC_CHANNEL, "/me " + msg);
   llSetObjectName(nameBeforeChange);

} </lsl> See also: mySayOwner, Category:LSL_Chat

Examples

<lsl> mySay("","Processing, please wait."); </lsl> //user sees just: 17:04 Processing, please wait.
//You don't need to specify anything in the first parameter. The second one is limited to the normal chat limitation of a maximum of 255 bytes for that string. You may if you wish in the function swap in llWhisper or llShout.

If you have many different scripts in the same prim using mySay and competing at the same time for the object name, one might grab object name while it is blank, and then set it back to blank, wiping out the object name. This version compensates for that competition.

<lsl> mySay(string objectName, string msg) {

   string nameBeforeChange = llGetObjectName();
   while (nameBeforeChange == "")
       nameBeforeChange = llGetObjectName();
   llSetObjectName(objectName);
   llSay(PUBLIC_CHANNEL, "/me " + msg);
   llSetObjectName(nameBeforeChange);

}

</lsl>

Notes

What this does:

Instead of users having their vision obscured by text like this covering half their screen:

[14:04] Animated Living Sofa Combo Couple & Solo 2.1e whispers: Lie F 1

They see just this:

[14:04] Lie F 1