Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Touch delay code and help with touch by owner script

Jack Tigerpaw
Registered User
Join date: 19 Nov 2007
Posts: 21
09-28-2008 10:24
Does anyone know what is the scripting code (or some similar example in another script) for when you touch and hold down the key for a certain amount of seconds, then it performs some action?

I want to do something like this, but how do I add in that delay?

From: someone
default
{
touch_start(integer total_number) {
if (llDetectedKey( 0 ) == llGetOwner())
{
llOwnerSay("Say something to owner here: AFTER OWNER has held down key for x seconds.";);
// Or do other things for OWNER here.
}
}
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
09-28-2008 13:43
I think you could start a timer on touch_start. Then if the toucher releases before the timer event you can kill the timer.

From: someone

touch_start(integer num)
{
llSetTimerEvent(10);
}

touch_end(integer num)
{
llSetTimerEvent(0);
}

timer()
{
llSetTimerEvent(0);
llOwnerSay("Say something to owner here: AFTER OWNER has held down key for x seconds.";);
}

Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
09-28-2008 13:48
Or perhaps record the llGetTime() of the leading edge detected in touch_start(), then subtract it from the time of the trailing edge detected in touch_end(), and branch depending on magnitude of difference.

No idea which is more efficient in practice, though.

[Edit: I should have mentioned that the two approaches differ in effect, this one waiting until the button is released for anything to happen, the other approach triggering at timeout, so the choice probably depends less on performance and more on which behavior is more intuitive.]
Soen Eber
Registered User
Join date: 3 Aug 2006
Posts: 428
09-28-2008 16:24
You can search for "press & hold" for my implementation of this for the left mouse click. There will be some differences for doing this with the keyboard, however, and there will some code you won't need (such as the access code).
Jack Tigerpaw
Registered User
Join date: 19 Nov 2007
Posts: 21
09-28-2008 18:15
From: Soen Eber
You can search for "press & hold" for my implementation of this for the left mouse click. There will be some differences for doing this with the keyboard, however, and there will some code you won't need (such as the access code).


Thank you, that script helped me.