Jump to content

Troubles with my HUD


Loki Eliot
 Share

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

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

Recommended Posts

Thanks to the wonderful support on this forum i made a HUD a while ago. The HUD has a button on it that activates a worn weapon to animate. BUt i hit a snag in that if i repeatedly tapped the button out of fear and panic, the HUD would wrack up a back log of actions and i would be repeatedly swinging my sword for the next 10 minutes.

So i came to this forum for a solution and i recieved one which is awesome. The following Script  was the result and stops my rapid clicking from causing  backlogs of actions.

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, "whack"); //say the defined comand for playing the animation
        llSetTimerEvent(gfTimer);
        giPressable = 0;
    }

}

timer() {
        giPressable = 1;
        llSetTimerEvent(0);    
    }
}

 Unfortunitly while testing with my friends today we discovered it only works for me. When i give the HUD to a friend and they rapidly click, then they get a backlog of actions. 

So does anyone know why this script works as planned for me in a HUD, but when i give the HUD to someone else it does not work as planned?

Link to comment
Share on other sites

Certainly.  It still thinks that you are its owner, unless you had the foresight to reset its script before giving it away.  The cure is to make a small modification....

key gOwner;default {    state_entry(){        gOwner = llGetOwner();    }    changed (integer change){        if (change & CHANGED_OWNER){            gOwner = llGetOwner();        }    }    attach(key id) {        if (id != NULL_KEY) { //check if the HUD has got attached, not detached            giChan =  (integer)("0x" + llGetSubString(gOwner, 0, 7)) * -1; //compute a channel number based in the key of the owner        }     giPressable = 1;    }

 ....  leaving the rest of the script as is.  The new global variable gOwner will be set to the current owner if the script is reset or if the HUD changes ownership.  You could also do this by putting llResetScript() in the changed event instead, but this is a less drastic alternative.

 

  • Like 1
Link to comment
Share on other sites

Assuming it's only supposed to work when you wear it, I'd take advantage of the fact that you can't wear something that doesn't belong to you, and just do something like this:

float gfTimer = 1;integer giChan;integer giPressable;key gOwner;default {	attach(key id) {		if (id) { //check if the HUD has got attached, not detached			gOwner =id;			giChan =  (integer)("0x" + llGetSubString(gOwner, 0, 7)) * -1; //compute a channel number based in the key of the owner		}		giPressable = 1;	}}

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4624 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...