Jump to content
Sign in to follow this  
KellyM Watkins

Adding Two Scripts To One

Recommended Posts

I have a couple of scripts that I have found on the LSL wiki and would like to combine them together. One is an Animate When Attached and the other is the Unpacker script (give inventory to folder). Trying to add them together, but my scripting knowliedge is not all that great.

Could someone help me?

Thanks.:matte-motes-kiss:

Share this post


Link to post
Share on other sites

Duh, that would help lol They are as follows:

Give Inventory (Unpacker)

 

// script created by SpiritWolf Chikuwa// minor changes by Strife Onizuka to speed things up//// /!\ PUBLIC DOMAIN /!\// You can Copy/Mod/Trans // Please, do not resell this script and give it full perm// Just please leave this header intact//// Minor changes: (insert your name here and delete this comment if you do any mod of this script, thank you)//// Script start here: list    gInventoryList; list getInventoryList(){    list       result = [];    integer    n = llGetInventoryNumber(INVENTORY_ALL);     while(n)        result = llGetInventoryName(INVENTORY_ALL, --n) + result;     return result;} default{    state_entry()    {        gInventoryList = getInventoryList();    }     touch_start( integer n )    {        integer i = 0;        string folder = llGetObjectName();         while(i < n)        {            llGiveInventoryList(llDetectedKey(i), folder, gInventoryList );            ++i;        }    }     changed( integer change )    {       if ( change == CHANGED_INVENTORY )           gInventoryList = getInventoryList();    }} // llGetInventory number and name will scan all objects on the box.// llGiveInventory will give you the content.// See also llGetInventory and llGiveInventory on LSL Wiki for further informations.

and

 

Animate on Attach

 

/*Bornslippy Ruby  presents...Start Animation On AttachThis script can handle: Animations, Attachments, Owner, Permissions, todoCopyright © 2010 Bornslippy RubyPermission is hereby granted, free of charge, to any person obtaining acopy of this software and associated documentation files (the "Start Animation On Attach"), todeal in Start Animation On Attach without restriction, including without limitation the rights touse, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of Start Animation On Attach, and to permit persons to whom Start Animation On Attach is furnished to do so,subject to the following conditions:The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIESOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISINGFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OROTHER DEALINGS IN THE SOFTWARE.http://secondlife.coolminds.org*/string HOLD_ANIM = "animation name";// --------------------------------------------------------default{    on_rez(integer rezzed)    {        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);    }        attach(key attached)    {        if(attached != llGetOwner())            if(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)                llStopAnimation(HOLD_ANIM);    }        run_time_permissions(integer perms)    {        if(perms & PERMISSION_TRIGGER_ANIMATION)            llStartAnimation(HOLD_ANIM);        else            llDetachFromAvatar();    }}

 

 

Share this post


Link to post
Share on other sites

Here you go. I rewrote it myself since I didn't want to deal with all that copyright stuff the one guy had.

If you attach it, it starts an animation to hold it. If you drop it, it won't. If you click it, it gives its inventory.

 

//Original portions by SpiritWolf Chikuwa, with modification by Strife Onizuka
//Modification by Acheron Gloom
//Public Domain, non-commercial, leave header intact.

string holdAnim = "Put the animation between these quotes, leave the quotes intact";

list gInventoryList;
list getInventoryList()
{
    list       result = [];
    integer    n = llGetInventoryNumber(INVENTORY_ALL);
    string scriptName = llGetScriptName();
   
    do
    {
        string invName = llGetInventoryName(INVENTORY_ALL, --n);
        if(invName != holdAnim && invName != scriptName)
            result = invName + result;
    }while(n);
 
    return result;
}
 
default
{
    state_entry()
    {
        gInventoryList = getInventoryList();
    }
  
    attach(key id)
    {
        if(id)
        {
            llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
            llStartAnimation(holdAnim);
        }
        else if(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
            llStopAnimation(holdAnim);
    }
 
    touch_start( integer n )
    {
        string folder = llGetObjectName();
        do
        {
            llGiveInventoryList(llDetectedKey(--n), folder, gInventoryList );
        }while(n);
    }
}

 

Share this post


Link to post
Share on other sites

This should work:

 

// script created by SpiritWolf Chikuwa // combined with another script © 2010 by Bornslippy Ruby// minor changes by Strife Onizuka to speed things uplist    gInventoryList;string  HOLD_ANIM = "animation name"; list getInventoryList(){    list       result = [];    integer    n = llGetInventoryNumber(INVENTORY_ALL);     while(n)        result = llGetInventoryName(INVENTORY_ALL, --n) + result;     return result;} default{    state_entry()    {        gInventoryList = getInventoryList();    }        on_rez(integer rezzed)    {        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);    }    run_time_permissions(integer perms)    {        if(perms & PERMISSION_TRIGGER_ANIMATION)            llStartAnimation(HOLD_ANIM);        else            llDetachFromAvatar();    }     touch_start( integer n )    {        integer i = 0;        string folder = llGetObjectName();         while(i < n)        {            llGiveInventoryList(llDetectedKey(i), folder, gInventoryList );            ++i;        }    }     changed( integer change )    {       if ( change == CHANGED_INVENTORY )           gInventoryList = getInventoryList();    }}

 

 

 

Share this post


Link to post
Share on other sites

how will this script work? I mean, attache from inventory? If they rez it, should it ask to be attached and then do so? This is sort of important....OR, is it click and then animate and do stuff?

Share this post


Link to post
Share on other sites


Poenald Palen wrote:

how will this script work? I mean, attache from inventory? If they rez it, should it ask to be attached and then do so? This is sort of important....OR, is it click and then animate and do stuff?

 

As far as I can see, the object (a sales box or shopping bag) is meant to be rezzed on the ground. It will unpack when clicked and also ask for permission to animate the object owner.

ETA: Although, seeing that the animation is called HOLD_ANIM, I guess it's meant to be attached after all. But if it's a sales box, not many people will do that.

Share this post


Link to post
Share on other sites

It's for a bag. I am redoing my vendors in my store. Person pays vendor > vendor gives bag.

 

The bag will have the items inside and just thought it would be neat to have the avatar holding the bag, hence the animation script. The avatar can touch the bag to open it's contents into their inventory.

Share this post


Link to post
Share on other sites

I edited my original post to not send the animation or the script with the rest of the contents.

 

By the way, you should try out scripting yourself. It isn't too hard ;p. LSL is a decent intro into programming actually since most of the functions use common english and theres a wiki full of information to use right off the bat. Plus the developing environment is pretty easy to get used to, being Second Life and all.

Share this post


Link to post
Share on other sites

Thank you so much!

 

I have tried to dabble with scripts a few times, I am learning slowly on everything, just this had stumped me with trying to add two scripts together like this.

Share this post


Link to post
Share on other sites

Well, honestly all you really had to do for those two was throw all the events together since they both used entirely seperate events and nothing else would have conflicted.

 

Just keep in mind you can't have two of the same events, so thats when you actually have to copy paste some code between them and see if you can work stuff out.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×