Jump to content

Selective unpacker ;)


Tattooshop
 Share

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

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

Recommended Posts

Hello there! ;)

I am trying to create an unpacker where one could use a button to select which objects to give away.

For example, I have three buttons on the HUD, and button1 gives out objects named object1a, object1b, and so on.

I just sketched something here, but I'm not sure if I'm on the right track. :D

string button = llGetLinkName(llDetectedLinkNumber(0));
if (button == "button1")
{
    llGiveInventoryList(llGetOwner(), llGetObjectName(object1a), InvenList);
    llGiveInventoryList(llGetOwner(), llGetObjectName(object1b), InvenList);
}

I have an unpacker, please help me add such a filter.

default
{
    touch_start(integer total_number)
    {
        integer x;
        for(x = 0; x < total_number; x++)
        {
            if(llDetectedKey(x) == llGetOwner())
            {
                string InvenName;
                integer InvenNumber = llGetInventoryNumber(INVENTORY_ALL);
                list InvenList = [];
                integer y;
                for(y = 0; y < InvenNumber; y++)
                {
                    InvenName = llGetInventoryName(INVENTORY_ALL, y);
                    if(InvenName != llGetScriptName()) InvenList += [InvenName];
                }
                llGiveInventoryList(llGetOwner(), llGetObjectName(), InvenList);
            }
        }
    }
}

 

Link to comment
Share on other sites

Well, it wasn't clear how many times you want to do this either, or how the things are named, or .....   so I left the details up to you. 

For example, you could put the names on a notecard and have your script read them into lists. 

Or if you have five objects, you could make five lists with one item in each list.

Or you could rename your objects alphabetically and then put items A-H in one list, I-P in a second list, and Q-Z in a third list. 

There are many ways to organize your items into separate lists.  The point is, once you have separate lists, you can have a button to hand out list A, a second button to hand out list B, and so forth.

  • Like 1
Link to comment
Share on other sites

integer gChan = -75;//I'm using an always open channel for simplicity.
list buttons = ["Average","Strange","Loony"];
list items = 
  [// "Average" items:
   "Carrot",
   "Pickle",
   "Cucumber",
   // "Strange" items:
   "Loose Spring",
   "Fancy Hat",
   // "Loony" Items:
   "Live Lobster",
   "Hippo's tooth",
   "Nest of dead Hornets" // no final ','
  ];
list item_extents =
  [ 0,2, // "Average" sub_list
    3,4, // "Strange" sub_list
    5,7  // "Loony" sub_list
  ];
default
{
    state_entry()
    {
      llListen(gChan,"",llGetOwner(),"");
      //^ this ensures owner-only; replace llGetOwner() with "" to open to public.
    }
    listen(integer Chan,string name, key ID,string text)
    {
       integer choice = llListFindList(buttons,text);
       if(choice!=-1)
       {
         integer range1 = llList2Integer(item_extents,choice*2);
         integer range2 = llList2Integer(item_extents,(choice*2)+1);
       	 llGiveInventoryList(ID, llGetObjectName(), llList2List(items,range1,range2));
       }else
       { // invalid button or other menu stuff.
       }
    }
    touch_start(integer n)
    {
        while(~--n)
        {
          key ID;
          if((ID=llDetectedKey(n))==llGetOwner())
          	//^^ remove above 2 lines for non-owner use 
          	llDialog(ID,"Pick a group to get items:",buttons,gChan);
          	// and replace ID with llDetectedKey(n)
        }
    }
}

I was bored; Untested code, probably has bugs.

Edited by Quistess Alpha
forgot a closing ];
  • Like 4
  • Thanks 2
Link to comment
Share on other sites

6 hours ago, Quistess Alpha said:
integer gChan = -75;//I'm using an always open channel for simplicity.
list buttons = ["Average","Strange","Loony"];
list items = 
  [// "Average" items:
   "Carrot",
   "Pickle",
   "Cucumber",
   // "Strange" items:
   "Loose Spring",
   "Fancy Hat",
   // "Loony" Items:
   "Live Lobster",
   "Hippo's tooth",
   "Nest of dead Hornets" // no final ','
  ];
list item_extents =
  [ 0,2, // "Average" sub_list
    3,4, // "Strange" sub_list
    5,7  // "Loony" sub_list
  ];
default
{
    state_entry()
    {
      llListen(gChan,"",llGetOwner(),"");
      //^ this ensures owner-only; replace llGetOwner() with "" to open to public.
    }
    listen(integer Chan,string name, key ID,string text)
    {
       integer choice = llListFindList(buttons,text);
       if(choice!=-1)
       {
         integer range1 = llList2Integer(item_extents,choice*2);
         integer range2 = llList2Integer(item_extents,(choice*2)+1);
       	 llGiveInventoryList(ID, llGetObjectName(), llList2List(items,range1,range2));
       }else
       { // invalid button or other menu stuff.
       }
    }
    touch_start(integer n)
    {
        while(~--n)
        {
          key ID;
          if((ID=llDetectedKey(n))==llGetOwner())
          	//^^ remove above 2 lines for non-owner use 
          	llDialog(ID,"Pick a group to get items:",buttons,gChan);
          	// and replace ID with llDetectedKey(n)
        }
    }
}

I was bored; Untested code, probably has bugs.

Hello there! Many many many thanks! The script is awesome! Everything works! :)👍

  • Like 5
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1015 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...