ZenMondo's Mailbox

From ZenMondo Wormser, 1 Year ago, written in Linden Scripting, viewed 404 times.
URL http://flynnos.org/flynnbin/view/633c2a0c Embed
Download Paste or View Raw
  1. //////////////////////////////////////
  2. // ZenMondo's Mailbox by ZenMondo Wormser
  3. //
  4. // Displays Online Status, as well as accepting
  5. // notecard "mail" to be be delivered to owner.
  6. //
  7. // Cleans Up after itself, deletes non-notecards.
  8. //
  9. //
  10. // LICENSE:
  11. //
  12. //  This script is given for free, and may NOT be
  13. //  resold or used in a commercial product.
  14. //  You may copy and distribute this script for free.
  15. //  When you redistribute or copy this script, you must
  16. //  do so with FULL PERMS (modify, copy, and transfer),
  17. //  and leave this notice intact.
  18. //
  19. //  You are free to modify this code, but any derivitive
  20. //  scripts must not be used in a commercial product or
  21. //  or sold, and must contain this license.  
  22. //
  23. //  This script is provided free for learning
  24. //  purposes, take it apart, break it, fix it,
  25. //  learn something.  If you come up with something
  26. //  clever, share it.
  27. //
  28. //  Questions about codepoetry (scripting) can always be addressed
  29. //  to me, ZenMondo Wormser.
  30. //
  31. /////////////////////////////////////////
  32.  
  33. key online_query;
  34.  
  35. key name_query;
  36.  
  37. string user_name;
  38.  
  39. {
  40.     state_entry()
  41.     {
  42.         llAllowInventoryDrop(TRUE);
  43.         name_query = llRequestAgentData(llGetOwner(), DATA_NAME);
  44.         llSetText("Setting Up, Ready in one minute.", <0,1,1>, 1.0);
  45.         llSetTimerEvent(60);
  46.        
  47.        
  48.     }
  49.  
  50.     timer()
  51.     {
  52.         online_query = llRequestAgentData(llGetOwner(),DATA_ONLINE);          
  53.     }
  54.    
  55.     dataserver(key queryid, string data)
  56.     {
  57.        
  58.         if(queryid == name_query)
  59.         {
  60.             user_name = data;
  61.             //llSay(0, data + " " + user_name);
  62.         }
  63.        
  64.         if(queryid == online_query)
  65.         {
  66.             integer online = (integer) data;
  67.        
  68.             if(online)
  69.             {
  70.                 llSetText(user_name + "\nIs ONLINE\nDrop a NoteCard into me to Send " + user_name + " a message.", <0,1,0>, 1.0);
  71.                 return;  
  72.             }
  73.        
  74.             else
  75.             {
  76.                 llSetText(user_name + "\nIs OFFLINE\nDrop a NoteCard into me to Send " + user_name + " a message.", <1,0,0>, 1.0);
  77.                 return;
  78.             }
  79.        
  80.         }    
  81.     }
  82.    
  83.     changed(integer mask)
  84.     {
  85.         if(mask & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY))
  86.         {
  87.             integer num_notes = llGetInventoryNumber(INVENTORY_NOTECARD);
  88.            
  89.             if(num_notes > 0)
  90.             {
  91.                 string note_name = llGetInventoryName(INVENTORY_NOTECARD, 0);
  92.                            
  93.                 llSay(0, "Sending Notecard, '" + note_name +"' please stand by.");
  94.            
  95.                 llGiveInventory(llGetOwner(), note_name);
  96.                
  97.                 llInstantMessage(llGetOwner(), "A NoteCard has been sent to you: " + note_name);
  98.                 llSay(0, "The Notecard, " + note_name + " has been sent. Thank you.");
  99.                
  100.            
  101.                 llRemoveInventory(note_name);
  102.                
  103.                 num_notes = llGetInventoryNumber(INVENTORY_NOTECARD);
  104.                
  105.                 while(num_notes > 0) // They dropped more than one notecard. Clean it up
  106.                 {  
  107.                     note_name = llGetInventoryName(INVENTORY_NOTECARD, 0);
  108.                      
  109.                     llSay(0, "Deleting " + note_name + ". It was not submitted.  Try Dropping one note at a time.");
  110.                    
  111.                     llRemoveInventory(note_name);
  112.                    
  113.                     num_notes = llGetInventoryNumber(INVENTORY_NOTECARD);
  114.                    
  115.                 }
  116.                
  117.             }
  118.            
  119.             else //Not a Notecard
  120.             {
  121.                //find out what was dropped and remove it.  
  122.                
  123.                
  124.                 list inventory;
  125.                 integer num_inv = llGetInventoryNumber(INVENTORY_ALL); // Should be 2
  126.                 integer counter = 0;
  127.                 while(counter < num_inv)
  128.                 {
  129.                     inventory += [llGetInventoryName(INVENTORY_ALL, counter)];
  130.                     counter ++;  
  131.                 }
  132.                
  133.                 // WHat we expect to find
  134.                 list this_script = [llGetScriptName()];
  135.                
  136.                 //Delete this script (which belong in the inventory) from the list
  137.                 integer index = llListFindList(inventory, this_script);
  138.                 inventory = llDeleteSubList(inventory, index, index);
  139.                
  140.                
  141.                 index = llGetListLength(inventory);
  142.                
  143.                
  144.                 //Just in case they snuck in more than one inventory item
  145.                 while (index >= 1)
  146.                 {                
  147.                     llSay(0, "That was not a notecard. Removing " + llList2String(inventory, 0));
  148.                     llRemoveInventory(llList2String(inventory, 0));
  149.                     inventory = llDeleteSubList(inventory, 0, 0);
  150.                     index = llGetListLength(inventory);  
  151.                 }
  152.             }
  153.         }
  154.     }
  155.    
  156.     on_rez(integer start_param)
  157.     {
  158.         llResetScript();
  159.     }
  160. }
  161.  

Reply to "ZenMondo's Mailbox"

Here you can reply to the paste above

captcha