Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

HUD Button Help Needed!

Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-08-2007 09:57
Hi There;

I am trying to add HUD buttons to an existing Dragon Hud to control effects that i added to the AV (such as a new particle breath). The effect works when actuated by a gesture based trigger, but i would like to be able to customize further via the HUD. I have at the moment tried this:

For the HUD button:

integer channel = 51;

integer STB = FALSE;
string text;
default
{
touch_start(integer total_number)
{
if(STB == TRUE)
{
llSay(channel,"/BREATHSTART";);
llSetColor(<1,1,1>,ALL_SIDES);
text = "FireBreath On";
llSetText(text,<1,1,1>,1);
STB = FALSE;


}
else if(STB == FALSE)
{
llSay(channel,"/BREATHSTOP";);
llSetColor(<1,0,0>,ALL_SIDES);
text = "FireBreath Off";
llSetText(text,<1,1,1>,1);
STB = TRUE;


}

}
link_message(integer sender,integer num,string msg,key id)
{
if(msg == "HIDE";)
{
llSetAlpha(0,ALL_SIDES);
llSetText("",<1,1,1>,1);
state hidden;
}
}
}

state hidden
{
link_message(integer sender,integer num,string msg,key id)
{
if(msg == "SHOW";)
{
llSetAlpha(1,ALL_SIDES);
llSetText(text,<1,1,1>,1);
state default;
}
}
}


For the prim i have added to the AV's head to emit the particle effect:

ParticleStart()
{
llParticleSystem([
PSYS_PART_FLAGS, 307,
PSYS_SRC_PATTERN, 8,
PSYS_PART_START_ALPHA, 1.00,
PSYS_PART_END_ALPHA, 0.00,
PSYS_PART_START_COLOR, <1.00,0.00,1.00>,
PSYS_PART_END_COLOR, <1.00,1.00,0.00>,
PSYS_PART_START_SCALE, <0.05,0.05,0.00>,
PSYS_PART_END_SCALE, <10.00,10.00,0.00>,
PSYS_PART_MAX_AGE, 2.30,
PSYS_SRC_MAX_AGE, 0.00,
PSYS_SRC_ACCEL, <0.00,0.00,0.00>,
PSYS_SRC_ANGLE_BEGIN, 0.00,
PSYS_SRC_ANGLE_END, 0.07,
PSYS_SRC_BURST_PART_COUNT, 10,
PSYS_SRC_BURST_RADIUS, 0.10,
PSYS_SRC_BURST_RATE, 0.05,
PSYS_SRC_BURST_SPEED_MIN, 1.15,
PSYS_SRC_BURST_SPEED_MAX, 10.00,
PSYS_SRC_OMEGA, <0.00,0.00,0.00>,
PSYS_SRC_TEXTURE, "a96ecd50-96e1-28b4-51ec-96b3112210c0"
]);

}

ParticleStop()
{
llParticleSystem([]);
}

//*****************************************************************************
default
{
state_entry()
{
llListen( 51, "", "", "" );
}

listen( integer channel, string name, key id, string message )
{
if( message == "BREATHSTART" )
{
if (llGetOwnerKey(id) == llGetOwner())
ParticleStart();
}
else if( message == "BREATHSTOP" )
{
if (llGetOwnerKey(id) == llGetOwner())
ParticleStop();
}
}
}

It's my 1st try at a HUD command so lord knows what i'm off on ;), the basic approach on the button code was modified from an LCK open source HUD. The dragon HUD is a Daryth made wyrmling HUD if that is helpful to know.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
06-08-2007 13:57
Err what was your actual question?
_____________________
I'm back......
Vlad Bjornson
Virtual Gardener
Join date: 11 Nov 2005
Posts: 650
06-08-2007 14:17
You are saying "/BREATHSTART" and channel 51, but listening for "BREATHSTART" - with no slash. That would be my first guess at the problem.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
06-08-2007 18:29
if if if if if if if if if if if
Jim Guyot
Tinkerer
Join date: 21 Apr 2007
Posts: 38
06-08-2007 20:48
From: Vlad Bjornson
You are saying "/BREATHSTART" and channel 51, but listening for "BREATHSTART" - with no slash. That would be my first guess at the problem.


I would tend to agree here. While normally, an opening slash would eliminate the typing anim for an agent, I don't think it has any real effect when dealing with objects. /me does, however, work with objects.
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-10-2007 23:15
Well the question was intended to be what i needed to change for it to work, as it did not. I'll try the suggestion about the "/".
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
06-11-2007 00:55
Instead of
CODE

default
{
state_entry()
{
llListen( 51, "", "", "" );
}

listen( integer channel, string name, key id, string message )
{
if( message == "BREATHSTART" )
{
if (llGetOwnerKey(id) == llGetOwner())
ParticleStart();
}
else if( message == "BREATHSTOP" )
{
if (llGetOwnerKey(id) == llGetOwner())
ParticleStop();
}
}
}

you will want to do something like this:
CODE

default
{
on_rez(integer X) {llResetScript();}
state_entry()
{
ParticleStop(); // When rezzed, stop any particle effects that may be active
llListen(51,"",llGetOwner(),""); // To avoid abuse by other people, we filter the listen. Also, for HUDs and the like it is advised to use a negative chat channel as avatars cannot speak on those.
}

listen( integer channel, string name, key id, string message )
{
if (id == llgetOwner()) // Listen is filtered, but let's still check this...
{
if (message == "BREATHSTART") {ParticleStart();}
if (message == "BREATHSTOP") {ParticleStop();}
}
}
}


Because
if (llGetOwnerKey(id) == llGetOwner())
Just compares the owners key with itself and will ALWAYS return TRUE.
Also, you need to think about the order of your comparisons.
Try to avoid repetitive checks like you have in your script.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
06-11-2007 05:40
From: Squirrel Wood

if (llGetOwnerKey(id) == llGetOwner())
Just compares the owners key with itself and will ALWAYS return TRUE.
No, it compares if the owner of "id" (who/whatever is speaking) is the same as the script's owner, and that's what Celty wants. What you have above will only listen to chat from the owner. This is a HUD button, not an llDialog button, so the owner won't be speaking commands, the button object will.

And you want the second "if" to be an "else if", since message will never simultaneously be "BREATHSTART" *and* "BREATHSTOP", and there's no reason to test for the second condition if the first has already been met. But I agree with only a single owner test. In fact, I might even use:

if( llGetOwnerKey(id) != llGetOwner() )
return;

Just to avoid the extra level of indentation.
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-11-2007 07:05
Many thanks, it works now! Just getting rid of the "/" did it. What does not work is the portion governing the HUD to be minimized from a linked message, so that when the rest of this HUD goes to the "hidden" state the new button does not.

I assume this may have to do with the HUD using a different channel than the rest of the hud, but i'm not sure (though the HUD is mod, the scripts are not). In this case it's fine because i actually like the fire breath button accessible when the other controls are minimized.

However as i plan to do other additions to the HUD, it would be good to know how to make other added buttons respond to the linked message command.

Thanks again!
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
06-11-2007 07:06
Oh yes i'll try the suggestion as to cleaning up the checks on ownership :)