Jump to content

Roleplay script for perishable goods


Erwin Solo
 Share

You are about to reply to a thread that has been inactive for 1686 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

A friend wanted a roleplay script for perishable goods.  She's making flowers, milk, etc., food that requires cooking (mix of ingredients, etc.) for roleplay.  She wanted a script for which her products "age" and delete themselves, even if stored in inventory.  Additionally, she wants the 'lifetime' of the perishables to reset if give from one avatar to another.  Here is what I did for her.  

// Erwin Solo 2019-05-23
// Autodelete script that remembers time spent in inventory.
// Uses Unix Clock, which will fail on 19-January-2038 for 32 bit integers.  
// See https://en.wikipedia.org/wiki/Year_2038_problem.
// I could hack around the 19-January-2038 bug, but hope we'll have generally agreed to solution.

integer TimeToLive = 7200; // enter time you want inventory to live in seconds

float gTimer = 3600; // timer runs every hour for low script load.  Okay to set lower for testing.

// enter UUID of person who you want to be immune from the timeouts
// Must be in quotes.  Example, "62d718f6-e00b-49ca-b434-338f712fd03a" for Erwin Solo
key SpecialPerson = "62d718f6-e00b-49ca-b434-338f712fd03a"; 

// ========================================
// Don't change anything below here
// ========================================


key Owner = NULL_KEY; // Owner determined by script at initialization

integer BirthTime = 0; // to be calculated at initialization

integer DieTime =0; // to be calculated at runtime

integer CurrentTime =0; // to be calculated at runtime


default
{
    state_entry()
    {
        Owner = llGetOwner(); 
        llSetTimerEvent (gTimer);
        BirthTime = llGetUnixTime(); 
        DieTime = BirthTime + TimeToLive; // Time object should die
    }

    on_rez( integer start_param )
    { 
        if (Owner != llGetOwner()) // if owner has changed, reset script to re-establish BirthTime and DieTime
        {
            llResetScript();
        }
        llSetTimerEvent (gTimer);
        if ( Owner != SpecialPerson ) // if owner is not the special person
        {
            CurrentTime = llGetUnixTime(); 
            
            if ( CurrentTime > DieTime ) 
            {
                llDie(); // object deletes itself
            }
        }

    }
    

    timer()
    {
        if ( Owner != SpecialPerson ) // if owner is not the special person
        {
            CurrentTime = llGetUnixTime(); 
            
            if ( CurrentTime > DieTime ) 
            {
                llDie(); // object deletes itself
            }
        }
    }
}
 

  • Like 2
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1686 days.

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
 Share

×
×
  • Create New...