MIVIMEX Posted December 1, 2018 Share Posted December 1, 2018 (edited) Hello! I'm trying to create a simple unpacker giving all content to the owner on rez and self-deleting. I have reviewed a bunch of scripts but they are all very difficult for a beginner. Please tell me how to start and where to go? that's what i have for now but it dont work... thanks for any help! default { on_rez(integer start_param) { llGiveInventory(llGetOwner(), llGetInventoryName(INVENTORY_OBJECT)); llDie; } } Edited December 1, 2018 by MIVIMEX Link to comment Share on other sites More sharing options...
Wandering Soulstar Posted December 1, 2018 Share Posted December 1, 2018 The problem is that llGiveInventory takes a string as it's second parameter, not an integer. And that string is the name of the inventory item to give. What you'll need to do is using llGetInventoryNumber, and llGetInventoryName, compile a list of the inventory items and then best use llGiveInventoryList to give the items to the AV. 1 Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted December 1, 2018 Share Posted December 1, 2018 (edited) All you need is to loop through the object's inventory and store all the names into a list, then send them with llGiveInventoryList. I guess the confusing part was you trying to use the function to send one item at a time. Edited December 1, 2018 by Wulfie Reanimator 1 Link to comment Share on other sites More sharing options...
MIVIMEX Posted December 1, 2018 Author Share Posted December 1, 2018 8 minutes ago, Wulfie Reanimator said: All you need is to loop through the object's inventory and store all the names into a list, then send them with llGiveInventoryList. What's the confusing part? @Wandering Soulstar @Wulfie Reanimator Thank you very much for the answers. the most confusing part is now how to get this list? default { on_rez(integer start_param) { llGiveInventory(llGetOwner(), llGetInventoryName(INVENTORY_OBJECT)); llGiveInventoryList(llGetOwner(), List); } } Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted December 1, 2018 Share Posted December 1, 2018 Just now, MIVIMEX said: @Wandering Soulstar @Wulfie Reanimator Thank you very much for the answers. the most confusing part is now how to get this list? default { on_rez(integer start_param) { llGiveInventory(llGetOwner(), llGetInventoryName(INVENTORY_OBJECT)); llGiveInventoryList(llGetOwner(), List); } } If you read the wiki page, it's really as simple as: list inventory; integer i; while(i < llGetInventoryNumber(INVENTORY_ALL)) { inventory += llGetInventoryName(INVENTORY_ALL, i); ++i; } Of course, if you (probably) don't want to send the unpacker script as well, you need to check if GetInventoryName matches GetScriptName. Then, if you think someone might put no-transfer or no-copy items into the contents, you can check for that with GetInventoryPermMask. 1 Link to comment Share on other sites More sharing options...
MIVIMEX Posted December 1, 2018 Author Share Posted December 1, 2018 17 minutes ago, Wulfie Reanimator said: If you read the wiki page, it's really as simple as: list inventory; integer i; while(i < llGetInventoryNumber(INVENTORY_ALL)) { inventory += llGetInventoryName(INVENTORY_ALL, i); ++i; } Oh thanks! where does this part go? and what does ++ mean? default { on_rez(integer start_param) { list inventory; integer i; while (i < llGetInventoryNumber(INVENTORY_ALL)) { inventory += llGetInventoryName(INVENTORY_ALL, i); ++i; llGiveInventoryList(llGetOwner(), inventory); } } } Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted December 1, 2018 Share Posted December 1, 2018 (edited) 9 minutes ago, MIVIMEX said: Oh thanks! where does this part go? and what does ++ mean? Sorry, I'm making too many assumptions. The bit of code I showed only fills that list, you can put it anywhere you want, where you need that list to be created. At the beginning of on_rez like you showed is fine. "++" means "increment," it can only be used with integer variables and it increases the value by one. It has some small technical details involved but that's not very important here. You should rewrite the loop in a way you understand. Lastly, you should not put llGiveInventoryList into the loop, otherwise you're sending a folder with one item, then a folder with two items, then a folder with three items... Put it outside of the loop, after it has finished, so that you only send one folder with all of the items found. Edited December 1, 2018 by Wulfie Reanimator 1 Link to comment Share on other sites More sharing options...
Xiija Posted December 2, 2018 Share Posted December 2, 2018 i have an old unpacker that is free / open source.. dunno if lookin at the code will help ya... https://marketplace.secondlife.com/p/XMODS-Unpacker-Box-v-20/5872695 1 1 Link to comment Share on other sites More sharing options...
Innula Zenovka Posted December 2, 2018 Share Posted December 2, 2018 @MIVIMEXHere's a fully commented example, which may help. Note that in a production version, I'd include some tests to make sure the objects are all copyable by the new owner. If they aren't, then llGiveInventoryList won't give them to the owner, and you need to give them separately, one at a time, using llGiveInventory. If you need help with that, please ask, but this, I hope, will help explain what we're talking about: list lContents; string strFolderName = "A folder of goodies";// change to the name you want for your folder default { state_entry() {//some preliminary work to set things up //first, populate the lContents list string strThisScript = llGetScriptName();//note the name of this script, since you don't want to give that as part of the folder integer max = llGetInventoryNumber(INVENTORY_ALL);//note the number of items in the object's inventory integer counter = 0; do{ string str = llGetInventoryName(INVENTORY_ALL, counter);//check the name of each item if(str!=strThisScript){//and if it's not this script lContents +=[str];//add the name to lContents } } while(++counter < max);//and keep on doing this, advancing the counter each time, until all items have been checked. if(llStringLength(strFolderName)== 0){//sanity check -- if no folder name is provided strFolderName = llGetObjectName();//then use the name of this object for the folder } } changed(integer change) { if(change & CHANGED_INVENTORY){//if the contents of the object's inventory change llResetScript();//then reset the script in order to rebuild the list } else if(change & CHANGED_OWNER){//if the object's owner changes, give the folder to the new owner llGiveInventoryList(llGetOwner(), strFolderName,lContents);//give the folder to the new owner } } attach(key id) { if(id){//if someone attaches the object llGiveInventoryList(id, strFolderName,lContents);//give them the folder } } } 1 Link to comment Share on other sites More sharing options...
MIVIMEX Posted December 6, 2018 Author Share Posted December 6, 2018 @Innula Zenovka Thank you very much, I was already desperate, having decided that this is not the easiest script to start with, but with your comments everything will become clear! thank you! Link to comment Share on other sites More sharing options...
steph Arnott Posted December 9, 2018 Share Posted December 9, 2018 I do not bother with those scripts any more. I just pass one file with everything in it. That is old hat stuff. Link to comment Share on other sites More sharing options...
Recommended Posts
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