Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Attach HUD automatically

Roy Naidoo
Registered User
Join date: 11 Jul 2008
Posts: 3
07-15-2008 13:41
Hi,

I'm trying to attach a HUD automatically. This is what I'm doing

- I touch an in world object
- I rez the HUD into the world
- Get permission to attach the HUD

I have been able to attach it automatically, if i own the HUD. Is there any way to work around this for any users touching the object.

HELP!!! :(
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-15-2008 15:03
No. You'll have to give them a copy using llGiveInventory() or llGiveInventoryList() and ask them to kindly attach it or rez it in-world so that it can attach automatically (since the rezzed copy will then belong to them). Harsh but true.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-15-2008 18:43
You can get kind of close, if you can set the attachment for sale as Original, and use a script something like this:

CODE

default
{
state_entry()
{
llSetClickAction(CLICK_ACTION_BUY);
}
changed(integer change)
{
if (change & CHANGED_OWNER)
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
}

run_time_permissions(integer perms)
{
if (perms & PERMISSION_ATTACH)
llAttachToAvatar(ATTACH_HUD_CENTER_1);
}
}


Any attachment has to be owned by the person to whom it gets attached, so it's just necessary for the HUD to come into the possession of the wearer. With the llSetClickAction*, the wearer just has to click the object to buy it (presumably for L$0), then accept the PERMISSION_ATTACH request. It's arguably slightly less cumbersome than hunting through Inventory to find and wear the thing. The object has to be set for sale as Original because a Copy will go into the buyer's Inventory, and CHANGED_OWNER won't happen in that copy until it's rezzed in-world.

Also, things that are attached directly from in-world may have surprises. One example--not relevant to HUDs--is http://jira.secondlife.com/browse/SVC-1765.

__________
* Of course you can do this in the Editor, too, and llSetClickAction() is most useful for changing behavior to reflect a change in the script state. But I like the fact the function exists since 1.19.1, so used it here for no good reason.
_____________________
Archived for Your Protection
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-15-2008 21:54
From: Qie Niangao
You can get kind of close, if you can set the attachment for sale as Original, and use a script something like....

Except that I don't believe anything rezzed from object inventory will be set for sale will it? That means you'd have to pre-rez and manually set a bunch of them, and then come back and do it again as soon as they are used up.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-16-2008 03:36
If it was set for sale when it was put in the object inventory, it will be for sale when rezzed from inventory. Or at least that's how it's worked for me in the past, and seems to be working as I test it again now.

I did forget to mention that, to test the attach-on-buy thing, one needs an accomplice to do the buying so that the object owner actually changes. That's as it should be; one just has to schedule testing around the alt's busy social calendar. ;)
_____________________
Archived for Your Protection
Cheree Bury
ChereeMotion Owner
Join date: 6 Jun 2007
Posts: 666
07-16-2008 05:07
From: Qie Niangao
one just has to schedule testing around the alt's busy social calendar. ;)


If your alt knows my alt, could you get a message to her that I have some work for her to do? That tramp is never online when I am anymore.
Roy Naidoo
Registered User
Join date: 11 Jul 2008
Posts: 3
It works!!
07-16-2008 11:18
Hey

Thank you. It works for all other user expect the user that actually owns the object. I guess that is because I already own the object so I can't buy the object. So it doesn't trigger the change function.