Difference between revisions of "Talk:Textbox2Hovertext"
Omei Qunhua (talk | contribs) (Concerns) |
Ackley Bing (talk | contribs) |
||
Line 72: | Line 72: | ||
llListenRemove(1); | llListenRemove(1); | ||
::does? [[User:Omei Qunhua|Omei Qunhua]] 15:58, 13 February 2013 (PST) | ::does? [[User:Omei Qunhua|Omei Qunhua]] 15:58, 13 February 2013 (PST) | ||
:::Why? It does exactly what its supposed to do which is to remove listen callback #1. What is it you really want to know?? --[[User:Ackley Bing|Ackley Bing]] 10:05, 14 February 2013 (PST) |
Revision as of 10:05, 14 February 2013
Listeners:
As your llListen() always has the same arguments (same channel and filtering by owner only) each llListen will be assigned to the same listener handle. So there's no danger of accumulating open listens, and your timer code could be simplified to:-
<lsl>
timer() { llListenRemove(listenhandle); llSetTimerEvent(0.0); }
</lsl>
Unless your object gets handed on to multiple subsequent owners :)
If you want anyone to be able to set the hover text, then you could preclude multiple open listeners by removing the listen at the start of the touch event. It doesn't matter if it's already been removed by the timer code (or has never been assigned):-
<lsl>
touch_start(integer num) { llListenRemove(listenhandle); key target = llDetectedKey(0); llSetTimerEvent(30.0); listenhandle = llListen(1, "", target, ""); llTextBox( target, "Set Hovertext", 1 ); }
</lsl>
Omei Qunhua 07:01, 29 January 2013 (PST)
Owner vs Toucher
Actually I now see that there is confusion between toucher and the person who gets the textbox. The original code had this line:
<lsl>
llTextBox( llDetectedKey(0), "Set Hovertext", (listenhandle = llListen(1, "", llGetOwner(), "")) );
</lsl>
Which sends a text box to the person who touched the object, but listens for a reply from the owner only (who is not necessarily the same person, or even online at the time). It also had the confusion between channel number and listener handle as Strife pointed out.
However Strife's revision still has problems in the version intended for owner use only, as it responds to anyone touching the object, but sends the textbox to, and listens to a reply from, the owner.
Better code for owner-only use would be:-
<lsl>
touch_start(integer num) { key target = llDetectedKey(0); if (target != llGetOwner() ) // remove this 'if' and the 'return' to allow anyone to change the hover text return; llListenRemove(listenhandle); llSetTimerEvent(30.0); listenhandle = llListen(1, "", target, ""); llTextBox( target, "Set Hovertext", 1 ); }
</lsl>
Omei Qunhua 07:24, 29 January 2013 (PST)
- I wanted to make as few changes as possible. As a bit of secret knowledge, listen handles are allocated incrementally, the first to be returned is 1. So even if the script did open multiple handles it would eventually clean them all up with the timer, nor would it clean them up too quickly (just way too slowly). I don't approve of that bit of cleverness, since it relies upon the allocation of listen handles (which I don't recall it ever being specified) but it works so I'm not going to spoil someone else's fun on their userpage. The script wastes CPU time and can run out of listens but again, not my call. You are correct, I forgot to make sure that if you set it to owner that only the owner's click would set it in motion. -- Strife (talk|contribs) 11:03, 29 January 2013 (PST)
- Maybe it's one thing putting it on your own user page, but another thing to then link it from the Wiki script library, whose rules say "Your script must be tested and working. This is a list of working, usable scripts." :)) Omei Qunhua 11:24, 29 January 2013 (PST)
- It works exactly as intended: For owners http://community.secondlife.com/t5/LSL-Scripting/SCRIPTING/m-p/1819191#M15173 :) --Ackley Bing 10:28, 13 February 2013 (PST)
Thank you for the feedback I really do appreciate it and have decided it's best to keep listening simple so that we don't debate here the best Listening practices i think that debate should be on a Listen page, not this one. This is really just a demonstration of llTextBox. --Ackley Bing 10:56, 13 February 2013 (PST)
- Ackley, I felt it wasn't appropriate for me to edit your own script on your own page, but I was concerned about its errors, as you had linked it to an idex of "working usable scripts". Hence I added an alternate example. You've now edited yours again, but I still consider it to be faulty. Sure, this is not a script to explain listeners, but the script does need to be correct in its handling of listens. May I ask, what is your understanding of what
llListenRemove(1);
- does? Omei Qunhua 15:58, 13 February 2013 (PST)
- Why? It does exactly what its supposed to do which is to remove listen callback #1. What is it you really want to know?? --Ackley Bing 10:05, 14 February 2013 (PST)
- does? Omei Qunhua 15:58, 13 February 2013 (PST)