Untitled
unknown
plain_text
2 years ago
1.9 kB
8
Indexable
//Set functions for Touch, Click and Long touch; 2023.12.19; by Paradox
//
//For detailed instructions, see the example.
integer touch_detected;
integer touch_timer;
integer touch_start_counter;
integer isTouch()
{
if (touch_start_counter == 1 && touch_detected == 0 && touch_timer > 4)
{
touch_start_counter = 0;
touch_timer = 0;
return TRUE;
}
else return FALSE;
}
integer isClick()
{
if (touch_start_counter == 2 && touch_timer <= 4)
{
touch_start_counter = 0;
touch_timer = 0;
return TRUE;
}
else return FALSE;
}
integer isLongTouch()
{
if (touch_detected == 1 && touch_timer == 50)
{
touch_start_counter = 0;
touch_timer = 0;
return TRUE;
}
else return FALSE;
}
default
{
state_entry()
{
llSetTimerEvent(0.01);
}
touch_start(integer total_number)
{
//For Touch and Click
touch_start_counter += 1;
}
touch(integer num_detected)
{
//For Long touch
touch_detected = 1;
}
touch_end(integer num_detected)
{
//For Touch, Click and Long touch
touch_detected = 0;
touch_timer = 0;
}
timer()
{
//For Touch, Click and Long touch
if (touch_start_counter > 0 || touch_detected == 1)
{
touch_timer += 1;
}
//Touch
if (isTouch() == TRUE)
{
llSay(0, "is Touch");
}
//Click
else if (isClick() == TRUE)
{
llSay(0, "is Click");
}
//Long touch
else if (isLongTouch() == TRUE)
{
llSay(0, "is Long touch");
}
}
}Editor is loading...
Leave a Comment