Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Changing attachments via script

Roman Worters
Registered User
Join date: 5 Aug 2006
Posts: 14
07-31-2008 14:54
Hi people!

I've been looking for a script, that changes attachments via chat command.
Perfect would be, that it changes 3 attachments and gives out a spoken chatmessage

For example it changes my gloves and my boots and says "Hallo" in chat.

Tho the chatmessage is not the most important part, changing attachements would be enough...

Does somebody have a script of this kind?

As said, I need to change 2-3 attachments via command, like /1 change or so.

Greetings,
Roman
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
07-31-2008 15:45
It can be done without a custom client.

Thats not totally true, if the objects you want to attach are alreadey rezzed in world it can be done, but not if they are in inventory.

There are clients around that can do thism but without knowing you requirments i can't recommend one.
Trep Cosmo
Registered User
Join date: 3 Mar 2005
Posts: 101
07-31-2008 21:43
I may be wrong, my scripts are in disarray right now.

I attempted to do such a thing a while back and found that you can rez an attachment and a script inside can attach that item to your avatar. Also attachments can detach themselves via script.

So you have two or more objects: The master that handles rezzing on command, and the attachments you want to swap around.

The problem I had with it is that I ended up with a copy of the attachment after it detaches. I don't think there's a way to drop to the ground through a script. So no llDie() :(

I'll see if I can dig up my scripts and post them.
_____________________
"There is no 'I' in team, but there is a 'Me' if you scramble it." -- House
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-31-2008 22:41
You have it completely right Trep. That is exactly the state of things. You can attach from in-world, you can detach TO your inventory. That's it.
Trep Cosmo
Registered User
Join date: 3 Mar 2005
Posts: 101
07-31-2008 23:19
SL hadn't shredded this set of scripts yet. Yay!

It's a crude implementation. I think I wrote it in like 2 minutes flat.

This is the master script. The attachments you want to switch go inside the object holding this one:

CODE

integer giChannel = 23;

vector gvRezOffset = <0.0, 0.0, 1.0>;

default
{
state_entry()
{
llListen(giChannel, "", llGetOwner(), "");
}

listen(integer channel, string name, key id, string message)
{
list lBits = llParseString2List(message, [" "], []);
string sCmd = llToLower(llList2String(lBits, 0));
string sSub;

if(sCmd == "wear")
{
sSub = llToLower(llList2String(lBits, 1));

if(sSub == "small")
{
// Rez Leilany hair
llRezObject(
"Leilany",
llGetRootPosition() + gvRezOffset,
ZERO_VECTOR,
ZERO_ROTATION,
ATTACH_HEAD
);
}
else if(sSub == "medium")
{
// Rez Link hair
llRezObject(
"Link",
llGetRootPosition() + gvRezOffset,
ZERO_VECTOR,
ZERO_ROTATION,
ATTACH_HEAD
);
}
else if(sSub == "large")
{
// Rez Goldie hair
llRezObject(
"Goldie",
llGetRootPosition() + gvRezOffset,
ZERO_VECTOR,
ZERO_ROTATION,
ATTACH_HEAD
);
}
else
{
llOwnerSay("Unknown hair size. Valid sizes are: Small, Medium, Large");
}
}
else
{
llOwnerSay("Unkown command. Valid commands are: Wear");
}
}

on_rez(integer start_param)
{
llResetScript();
}
}


And this is the slave script. Each attachment inside the master need this:

CODE

integer giAttachPos = ATTACH_HEAD;

default
{
attach(key attached)
{
if(attached != NULL_KEY)
{
// Attached
state wear;
}
else
{
llDie();
}
}

on_rez(integer start_param)
{
if(start_param != 0)
{
giAttachPos = start_param;
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
}
}

run_time_permissions(integer perm)
{
if(perm & PERMISSION_ATTACH)
{
llAttachToAvatar(giAttachPos);
}
else
{
llOwnerSay("Error: I need permission to attach to you. Please try again.");
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
}
}
}

state wear
{
attach(key attached)
{
if(attached == NULL_KEY)
{
llDie();
}
}
}


Ooh! Look! I came up with a stupid way to clean up the inventory. After you switch attachments you're left with a copy in your inventory. So I put a check for a null-rez or whatever you'd like to call it. It llDie()s the item if it didn't get rezzed by the master.
_____________________
"There is no 'I' in team, but there is a 'Me' if you scramble it." -- House
Roman Worters
Registered User
Join date: 5 Aug 2006
Posts: 14
08-02-2008 19:14
so it needs to be rezzed in world? well, i would have needed this for no build zones, but since it seems impossible, i say thanks to all your help :)
Hopefully they'll implent a way to do that via inventory