Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Making a hud to control a seperate object..how to make it work for only owner.

Tatayana Wylder
Registered User
Join date: 8 Jan 2010
Posts: 3
01-08-2010 12:14
Ok, so... I want to make a simple button on my hud that talks to a prim, usually attached at some point to the body, and tells it to turn on or off a bling script inside said prim.
But also, want it to be secure so that if two people with he same
hud are in a room, and press the button, it doesn't effect the other persons prim.
Basically the bling script is listening for bling on, or bling off on a specific channel, it works great with the hud item if its just a regular whisper, but, anyone can still control it. How do i secure it to an individual avatar?

thanks much to any who reply!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-08-2010 12:41
in the attachments scripts listen code..
CODE

listen( integer vIntChn, string vStrNom, key vKeySpk, string vStrMsg ){
if (llGetOwnerKey( vKeySpk ) == llGetOwner()){
//-- only runs if the speakers key has the same owner, or is the owner
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-08-2010 12:45
From: Void Singer
in the attachments scripts listen code..
CODE

listen( integer vIntChn, string vStrNom, key vKeySpk, string vStrMsg ){
if (llGetOwnerKey( vKeySpk ) == llGetOwner()){
//-- only runs if the speakers key has the same owner, or is the owner
}
}

An excellent snippet to remember.

Could also have the object do the llListen to only listen to the owner. Just make sure to have use the changed event and watch for changes to the owner (or llResetScript in on_rez).
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-08-2010 12:58
From: Meade Paravane
An excellent snippet to remember.

Could also have the object do the llListen to only listen to the owner. Just make sure to have use the changed event and watch for changes to the owner (or llResetScript in on_rez).

only owner won't work for a hud com to the attachment

for items that a single av may owner more than one of, you'll have to do additional filtering

also beware of generic commands, or operating on them without checking the source, as other objects owned by the same av may use the same thing. it'll prevent you from receiving messages not meant for your stuff, or sending commands to stuff you didn't make ;)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-08-2010 13:05
From: Void Singer
only owner won't work for a hud com to the attachment

Oh. Duh. Right. I knew that..

/me goes in search of a coffee maker. Darn Friday afternoons.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Tatayana Wylder
Registered User
Join date: 8 Jan 2010
Posts: 3
01-08-2010 14:18
thank you for the quick response. I think I get it now! Will take some time to break down each individual part so I can actually retain this knowledge but its a big big help!

edit:

Guess I am too slow to get this to work correctly right off. So. Wish me luck. I am going to try it on a simpler script first, then rewrite my own particle effect script from the ground up. I am such a newb but it all helps me learn so whhhy not!

edit 2:

Yup... I fail... is there a longer explanation of that someone might be willing to contribute.. :) Pretty please :)
Indeterminate Schism
Registered User
Join date: 24 May 2008
Posts: 236
01-09-2010 09:01
// HUD script
integer BlingOn;

default
{
state_entry()
{
llSetObjectName("Bling HUD";); // <== This is so a single person can have more than one HUD/object controller
}

touch_start(integer HowMany)
{
BlingOn = !BlingOn;
llWhisper(-2002, (string) BlingOn);
}
}

--------------------------------------------------------------------------------

// Object script
default
{
listen(integer ChannelIn, string FromName, key FromID, string Message)
{
if (llGetOwnerKey(FromID) == llGetOwner())
{
if (Message == (string) TRUE)
{
// PUT YOUR BLING 'ON' INSTRUCTIONS HERE
}
else
{
// PUT YOUR BLING 'OFF' INSTRUCTIONS HERE
}
}
}

state_entry()
{
llListen(-2002, "Bling HUD", NULL_KEY, "";); // <== Has to match the name of the HUD
}
}
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
01-09-2010 09:25
What's happening there, Tatiana (I had to think about it for a moment, you see) is that the value of the integer BlingOn, in the hud script, switches between TRUE and FALSE each time you touch the hud.

Each time the value changes, the script converts the new value to a string, because it has to do that to "say" it, and says it. The bling script then converts what it hears back to an integer value and determines if it's TRUE or FALSE.

If it's TRUE, turn the bling on, otherwise turn it off.
Tatayana Wylder
Registered User
Join date: 8 Jan 2010
Posts: 3
01-11-2010 10:13
Perfect. That helped me 100% as well as taught me a lot. Thank you to everyone that posted in response to my question... Its so nice to have a supportive community!
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
01-11-2010 14:23
From: Meade Paravane
Oh. Duh. Right. I knew that..

/me goes in search of a coffee maker. Darn Friday afternoons.


No worries, I was about to make the same mistake (long day).
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey