Friday, April 3, 2026

Expanded Mailbox Script

The very first script I provided actually was a complete, working mailbox script! The magic happens with the llAllowInventoryDrop(TRUE); command, which is what turns a regular object into a functioning mailbox that anyone can drop items into.

However, if you are looking for a more "complete" mailbox experience, I have expanded the script below. This upgraded version combines the dual-notification system from earlier with standard mailbox features: floating hover text to identify the mailbox, and a touch response that gives people instructions on how to use it.

Here is the combined, expanded script for you, Lady Kati Evans:

Code snippet
// --- CONFIGURATION ---
// Replace the zeros below with the actual UUID key of the second person.
key second_person = "00000000-0000-0000-0000-000000000000"; 

// Change the text between the quotes to customize the floating text over the mailbox.
// The \n creates a new line.
string hover_text = "Magistrate's Mailbox\nHold Ctrl and drag items here to drop them.";

// Color of the hover text in RGB format (currently set to white).
vector text_color = <1.0, 1.0, 1.0>; 
// ---------------------

default
{
    state_entry()
    {
        // 1. Turns the object into a mailbox
        llAllowInventoryDrop(TRUE);
        
        // 2. Sets the floating text above the mailbox
        llSetText(hover_text, text_color, 1.0); 
    }

    // 3. Gives instructions if someone clicks the mailbox
    touch_start(integer total_number)
    {
        key clicker = llDetectedKey(0);
        llRegionSayTo(clicker, 0, "To leave a message or item, please hold down the 'Ctrl' key on your keyboard and drag the item from your inventory directly onto this mailbox.");
    }

    // 4. Handles the notifications when an item is dropped
    changed(integer change)
    {
        // CHANGED_ALLOWED_DROP triggers when someone else drops an item.
        // CHANGED_INVENTORY triggers if the owner drops an item.
        if (change & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY))
        {
            string regionName = llGetRegionName();
            string objectName = llGetObjectName();
            string message = "Notification: A new item has been dropped into '" + objectName + "' in the region " + regionName + ".";
            
            // Send IM to Owner
            llInstantMessage(llGetOwner(), message);
            
            // Send IM to the Second Person
            if (second_person != NULL_KEY && second_person != "")
            {
                llInstantMessage(second_person, message);
            }
        }
    }
}

What's New in This Version:

  • Hover Text: Added llSetText in the configuration section so you can display a floating title over the mailbox.

  • Click-to-Learn: Added a touch_start event. If a resident doesn't know how to drop items into a mailbox, they will usually click it. This will send them a private chat message explaining the "Ctrl + Drag" method.

  • All-in-One: It still retains the instant message notifications sent directly to you and the second UUID key you provide.

No comments:

Post a Comment