Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

button script behaving oddly

Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
11-28-2005 23:34
for some reason, this script in one of my HUD buttons seems to think it get's touched twice when I only touch it once. any ideas why?

[edit] managed to solve it on my own: changing the touch_end to a touch_start event fixed the problem [/edit]

CODE

integer damage = 21; //This is info that is sent in a link message
integer myheat = 13; // to the prim that actually handles all the
integer tarheat = 5; //Combat damage and wether or not things hit
integer delay = 3; //I'm using a system that should only require
integer ready = FALSE; //physical objects for missiles and bullets, and
integer online = TRUE; //lazer fire is instead calculated "instantaneously" as if it is traveling at the speed of light, like a real lazer would behave.

on()//the weapon's status is on, and the appropriate info is sent to the rest of the combat system
{
llMessageLinked(LINK_SET,401,"PPC1//" +(string) delay + "//" + (string) damage + "//" + (string) myheat + "//" + (string) tarheat,NULL_KEY); //401 indicates which weapon slot (out of 8 total) is turned on. in this case this is slot one
llSetText("Left PPC:\nOnline",<0,1,0>,1);
ready=TRUE;
llOwnerSay("the weapon is turned on"); //debugging shiz
}

off()//the weapon's status is off and the appropriate info is sent to the rest of the combat system
{
llMessageLinked(LINK_SET,401,"",NULL_KEY);//Sends out the empty string, indicating that the weapon has been turned off
llSetText("Left PPC:\nTurned Off",<0,0,0>,1);
llOwnerSay("the weapon is turned off"); //debugging shiz
}


default

{
state_entry()
{
}

touch_end(integer total_number)
{
if (ready == FALSE)//if the weapon is turned off then turn it on, but only if it's online (not damaged)
{
llOwnerSay("I've been touched and the weapon was turned off");//Debugging shiz
if (online == TRUE)
{
llOwnerSay("The weapon is online and I am turning it on");//debugging shiz
on();

}
}
else if (ready == TRUE) // if the weapon is turned on, then turn it off.
{
llOwnerSay("I've been touched and the weapon was turned on. I am turning it off now");
off();
ready = FALSE;
}
}

attach(key attached) //Resets the status of the weapon when the HUD is attached
{
if (attached != NULL_KEY) // object has been attached
{
llOwnerSay("The HUD has just been attached so I'm setting the weapon status to off");
ready=FALSE;
}

}

link_message(integer sender_num, integer num, string message, key id)
{
if (num == 501)//Listens for the weapon status on "channel" 501
{
if (message =="off")//Will be sent out if/when the damage script determines that this weapon has been hit and is offline
{
online=FALSE;//The Weapon has been hit and is offline
off();
llSetText("Left PPC:\nOffline",<1,0,0>,1); //
}
if (message == "on")//Will be used with the reset button on the HUD to start a new game and reset everything back to undamaged and fully operational
{
online = TRUE;//weapon's status is online
}
}
if (num == 601)//"listens on channel 601" in the linked messages to set the status of the weapon if it is charging or not, but only if the weapon is online
{
if (message == "charging")
{
if (online == TRUE)
{
llSetText("Left PPC:\nCharging",<1,1,0>,1);
}
}
if (message == "ready")//if the firing script determines that this weapon is ready to fire again, then it will send out this message, but only if the weapon is online
{
if (online == TRUE)
{
llSetText("Left PPC:\nOnline",<0,1,0>,1);
}
}
}
}
}
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
11-29-2005 00:22
try adding a return after on(); in the touch end event.
_____________________