Jump to content

llAttachToAvatar Question


JackRipper666
 Share

You are about to reply to a thread that has been inactive for 4430 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hey guys I'm puzzled by something with llAttachToAvatar. If I wanted to specify a part I built like a mesh object for example to be attached. How would I do that? I been looking on wiki but all it tends to show me is this  llAttachToAvatar(ATTACH_LHAND ); and it goes on to specify example (ATTACH_CHIN); What I am looking for is something where I can say either from the folder in my inventory where the obect I want to point to exists. Or if I can't do it that way put my object in the hud contents with the script. Then point to it some how with a string function maybe? I can't seem to figure out how to piece that together if anyone could help me out I'd appreciate it! 

 

 

Link to comment
Share on other sites

I'm not sure I completely understand where or what your exact problem is. It seems that you want to call a function from your inventory or the inventory of a HUD that attaches an object to the ava.

If this is the problem, the quick answer is: You can't. What you can do, however, is rez an object from another objects inventory and then attach it.

Link to comment
Share on other sites

Ok I had a feeling I wouldn't be able to do that but basically again what I am trying to do is take that llattachtoavatar function and use it differently from how it's show on wiki. where I could some how combined it's (ATTACH_CHIN) but tell the llattachtovatar function what I'm wanting to be attached to the chin which would be a object within the small hud I'm working on. This way it's not just attaching the hud to my face. Again so you're saying this is not possible? This is the code I was looking at for attachment that I was trying to modify.

//-- rez object on ground, drop in this script, it will request permissions to attach,
//-- and then attach to the left hand if permission is granted. if permission is denied,
//-- then the script complains.
default
{
state_entry()
{
llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );
}

run_time_permissions( integer vBitPermissions )
{
if( vBitPermissions & PERMISSION_ATTACH )
{
llAttachToAvatar( ATTACH_LHAND );
}
else
{
llOwnerSay( "Permission to attach denied" );
}
}

on_rez(integer rez)
{
if(!llGetAttached())
{ //reset the script if it's not attached.
llResetScript();
}
}

attach(key AvatarKey)
{
if(AvatarKey)
{//event is called on both attach and detach, but Key is only valid on attach
integer test = llGetAttached();
if (test) {
llOwnerSay( "The object is attached" );
} else {
llOwnerSay( "The object is not attached");
}
}
}
}

If that's the case and I understand what you said, you're saying I'd have to make a script for the hud where it would call the inventory object that I put in the HUD. But that script within the HUD would only be able to rez the object I'm trying to attach. Therefore the attachment would happen from the second script would only go inside the object that rezed and is going to be attached. As soon as it rezes in a sandbox for example that script starts running asking me to attach that object. Something like that?

Another example I'm looking at is this one where I only changed so far it's menu options to "Breath 1", "Breath 2" 

The only problem I'm having if that's how you do it, is how do I tell it to rez that object? Example this part here I'm trying to change 

else if (choice == "Breath 1") {
//do something       <<<<<<<<<<<<----------This part here I know I have to put a function to call Breath 1 object in the HUD right? I just don't know what function would rez it for me. Then script two inside that object would do the rest for attaching.
llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
}

Here is the rest of the example of the script that gives me dialog menu buttons.

list Objects = ["-", "Breath 1", "Breath 2"];
string msg = "Please make a choice.";
key ToucherID;
integer channel_dialog;
integer listen_id;

default{
state_entry() {
channel_dialog = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
llRequestPermissions(llGetOwner(),PERMISSION_ATTACH);
}

touch_start(integer total_number) {
ToucherID = llDetectedKey(0);
llDialog(ToucherID, msg, Objects, channel_dialog);
listen_id = llListen( channel_dialog, "", ToucherID, "");
llSetTimerEvent(60); //HERE WE SET A TIME LIMIT
}

listen(integer channel, string name, key id, string choice) {
if (choice == "-") {
llDialog(ToucherID, msg, Objects, channel_dialog);
}
else if (choice == "Breath 1") {
//do something
llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
}
else if (choice == "Breath 2") {
//do something
llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
}
else {
//do something else.
llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
}
}

timer() { //TIME’S UP!
llListenRemove(listen_id);
llWhisper(0, "Sorry. You snooze; you lose.");
llSetTimerEvent(0.0); //Stop the timer from being called repeatedly
}
}

 

Anyway sorry I know this is a lot of questions, just making my head hurt how to put it all together lol!

Link to comment
Share on other sites

ok - let me give you a step-by-step walkthrough of what I meant. Script 1 refers to the script that would go into the HUD, Script 2 is the one that would to into the object to be attached:

Script 1

  1. open your dialog and listen for the reply
  2. in the if statement, you rez the object corresponding to the dialog reply

Script 2

  1. in the on_rez event, you ask the permission to attach. As the key, you can use llGetOwner
  2. in the run_time_permissions event, if the permission to attach is granted, you use llAttachToAvatar to attach the object to the owner

I hope that makes clear what has to go in which object.

 

Link to comment
Share on other sites

Ok so far this is working thanks. But only thing I now have problem with is trying to do a detach of an object. I get this error 


Script trying to detach from agent but PERMISSION_ATTACH permission not set! I'm missing something. So here is script for the hud and beneath that one inside object that attaches. If I can solve that I probably have this done lol! Thanks though this is tedious work.

 

list Objects = ["-", "Breath 1", "Breath 2", "Detach"];
string msg = "Please make a choice.";
key ToucherID;
integer channel_dialog;
integer listen_id;
string Object = "Cold_Breath_Gorilla_Heavy_Breathing";
string Object2 = "Cold_Breath_Gorilla_No_Sound";

default{
state_entry() {
channel_dialog = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
llRequestPermissions(llGetOwner(),PERMISSION_ATTACH);
}
touch_start(integer total_number) {
ToucherID = llDetectedKey(0);
llDialog(ToucherID, msg, Objects, channel_dialog);
listen_id = llListen( channel_dialog, "", ToucherID, "");
llSetTimerEvent(60); //HERE WE SET A TIME LIMIT
}

listen(integer channel, string name, key id, string choice) {
if (choice == "-") {
llDialog(ToucherID, msg, Objects, channel_dialog);
}
else if (choice == "Breath 1") {
llRezObject(Object, llGetPos() + <0.0,0.0,1.0>, <0.0,0.0,0.0>, <0.0,0.0,0.0,1.0>, 0); //do something
llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
}
else if (choice == "Breath 2") {
llRezObject(Object2, llGetPos() + <0.0,0.0,1.0>, <0.0,0.0,0.0>, <0.0,0.0,0.0,1.0>, 0); //do something
llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
}
else if (choice == "Detach") {
llDetachFromAvatar();
llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
}
else {
//do something else.
llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
}
}

timer() { //TIME’S UP!
llListenRemove(listen_id);
llWhisper(0, "Sorry. You snooze; you lose.");
llSetTimerEvent(0.0); //Stop the timer from being called repeatedly
}
}

 

Script 2 inside attachment object....

 

// Cold breath physic's script with attachment

default
{
state_entry()
{
llSay(0, "Cold");

llLoopSound(llGetInventoryName(INVENTORY_SOUND,0),1);
llSetTimerEvent(2.7);
}
timer()
{
llParticleSystem([ PSYS_PART_MAX_AGE,0.8,
PSYS_PART_FLAGS,1,
PSYS_PART_START_COLOR, <1,1,1>,
PSYS_PART_END_COLOR, <1,1,1>,
PSYS_PART_START_SCALE,<0.1,0.1,0.1>,
PSYS_PART_END_SCALE,<0.2,0.2,0.2>,
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE,
PSYS_SRC_BURST_RATE,0.1,
PSYS_SRC_ACCEL, 0.8 * llRot2Fwd(llGetRot()),
PSYS_SRC_BURST_PART_COUNT,10,
PSYS_SRC_BURST_RADIUS,0.02,
PSYS_SRC_BURST_SPEED_MIN,0.0,
PSYS_SRC_BURST_SPEED_MAX,0.2,
PSYS_SRC_TARGET_KEY,llGetOwner(),
PSYS_SRC_ANGLE_BEGIN,0.0,
PSYS_SRC_ANGLE_END,0.0,
PSYS_SRC_OMEGA, <0.2,0.2,0.2>,
PSYS_SRC_MAX_AGE, 0.2,
PSYS_SRC_TEXTURE, "8146459e-47a2-47ce-93d6-bac9359afa84",
PSYS_PART_START_ALPHA, 0.3,
PSYS_PART_END_ALPHA, 0.1
]);
llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );
}
run_time_permissions( integer vBitPermissions )
{
if( vBitPermissions & PERMISSION_ATTACH )
{
llAttachToAvatar( ATTACH_CHIN );
}
else
{
llOwnerSay( "Permission to attach denied" );
}
}

on_rez(integer rez)
{
if(!llGetAttached())
{ //reset the script if it's not attached.
llResetScript();
}
}

attach(key AvatarKey)
{
if(AvatarKey)
{//event is called on both attach and detach, but Key is only valid on attach
integer test = llGetAttached();
if (test) {
llOwnerSay( "The object is attached" );
} else {
llOwnerSay( "The object is not attached");
}
}
}
}


Link to comment
Share on other sites

Hm.. well maybe I'm also going about this the wrong way to. Because as I rez the object in world from the button I click on the hud. I kinda assumed it would put that in objects creating multiples every time I clicked the button. I'm basiclly trying to build a small Hud that attached two different objects. From other huds I've used I don't know what they are doing but it works how I'd like it. Attaching the object only to detach it when say clicking a hide button or maybe now that I think of it it's still there I'll have to see lol. I'll take a look at created HUDs on wiki I recently ran into see what that says. Thanks man!

Link to comment
Share on other sites

You have that a lot with weapons and the like. Very often, the itmes are just made invisible.

But if you want to detach them, a script in the items would have to do that - but the HUD could 'tell' the script in the item to detach - that's the trick. The HUD does nbot detach the item, but tells the item to detach itself

Link to comment
Share on other sites

I think that what you want is to be able to attach any object in your inventory or hud inventory with a command, well you can't, but most here don't want to tell you that, lol, maybe the lindens will come out with an instruction were you can, but at the moment you can't, you can rez something to the ground and touch that to attach but you can't attach from the inventory with a command from another object, my drinks by rezzing then need to be bought(to change owner) then touch to wear, I would love to be able to attach from a hud inventory but can't, I made my drinks dispenser 2 years ago, but since then the lindens have new instructions for these realms games, their might be the ability for that with them, I don't know I haven't looked at them.

Link to comment
Share on other sites

@ Lucinda Bulloch, I see this is confusing. It would be nice though to just attach an object from the hud object. But have it act as not a new inventory item. Just not making duplicates of what is already in the HUD. I see really great huds I just don't know their secret lol. I can understand the reason to rettain that knowledge and not share it though. SL seems to be getting more and more competitive and hard to make the means to live lol. Unless you're very knowledgable. 

I might have to find some huds that are free that I can disect and see how it's built. I think I'll get lucky to find that but on second thought I need to look into it now that I think of it lol. Thanks!

Link to comment
Share on other sites

Yes, it would be great to be able to attach things out of a HUD, but that's not the way SL (or LSL) works.  You have to rez them, then attach them, and (when you're done) detach them.  That means that you get an extra copy in your OWN inventory every time, because there's no way to detach the object back into the HUD.  A couple of the new tools that LL has developed for use in Linden Realms will be able to solve part of that problem, so that copies don't pile up in your inventory, but you'll still have to rez and then attach.

Link to comment
Share on other sites

The only way I can think of, at the moment, to do what you describe involves the user having an RLV viewer and RLV turned on.   Then it's do-able -- check their #RLV folder to see if the item is there; if it is, attach it, and if it isn't, give it to them and force attach it as soon as they accept it.   But that's not going to work for most people.

The Linden Realms experience tools, if and when they get rolled out, may well make life a lot easier, but, until then, you're stuck.

 

Link to comment
Share on other sites

Yea I agree with both your comments. I think though it's done some how through a HUD that controls an Object within an object. Or at least that's one way. Just looking at other huds and how they are used. I usually have an attachment object and a HUD. I can't see into the contents of course but I can only assume one of the two objects has the other attachments inside it. They gotta be pulled from some where lol! I am new to coding and more of an artist anyway so I can see how I will have mental blocks here for quite awhile. If I figure it out though I'll post here how it's done. I just been so tied up for time again! Aren't we all?! lol

Link to comment
Share on other sites

There is no "object within an object".  Your inventory and the Contents of any object are nothing more than a species of lookup table that tells the servers where to find the description of each item listed.  The objects don't exist until you rez them, so there's no way to control them.  You're trying to invent to SL equivalent of a perpetual motion machine.  Fun to imagine, but not doable unless you step outside of the fundamental rules of SL and LSL with something like RLV, as Innula suggested. 

Link to comment
Share on other sites

The only other thing I can suggest is the "Lulu loophole", which allows you -- after a bit of setting up -- to rez items from a hud and they attach to you without asking permission, but when you detach them, they end up in your inventory.

But apart from that and RLV, at the moment  the only other way -- which is probably the best in a lot of circumstances -- is to wear the items and have the hud tell them when to show and hide themselves.

Link to comment
Share on other sites

@ Rolig...hmm I see this is more difficult then I realized lol. I guess i have two huds in mind actually. One with attaching and detaching and after that one hopefully move on to what I thought was an object with contents holding a couple objects in there and called on from a additional HUD object with a script. This is giving me some idea's at least  since I didn't realize it doesn't exist until rezzed.

 

@ Thans Innula, I guess though I want something I can make that doesn't require a certain viewer to make this work. An I'd still like to figure out how to make it where it doesn't create more inventory using loophole. I'm looking to do it more as sellable item for avatars I make so I don't think customers would be happy with me if it kept piling up inventory lol. Thanks though I'll have to keep looking soon possibly this weekend now that I have some free time. =)

Link to comment
Share on other sites

At the moment,  quite simply, you cannot do what you describe.   I don't care what you think you've seen -- I can guarantee you that, outside Linden Realms, it can't be done with LSL, so it can't have worked the way you think it did!

That may very well change when Experience Tools are rolled out, since, according to the blog post, they're hoping to introduce a temporary attachment call,  so it might be an idea to hold off making your item till then.

Link to comment
Share on other sites

Hello Innula, you're correctly about that. What I been confused on is how most HUD's are being created with what is capable in SL. Being that I'm not a programmer and came in late in the game with second life content creation. I was talking to Keiran Rotaru about some of his creations and HUDs and he explained to me that it's an .obj converted to a sculpt map which looks like a texture when you click it, but in world it forms the shape you built as an object outside of SL. So I was like wow, no wonder I been confused.  So this is one way that definitely will work using prim_type code to call your sculpt maps inside the object. I still need to learn how it all works exactly hopefully I can write some kind of example lol. Both my idea's would work this way attaching objects and also having a hud with say multiple armor sets or something. 

Link to comment
Share on other sites

Thanks.  That makes a lot of sense -- the function you need to look at, I think,  is llSetLinkPrimitiveParamsFast, which lets you do to prims by script almost everything you can with the edit window.

You don't actually need to put the sculptmaps inside the prim.   Instead, you can simply call them by their uuid, hard-coded in the script.   I would very strongly advise doing it that way, since otherwise the script will have to read the uuids of the sculptmaps it's applying to child prims, which it can only do if the sculptmaps contained in the prim are full perms, which you probably don't want them to be in something you're selling.

Link to comment
Share on other sites

Yea I'm noticing now there is two ways of doing it with sculpt maps either dropping them in. Or just as you said using the UUID copying that out of inventory that I guess SL generates for each item in your inventory once it's uploaded in world. Then I can just call that item by it's hard coded ID inside a script to give the sculpt prim it's shape I want. I can now call multiple sculpt maps just from script code. Which is really cool, I guess where my head hurts is if I do this I'm learning sculpt maps of an object tend to have UV map that is setup to not be touched if you're working inside say AC3D. So if I rebuild something I'm wondering how I'd get texture applied to the sculpt map. I know I could just drop sculpt map this time in the object instead of coding it to be called in the object with a script, but without a defined UV space I create outside of SL in another program I'm wondering how I'm going to get a texture applied to the object. I know you can bake things which I been playing with the ant available on wiki from SL. But in order to paint on a surface say I guess Zbrush what I'm familiar with usually I have to create a UV map first this way it remembers when I bring it in world where that paint texture is and will show up on the model. Sculpt maps again tend to want that UV to define it's shape in SL. I know I'm missing something if it's been done for a long time this way lol. So if I can figure out how to throw texture that will show up in the right spot on a sculpt map then I should be set on how that's done. lol

Link to comment
Share on other sites

While I'm not particularly familiar with the process of making sculpties with external programmes, and I don't know Zbrush at all, I do know that when you export your textured sculptie from the programme, and import it into SL, you end up with two textures -- the sculptmap itself (the rainbow-coloured .tga) and the texture you want to apply the exterior of the sculpted prim in SL.

So, if you're using llSetLinkPrimitiveParamsFast to tell prims what sort of sculptie they should be, you say something like

llSetLinkPrimitiveParamsFast(link_no,[PRIM_TYPE, PRIM_TYPE_SCULPT, "sculptmap uuid", PRIM_SCULPT_TYPE_SPHERE,PRIM_TEXTURE,ALL_SIDES,"texture uuid",repeats,offset,rotation]);

for each prim whose properties you are setting.   You will probably want to set rather more that that, of course -- PRIM_SIZE, PRIM_POS_LOCAL, and PRIM_ROT_LOCAL, maybe.

Link to comment
Share on other sites

Ah thanks again Innula! Yup that's definitely one way I might do it. I'm also seeing you can share UVmap space with a texture that is premade outside of SL. So say photoshop as long as I adjust it in photoshop to hit area's of a model or attachment I want I should get results. It's just harder to paint nurbs it seems since it's a 0 to 1 texture space they call it. An I'm still looking into how to paint that as well lol. Other then that though I now see how I can build stuff that has more control in SL using sculpt maps and scripted code. I just hope I can remember how it's all done LOL! 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4430 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...