Fix touch_start behaviour in slua
inĀ progress
WolfGang Senizen
LSL has an awkward
bug
/behavior
with touch_start
If a user is already touching a prim, no other users
touch_start
s will trigger, only their touch
and touch_end
events.This is awkward and seemingly undocumented at least on the wiki.
While it may not be something that can be changed in lsl, it would be nice to clear this up in slua and not carry this "bug" over
LSL script
list ks = [];
handle(string name, integer t) {
while(t--) {
string evnt = name + ": " + llDetectedName(t);
if(llListFindList(ks,[evnt]) == -1) {
ks += evnt;
}
}
ks = llListSort(ks,1,1);
llSetLinkPrimitiveParamsFast(0, [PRIM_TEXT,llDumpList2String(ks,"\n"),<1,1,1>,1]);
llSetTimerEvent(5.0);
}
default {
state_entry() {
llSetLinkPrimitiveParamsFast(0, [PRIM_TEXT,"",<1,1,1>,1]);
}
touch_start(integer t) {
handle("touch_start",t);
}
touch(integer t) {
handle("touch",t);
}
touch_end(integer t) {
handle("touch_end",t);
}
timer() {
ks = [];
llSetTimerEvent(0.0);
llSetLinkPrimitiveParamsFast(0, [PRIM_TEXT,"",<1,1,1>,1]);
}
}
SLua script
local ks = {}
local clearHandle = nil
local function clear()
ll.SetLinkPrimitiveParamsFast(0, {PRIM_TEXT,"",vector.one,1})
ks = {}
end
local function handler(name)
return function(events:{DetectedEvent})
for _,event in events do
local evnt = `{name}: {event:getName()}`
if not table.find(ks, evnt) then
ks[#ks+1] = evnt
end
end
table.sort(ks)
ll.SetLinkPrimitiveParamsFast(0, {PRIM_TEXT,table.concat(ks,"\n"),vector.one,1})
if clearHandle then LLTimers:off(clearHandle) end
clearHandle = LLTimers:once(5, clear)
end
end
clear()
LLEvents:on("touch_start", handler("touch_start"))
LLEvents:on("touch", handler("touch"))
LLEvents:on("touch_end", handler("touch_end"))
Both of these scripts require 2 users to click, and you can see that only the person that clicks first gets a touch_start set text.
Log In
H
Harold Linden
marked this post as
inĀ progress
Thanks for the report! As far as I can tell, this bug has existed since 2009.
We probably can't fix it for LSL at this point, there are too many scripts that could break if
num_detected
in a touch_start
is greater than 1
since they never had to deal with it before. Fixing it in SLua is straightforward though.H
Harold Linden
Fix for this should go out with the next release
Thunder Rahja
Here is the bug as previously reported and acknowledged: https://feedback.secondlife.com/scripting-bugs/p/touch-start-only-triggers-on-the-second-touch-if-touch-is-already-active
I have noted it under touch_start's caveats on the wiki.
Nexii Malthus
This bug can be even more annoying in SLua where you may have to deal with event registrations more fluidly and precisely for multi-touch objects. Tracking touches of different users from start to end.