Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Attaching Object To HUD

Jaydin Normandy
Registered User
Join date: 1 Apr 2006
Posts: 19
07-22-2009 12:15
I have a HUD that I want everyone to be able to use. I realize that there are a lot of new users out there that don't understand how to attach a hud to your screen so I wanted to make it so that it would attach automatically. I have a poster that when touched will rez the hud in world and then another script inside the HUD will ask if you want to attach it to your screen. Here is the script that attaches it to your screen:

CODE

integer channel = 987654;

default
{
on_rez(integer start_param) {
llListen( 5, "", NULL_KEY, "" );

}
listen( integer channel, string name, key id, string message )
{
if(message == "delete")
{
llDie();
}
else{

llRequestPermissions((key)message, PERMISSION_ATTACH);
}
}

run_time_permissions(integer perm) {
if (perm & PERMISSION_ATTACH) {
llAttachToAvatar(ATTACH_HUD_BOTTOM_RIGHT);
}
}


}


The poster says your avatar key on channel 5 and then it asks to attach itself to that persons screen. This works flawlessly... with me. Every other person can't have it attach automatically because they are not the HUD owner. Is there anyway to get around this permissions problem?
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
07-22-2009 12:23
Two immediate possibilities ...

(a) Give the new user the HUD. Once they own it, they ought to be able to attach it.
(b) Forget the script. If you attach the HUD yourself and then save it to inventory, it will remember its attachment point. Then, when you give it to the next owner all she has to do is wear it. It will automatically attach as a HUD, at the spot you have designated.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
07-22-2009 12:54
The item rezzing the HUD must belong to the person the HUD is trying to attach to. There is no way around this. So give them a copy of the giver and have the rez it, if you want to do it that way.

But probably simpler to just give them the HUD directly, and name it "Whatever HUD (Wear Me)" . Wearing something isn't really that hard.
_____________________
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
07-22-2009 13:02
Incidentally, because monitor dimensions vary from one user to the next, people sometimes find that a HUD is off screen or at least poorly placed when it's attached. I've found that many people have no idea how to reposition a HUD on the screen, so I wrote a generic script that I use as a shell when I want to create a HUD. I add the actual working parts of the HUD to this script as a touch_start event.

When someone attaches the HUD, the initialization message tells them to type /99 help if they need to adjust it. If they do, it opens a blue dialog box with positioning buttons. This isn't a particularly elegant or tricky script, but it saves a lot of IMs from users who can't position their HUDs.

CODE

//Generic HUD Framework
//Rolig Loon, December 2008
//

integer ON;
vector CurrPos;
integer CHANNEL = -57;
list buttons = ["Done","Up","Down","Left","Right", "Rotate"];
integer dialog;
integer move;
init()
{
dialog = llListen(CHANNEL,"",NULL_KEY,"");
move = llListen(99,"",llGetOwner(),"");
}
setCur()
{
llDialog(llGetOwner(), "Can't see the HUD?" + "\n\n Move it with direction buttons." + "\n Click \"Done\" to end setup.", buttons, CHANNEL);
CurrPos = llGetLocalPos();
}

default {
on_rez(integer param)
{
llInstantMessage(llGetOwner(), "Welcome, " + llKey2Name(llGetOwner()) + ". Initalizing ...");
init();
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, < 1, 0, 0>, 0.5]);
ON = -1;
}

state_entry()
{
ON = -1;
init();
}

listen(integer channel, string name, key id, string message)
{
list temp = llParseString2List(message,["="],[]);
string tag = llToLower(llStringTrim(llList2String(temp,0),STRING_TRIM));
if (llToLower(message) == "help")
{
llSetPos(< 0.0,0.0,0.0>);
llSetLocalRot(ZERO_ROTATION);
setCur();
}
else if (message == "Done")
{
llListenRemove(dialog);
llListenRemove(move);
return;
}
else if (message == "Right")
{
llSetPos(CurrPos + < 0.0,-0.1,0.0>);
setCur();
}
else if (message == "Left")
{
llSetPos(CurrPos + < 0.0,0.1,0.0>);
setCur();
}
else if (message == "Up")
{
llSetPos(CurrPos + < 0.0,0.0,0.1>);
setCur();
}
else if (message == "Down")
{
llSetPos(CurrPos + < 0.0,0.0,-0.1>);
setCur();
}
else if (message == "Rotate")
{
rotation y_90 = llEuler2Rot( < 0, 90 * DEG_TO_RAD, 0> );
rotation new_rot = y_90 * llGetLocalRot();
llSetRot(new_rot);
setCur();
}
}

attach(key attached)
{
if (attached == NULL_KEY)
{
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, < 1, 0, 0>, 0.5]);
ON = -1;
}
else
{
llInstantMessage(llGetOwner(),"To adjust this HUD, type \" /99 help \".");
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, < 1, 0, 0>, 0.5]);
ON = -1;
llSetTimerEvent(300.0);
}
}

timer()
{
llListenRemove(dialog);
llListenRemove(move);
llSetTimerEvent(0.0);
}
}
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Jaydin Normandy
Registered User
Join date: 1 Apr 2006
Posts: 19
09-15-2009 08:26
Would it be possible to deed it to a group? Will it attach to users of a group if the HUD is owned by the group?
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
09-15-2009 09:11
From: Jaydin Normandy
Would it be possible to deed it to a group? Will it attach to users of a group if the HUD is owned by the group?

No. The object MUST be owned BY THE RESIDENT ATTACHING IT. If you think about it, this makes sense: all of your attached objects live in your inventory (whether they were attached from your inventory or from an object rezzed in-world).