Jump to content

Preventing a backlog of touch commands


Loki Eliot
 Share

You are about to reply to a thread that has been inactive for 4666 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Today i am looking to prevent my HUD from storing a backlog of touch commands. When i click the Button it sends out a word activation for another attachment. What i have found though is that if i press the button repeatedly the HUD stores up the Button presses and for a long while after ive finished pressing the button, it is still sending out commands.

Is there a Delay effect i can place at the end of the touch command to prevent it from taking another touch command for about 1 second?

this is my HUD

integer giChan;

default {
    attach(key id) {
        if (id != NULL_KEY) { //check if the HUD has got attached, not detached
            giChan =  (integer)("0x" + llGetSubString(llGetOwner(), 0, 7)) * -1; //compute a channel number based in the key of the owner
        }
    }
    
    touch_end(integer num_detected) {
        llWhisper(giChan, "throw"); //say the defined comand for playing the animation
        llSetAlpha(0, ALL_SIDES);
        llSleep(0.1);
        llSetAlpha(100, ALL_SIDES);
    }
}

 

Link to comment
Share on other sites

You timer and a flag to define if the button reacts on touches or not. The touch and the timer toggle the flag - here is how it could look:

float gfTimer = 1;integer giChan;integer giPressable;default {    attach(key id) {        if (id != NULL_KEY) { //check if the HUD has got attached, not detached            giChan =  (integer)("0x" + llGetSubString(llGetOwner(), 0, 7)) * -1; //compute a channel number based in the key of the owner	}	giPressable = 1;    }    touch_end(integer num_detected) {	if(giPressable) {		llWhisper(giChan, "throw"); //say the defined comand for playing the animation		llSetTimerEvent(gfTimer);		giPressable = 0;		llSetAlpha(0, ALL_SIDES);		llSleep(0.1);		llSetAlpha(100, ALL_SIDES);	}}timer() {		giPressable = 1;		llSetTimerEvent(0);		}}

 

  • Like 1
Link to comment
Share on other sites

You may consider a 'long' touch:

integer giChan;default {    attach(key id) {        if (id != NULL_KEY) { //check if the HUD has got attached, not detached            giChan =  (integer)("0x" + llGetSubString(llGetOwner(), 0, 7)) * -1; //compute a channel number based in the key of the owner        }    }
    touch_start(integer num) { llResetTime(); }
touch_end(integer num_detected) { if ( llGetTime() > 0.8 ) { // mouse button held for more tham 0.8S
llWhisper(giChan, "throw"); //say the defined comand for playing the animation llSetAlpha(0, ALL_SIDES); llSleep(0.1); llSetAlpha(1.0, ALL_SIDES);
}
 }}



Link to comment
Share on other sites

I'm reluctant to complicate matters, but a thread with this title sorta calls out for some reference to the cliche of using a separate state that lacks any handler for touch-related events.  While the script is in that state, new touch events will not be generated -- indeed, the mouse cursor won't show the object as touchable.

Link to comment
Share on other sites

if the hud is handling a return from it's action Qie's method may be optimal, or a variation of it with a global variable that just ignores (or even gives the user a "wait" message) additional touches before it's recieved it's return.

if it doesn't recieve a return then you may be better off dealing with ignoring any excess messages it's generating in the receiving script, and using min event delay to help pad it out.

Link to comment
Share on other sites

llSetAlpha has got a delay , but you dont wait the end of the delay to fire the second llSetAlpha

 

integer giChan;default {    attach(key id) {        if (id != NULL_KEY) { //check if the HUD has got attached, not detached            giChan =  (integer)("0x" + llGetSubString(llGetOwner(), 0, 7)) * -1; //compute a channel number based in the key of the owner        }    }        touch_end(integer num_detected) {        state first_alpha;    }}state first_alpha{    state_entry()    {        llWhisper(giChan, "throw"); //say the defined comand for playing the animation        llSetAlpha(0, ALL_SIDES);                 }    changed (integer change )    {        if (change & CHANGED_COLOR )            state second_alpha;    }}state second_alpha{    state_entry()    {        llSleep(0.1); // to tune at your conveniance        llSetAlpha(100, ALL_SIDES);           }    changed (integer change )    {        if (change & CHANGED_COLOR )            state default;    }}    

 

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4666 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...