Advertisement
Guest User

Permissions Inventory Report

a guest
Aug 24th, 2019
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This code fragment will not compile on its own and will need to be placed in a more complete script.
  2. // These functions will look at items in inventory of the prim and report on their permission status.
  3. //
  4. // Published under Creative Commons License by Ryonen Moon 8/24/2019
  5. // You may use this code in your own work, even for commercial products.
  6. // The only limitation I place is that you may not sell this code, nor represent it as your own.
  7. //
  8.  
  9. // Return a short string representing the perms mask. "C__" = Copy only, "C_T" = Copy and Transfer, "CMT" Copy, Modify, and Transfer
  10. string permsMaskString(integer perms)
  11. {
  12.     string result;
  13.  
  14.     if ((perms & PERM_COPY) == PERM_COPY)
  15.         result += "C";
  16.     else
  17.         result += "_";
  18.  
  19.     if ((perms & PERM_MODIFY) == PERM_MODIFY)
  20.         result += "M";
  21.     else
  22.         result += "_";
  23.  
  24.     if ((perms & PERM_TRANSFER) == PERM_TRANSFER)
  25.         result += "T";
  26.     else
  27.         result += "_";
  28.  
  29.     return result;
  30. }
  31.  
  32.  
  33. // Chat a permissions overview of all inventory items
  34. reportInventoryPerms()
  35. {
  36.     integer i;
  37.     integer copyOnly;
  38.     integer n = llGetInventoryNumber(INVENTORY_ALL);
  39.     string  report;
  40.     list    reportParts;
  41.  
  42.     llOwnerSay("Permissions Report");
  43.  
  44.    
  45.     for( i = 0; i < n; i++ ) {
  46.        
  47.         string  name =  llGetInventoryName(INVENTORY_ALL, i);
  48.         integer permsBase = llGetInventoryPermMask(name, MASK_BASE);
  49.         integer permsNextOwner = llGetInventoryPermMask(name, MASK_NEXT);
  50.         string  permsOut = permsMaskString(permsBase) + " " + permsMaskString(permsNextOwner);
  51.  
  52.         if ((permsNextOwner & PERM_COPY) && (!(permsNextOwner & PERM_MODIFY)) && (!(permsNextOwner & PERM_TRANSFER)))
  53.             copyOnly += 1;
  54.         else {
  55.             string s = " " + permsOut + "  .. " + name + "\n";
  56.  
  57.             if ((llStringLength(report) + llStringLength(s)) < 1024)
  58.                 report += s;
  59.             else {
  60.                 reportParts += report;
  61.                 report = s;
  62.             }
  63.         }
  64.     }
  65.     reportParts += report;
  66.  
  67.     if (copyOnly < n) {
  68.         llOwnerSay("Base Next");
  69.  
  70.         integer j;
  71.         integer len = llGetListLength(reportParts);
  72.  
  73.         do
  74.         {
  75.             string s = llList2String(reportParts, j);
  76.             llOwnerSay(s);
  77.         }
  78.         while (++j < len);
  79.     }
  80.  
  81.     llOwnerSay ("\n" + (string)n + " Total Items");
  82.     llOwnerSay ((string)copyOnly + " Copy Only");
  83.     llOwnerSay ((string)(n - copyOnly) + " Item(s) of Concern\n");
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement