Looking for a self destruct type script..
|
|
Esch Snoats
Artist, Head Minion
Join date: 2 May 2006
Posts: 261
|
07-07-2006 11:50
I want to place a "New" sign above new items in my store, but don't want to have to manage deleting the signs after a certain period of time being up. Does anyone have a simple script I can place in my "New" sign that is a timer that will self destruct that prim and delete it after X number of days? Any help is appreciated, thank you!!!
E
|
|
Adriana Caligari
Registered User
Join date: 21 Apr 2005
Posts: 458
|
07-07-2006 11:55
integer days = 7; integer count;
init() { count = 3600 * 24 * days; llSetTimer( count); } default { state_entry() { init(); } { on_rez( integer r ) { init(); } timer() { llDie(); } }
Simple but effective - set the number of days and put in the script After seven days it kills itself
|
|
Esch Snoats
Artist, Head Minion
Join date: 2 May 2006
Posts: 261
|
07-07-2006 13:21
Excellent!! Thank you very much!!
E
|
|
Esch Snoats
Artist, Head Minion
Join date: 2 May 2006
Posts: 261
|
07-07-2006 15:10
I plugged this into an object and it tells me there's syntax errors in it. I tried it by itself and by nesting it within the default script that comes up. Is there another part of this script missing or am I doing something wrong? I know nothing about scripting, so I have no clue what I need to do to fix this.
Thanks! E
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
07-07-2006 15:25
Don't nest it in the default script. Delete the default and paste this script in instead. Replace 'llSetTimer' (in the 5th line, not counting the blank lines) with 'llSetTimerEvent'. Hopefully that should fix it.
|
|
Gattz Gilman
Banned from RealLife :/
Join date: 29 Feb 2004
Posts: 316
|
07-07-2006 17:23
there was also an extra {. integer days = 7; integer count;
init() { count = 3600 * 24 * days; llSetTimerEvent( count); } default { state_entry() { init(); } on_rez( integer r ) { init(); } timer() { llDie(); } }
|
|
Aodhan McDunnough
Gearhead
Join date: 29 Mar 2006
Posts: 1,518
|
07-07-2006 17:26
Another solution would be a script that checks the GMT time, so instead of number of days, you punch in the expiry date and time.
|
|
Adriana Caligari
Registered User
Join date: 21 Apr 2005
Posts: 458
|
07-08-2006 00:23
oops sorry
for some inane reason I always type llSetTimer
and not llSetTimerEvent
|
|
Esch Snoats
Artist, Head Minion
Join date: 2 May 2006
Posts: 261
|
07-09-2006 14:02
Ok, well I decided to run a test on this script and set the days to 1, and rezzed it in a test object yesterday. It's been over 24 hours and so far the item hasn't disappeared yet. Can someone write in a command into the above code so that I can type in a command to find out how much time is left before the object self destructs? I'm pretty sure It's been over 24 hours, but with that new command I'll know for sure if this is working or not.
Thank you!!!!!!!! E
|
|
Norman Desmoulins
Grand Poohba
Join date: 10 Nov 2005
Posts: 194
|
07-09-2006 16:00
The code is too simplistic anyway to ever really work... at least not over a period of so many hours... anything that causes the object to re-rez resets the timer. A better solution is a script that just allows you to put in the expiration date (like in the object description) and llDie's on the date.
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
07-09-2006 16:48
integer days = 7;
default {
on_rez( integer Parameter ) { llResetScript(); } state_entry() { if( llGetObjectDesc() == "" ) { integer time_to_die = llGetUnixTime() + ( days * 24 * 60 * 60 ); llSetObjectDesc( (string)time_to_die ); } llSetTimerEvent( 3600.0 ); } timer() { if( llGetUnixTime() > (integer)llGetObjectDesc() ) llDie(); } touch_start( integer ContactsTotal ) { if( llDetectedKey(0) != llGetOwner() ) return; integer time_to_live = ((integer)llGetObjectDesc() - llGetUnixTime()) / 3600 + 1; llOwnerSay( "This item will die in about " + (string)time_to_live + " hours." ); } }
Slightly more reset-proof, in theory anyway. First time it's rezzed, the descritpion field is used to memorize the time after which object should die (calculated from time of rezzing + number of days specified in script) ... then it checks once an hour if it's time to die. Frequency of timer can be adjusted if one doesn't mind the object to stick around for a bit longer until another check happens... when touched by owner, it reports how many hours of life it has left.
|
|
Yiffy Yaffle
Purple SpiritWolf Mystic
Join date: 22 Oct 2004
Posts: 2,802
|
07-09-2006 17:20
Just get a copy of one of those freebie rento scripts and have it llDie after it expires and mod it so you don't need to pay it. 
|
|
Esch Snoats
Artist, Head Minion
Join date: 2 May 2006
Posts: 261
|
07-09-2006 18:56
From: Joannah Cramer Slightly more reset-proof, in theory anyway. First time it's rezzed, the descritpion field is used to memorize the time after which object should die (calculated from time of rezzing + number of days specified in script) ... then it checks once an hour if it's time to die. Frequency of timer can be adjusted if one doesn't mind the object to stick around for a bit longer until another check happens... when touched by owner, it reports how many hours of life it has left. Ok, I must not be doing something right. I installed it on an object. Set it to die in 1 day. I rezzed it just fine, but when I click on it, it tells me: "This item will die in about -320136 hours." I reset the script, tried again, same thing. Any idea why it's freaking out on the number of hours? Also it's not putting anything in the description field. Thanks for your help with this btw, much appreciated!! E
|
|
Norman Desmoulins
Grand Poohba
Join date: 10 Nov 2005
Posts: 194
|
07-09-2006 20:27
Make sure the description field is completely empty before running the script... that means no (No Description) either.
|
|
Esch Snoats
Artist, Head Minion
Join date: 2 May 2006
Posts: 261
|
07-09-2006 20:31
I removed the (no description) from the description line and then took the object and re-rezzed it, but when I did thatthe (no description) comes back. Is there any way to permanently remove it? Add a space?
E
|
|
Norman Desmoulins
Grand Poohba
Join date: 10 Nov 2005
Posts: 194
|
07-09-2006 20:38
Just blank it out by removing all the characters and then reset the script... I always just do the following... but have a feeling there is something wrong with it too... like what about localization... string tmp = llGetObjectDesc(); if (tmp=="" || tmp=="  No Description)"  {
|
|
Esch Snoats
Artist, Head Minion
Join date: 2 May 2006
Posts: 261
|
07-09-2006 20:57
Ah ok, that fixed it. So that means every time I rez this thing I have to rez it, blank out the description, then reset the script? Thanks again for your help with this.  E
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
07-09-2006 22:20
From: Esch Snoats So that means every time I rez this thing I have to rez it, blank out the description, then reset the script? Nah ^^ #1 build your object #2 drop the script in its inventory (the original version) #3 close edit panel. #4 right-click the object and Edit it again. in edit window there will be numbers in description field of object, erase them. Close edit window. #5 right-click on object and Take it to your inventory #6 in the inventory open properties window for that object and delete "  No Decription)" from description field. now each time you rez a copy of this object, it'll set its timer to die in 7 days from the moment it was rezzed... it's quite a bit convoluted to get to that point, of course :/
|
|
Norman Desmoulins
Grand Poohba
Join date: 10 Nov 2005
Posts: 194
|
07-10-2006 03:02
From: Joannah Cramer Nah ^^ #6 in the inventory open properties window for that object and delete "  No Decription)" from description field. That won't work... there is some sillyness/bug/feature that causes SL to change the empty description to (No Description) again. You just need to just check for "" or "  No Description)"
|
|
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
|
07-10-2006 05:28
how about this untested code: if(( llGetObjectDesc() == "") || ( llGetObjectDesc() == "(No Description)")) {
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
07-10-2006 06:19
From: Norman Desmoulins That won't work... there is some sillyness/bug/feature that causes SL to change the empty description to (No Description) again. Try it, i did before writing that down ^^ i guess maybe it was fixed or something, but seems as long as the item is in your inventory while you edit, erasing the "  No Description)" thing does work. Maybe replacing empty description with "  No Description)" label happens only when you right-click Take object from world into the inventory o.O;
|