Difference between revisions of "Textbox2Hovertext"
Jump to navigation
Jump to search
(channel and handle numbers are different. I do not like how you use a slow loop to remove listens but it's a clever solution that should work.) |
Omei Qunhua (talk | contribs) (Improve and correct) |
||
Line 22: | Line 22: | ||
if (listenhandle) llListenRemove(listenhandle--); | if (listenhandle) llListenRemove(listenhandle--); | ||
else llSetTimerEvent(0.0); | 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); | |||
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() | |||
{ | |||
llListenRemove(listenhandle); | |||
llSetTimerEvent(0.0); | |||
} | } | ||
} | } | ||
</lsl> | </lsl> |
Revision as of 08:57, 29 January 2013
<lsl> // Textbox2Hovertext.LSL by Ackley Bing . January 2013 // A simple script to allow hovertext to be set with a dialog text box
integer listenhandle;
default {
touch_start(integer num) { key target = llGetOwner();// or llDetectedKey(0) llSetTimerEvent(30.0); listenhandle = llListen(1, "", target, ""); llTextBox( target, "Set Hovertext", 1 ); } listen(integer channel, string name, key id, string message) { llSetText(message, <1.0,1.0,1.0>, 1.0); } 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);
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() { llListenRemove(listenhandle); llSetTimerEvent(0.0); }
} </lsl>