Lot Reservation

From Second Life Wiki
Jump to navigation Jump to search

Lot Reservation v1.0.0

Click an object to reserve a lot/parcel.
Very simple means of reserving a place.
The person who reserved the lot can reset/relinquish their reservation by touching the prim again.
The owner of the prim can reset anyone's reservation.
No attempt is made to make sure people don't reserve more than one (as that may be your requirement).
Originally written for Moxie Polano and RFL lot reservation in Haute Couture sim.
TO USE: Drop into a prim, scale and position prim on a map of the area to be shared. Persons wishing to reserve a place click on the prim.

//=========================================================================
// ---LICENCE START---
// http://creativecommons.org/licenses/by-sa/3.0/
// ie: Attribution licence:
//   Give me credit by leaving it in the script I created.
//   Supply my original script with your modified version.
//   Refer to the wiki URL from which you copied this script.
//      https://wiki.secondlife.com/wiki/Lot_Reservation
// ---LICENCE END---
//=========================================================================

// SHARED CONFIGURATION
integer     gPayloadPIN         = -81520;
//----------------------------------
// CONFIGURATION
vector      gReservedColor      = <1.0, 0.0, 0.0>;
vector      gVacantColor        = <0.0, 1.0, 0.0>;
//----------------------------------
// CORE CODE
string      gReservedName;
key         gReservedKey;
//=========================================================================
default
{   on_rez(integer start_param)
    {   llResetScript();
    }
    state_entry()
    {   if (gPayloadPIN)    llSetRemoteScriptAccessPin(gPayloadPIN);
        llSetText("vacant", gVacantColor, 1.0);
        llSetColor(gVacantColor, ALL_SIDES);
    }
    touch_start(integer total_number)
    {   gReservedName = llDetectedName(0);
        gReservedKey = llDetectedKey(0);
        llSetText(gReservedName, gReservedColor, 1.0);        
        llSetColor(gReservedColor, ALL_SIDES);        
        llInstantMessage(gReservedKey, 
            "Thanks "+gReservedName+", this lot is now reserved for you."
            +"\nIf you wish to relinquish this one for another lot, then touch this object again and this lot will become available."
            +"\nPlease only reserve one lot."            
        );
        state reserved;
    }
}
//========================================================================
state reserved
{   on_rez(integer start_param)
    {   llResetScript();
    }
    state_entry()
    {
    }
    touch_start(integer total_number)
    {   key uuid = llDetectedKey(0);
        if (uuid == llGetOwner() || uuid == gReservedKey)
        {   llInstantMessage(gReservedKey, 
                "Thanks "+gReservedName+", you have now released this lot."
                +"\n It is now available for others to reserve."
            );
            llResetScript();
        }
    }
}
//=========================================================================