Table of Contents

Introduction

This script was tested and works on OpenSim version 0.7.4!

This is a very simple script to self-destruct a primitive at a certain date and time which also survives simulator resets. All date and time references are set in UTC time because we do not want to overload the script too much.

Setup

In order to set a self-destruct time:

  • Create a new primitive and drop this script inside it. As soon as you do, you will see some overhead text appear, saying that the self-destruct is not armed.
  • Set the primitive's description to the date and time at which the primitive will self-destruct. The format is given by:
YYYY-MM-DD hh:mm

where the letters stand for:

Symbol Description
Y year, as four digits
M month, as two digits
D day, as two digits
h hour, as two digits in 24hour time
m minutes

An example could be:

2012-08-20 13:00

which would make the primitive self-destruct at 1:00 PM on the 20th of August 2012.

Code

objectselfdestruct.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
string zTimeDate;
 
default
{
    state_entry() {
        llSensorRepeat("", NULL_KEY, AGENT, .1, .1, 1);
    }
 
    no_sensor() {
        llSensorRemove();
        zTimeDate = llGetObjectDesc();
        list cTimeDate = llParseString2List(zTimeDate, [" "], []);
        // Arm check
        list nTimeDate = llParseString2List(llGetTimestamp(),["-",":"],["T"]);
        list nDate = llParseString2List(llList2String(cTimeDate, 0), ["-"], []);
        list nTime = llParseString2List(llList2String(cTimeDate, 1), [":"], []);
        if(llGetListLength(nDate) + llGetListLength(nTime) != 5) {
            llSetText("Time now: " + llList2String(nTimeDate, 0) + "-" + llList2String(nTimeDate, 1) + "-" + llList2String(nTimeDate, 2) + " " + llList2String(nTimeDate, 4) + ":" + llList2String(nTimeDate, 5) + " UTC\nSelf-destruct is not armed.\n", <1,1,1>, 1);
            llSensorRepeat("", NULL_KEY, AGENT, .1, .1, 1);
            return;
        }
        llSetText("Time now: " + llList2String(nTimeDate, 0) + "-" + llList2String(nTimeDate, 1) + "-" + llList2String(nTimeDate, 2) + " " + llList2String(nTimeDate, 4) + ":" + llList2String(nTimeDate, 5) + " UTC\n" + "Self-Destruct: " + zTimeDate + " UTC", <1,1,1>, 1);
        llSetTimerEvent(1);
    }
 
    on_rez(integer pin) {
        llResetScript();
    }
 
    timer() {
 
        if(llGetObjectDesc() != zTimeDate) llResetScript();
        list nTimeDate = llParseString2List(llGetTimestamp(),["-",":"],["T"]);
        list nDate = llParseString2List(zTimeDate, ["-"], []);
        list nTime = llParseString2List(zTimeDate, [":"], []);
        if(llGetListLength(nDate) + llGetListLength(nTime) != 5) {
            llSetText("Time now: " + llList2String(nTimeDate, 0) + "-" + llList2String(nTimeDate, 1) + "-" + llList2String(nTimeDate, 2) + " " + llList2String(nTimeDate, 4) + ":" + llList2String(nTimeDate, 5) + " UTC\nSelf-destruct is not armed.\n", <1,1,1>, 1);
            llSensorRepeat("", NULL_KEY, AGENT, .1, .1, 1);
            return;
        }
 
        list cTimeDate = llParseString2List(zTimeDate, [" "], []);
        llSetText("Time now: " + llList2String(nTimeDate, 0) + "-" + llList2String(nTimeDate, 1) + "-" + llList2String(nTimeDate, 2) + " " + llList2String(nTimeDate, 4) + ":" + llList2String(nTimeDate, 5) + " UTC\n" + "Self-Destruct: " + llGetObjectDesc() + " UTC", <1,1,1>, 1);
 
        list zDate = llParseString2List(llList2String(cTimeDate, 0), ["-"], []);    
        if(llList2Integer(zDate, 0) < llList2Integer(nTimeDate, 0)) return;
        if(llList2Integer(zDate, 1) < llList2Integer(nTimeDate, 1)) return;
        if(llList2Integer(zDate, 2) < llList2Integer(nTimeDate, 2)) return;
 
        list zTime = llParseString2List(llList2String(cTimeDate, 1), [":"], []);
        if(llList2Integer(zTime, 0) < llList2Integer(nTimeDate, 4)) return;
        if(llList2Integer(zTime, 1) < llList2Integer(nTimeDate, 5)) return;
 
        llDie();
    }
}

secondlife/object_self_destruct.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.