Difference between revisions of "Textbox2Hovertext"

From Second Life Wiki
Jump to navigation Jump to search
(Improve and correct)
m (<lsl> tag to <source>)
 
(12 intermediate revisions by one other user not shown)
Line 1: Line 1:
<lsl>
<source lang="lsl2">
// Textbox2Hovertext.LSL by Ackley Bing . January 2013
// Textbox2Hovertext by Ackley Bing & Omei Qunhua
// A simple script to allow hovertext to be set with a dialog text box
// A simple script to allow object owners to change the "hovertext"
// on their prims using a text entry box (llTextBox).


integer listenhandle;
integer listenhandle;
 
default
default
{
{
     touch_start(integer num)
     touch_start(integer num)
     {
     {
         key target = llGetOwner();// or llDetectedKey(0)
         key Writer = llDetectedKey(0);
         llSetTimerEvent(30.0);
        if(Writer!=llGetOwner()) return; // remove this line to allow anyone to change the hover text
         listenhandle = llListen(1, "", target, "");
        llListenRemove(listenhandle);
         llTextBox( target, "Set Hovertext", 1 );
         llSetTimerEvent(60.0); // Time to input text until script closes listener in case target doesnt enter anything into textbox
         listenhandle=llListen(-12345, "", Writer, "");
         llTextBox( Writer, "Set Hovertext", -12345);
     }
     }
     listen(integer channel, string name, key id, string message)
     listen(integer channel, string name, key id, string message)
     {
     {
         llSetText(message, <1.0,1.0,1.0>, 1.0);
         llSetText(message, <1, 1, 1>, 1);
    }
    timer()
    {
        if (listenhandle) llListenRemove(listenhandle--);
        else llSetTimerEvent(0.0);
    }
}
</lsl>
 
Here is a further improved and corrected version by Omei Qunhua, removing the confusion between toucher and owner, and simplifying the listen removal.
 
<lsl>
integer listenhandle;
 
default
{
    touch_start(integer num)
    {
        key target = llDetectedKey(0);
 
        // remove this 'if' and the 'return' to allow anyone to change the hover text
        if (target != llGetOwner() )       
            return;
 
        // Avoid possible multiple active listeners, if different people click within 30 seconds
         llListenRemove(listenhandle);
         llListenRemove(listenhandle);
 
         llSetTimerEvent(0.0);
         llSetTimerEvent(30.0);
 
        // Reduce the chance of picking up unrelated chat, by using a large negative channel
        // We could get even more secretive here if desired, but this'll do for now
        listenhandle = llListen(-12345, "", target, "");
        llTextBox( target, "Set Hovertext", -12345 );
    }
    listen(integer channel, string name, key id, string message)
    {
        llSetText(message, <1.0,1.0,1.0>, 1.0);
     }
     }
     timer()
     timer()
Line 61: Line 29:
     }
     }
}
}
</lsl>
</source>
[[Category:LSL Library]]

Latest revision as of 07:48, 25 January 2015

// Textbox2Hovertext by Ackley Bing & Omei Qunhua
// A simple script to allow object owners to change the "hovertext"
// on their prims using a text entry box (llTextBox).

integer listenhandle;
 
default
{
    touch_start(integer num)
    {
        key Writer = llDetectedKey(0);
        if(Writer!=llGetOwner()) return; // remove this line to allow anyone to change the hover text
        llListenRemove(listenhandle);
        llSetTimerEvent(60.0); // Time to input text until script closes listener in case target doesnt enter anything into textbox
        listenhandle=llListen(-12345, "", Writer, "");
        llTextBox( Writer, "Set Hovertext", -12345);
    }
    listen(integer channel, string name, key id, string message)
    {
        llSetText(message, <1, 1, 1>, 1);
        llListenRemove(listenhandle);
        llSetTimerEvent(0.0);
    }
    timer()
    {
        llListenRemove(listenhandle);
        llSetTimerEvent(0.0);
    }
}