Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Collision Filter to Reset script and start timer over

ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
10-28-2007 15:17
This is my first attempt at writing more then a basic script from scratch, and using "collision filter" which I can't seem to find any good examples for.

Basically what I want to accomplish is this:

The script resides in a landing pad at the Owner's "Home".

on rez - reset script to start everything fresh, timer starts counting down.

on collision with Owner, reset script - restart timer

timer counts down X days, if it reaches the end of X days it

sends out notice to owner in IM & Notecard
sends out notice to avatar in IM & Notecard

I'm getting a compilation error at line 14 (collision_filter) but this may not be the only problem.

CODE

// This script sends out messages at a regularly timed interval, unless it is restarted by a collission with the Owner.

default
{
state_entry()
{
llSetTimerEvent(86400); //time in seconds, 24 hours: 60*60*24--no need to make LSL do this simple calculation
}
on_rez(integer start_param)
{
// Reset script when the object is rezzed
llResetScript();
}
////////////////////////////////////////////////
collision_filter("",llGetOwner(),TRUE)
//collision filter recognizes only collisions with Owner.
{
state ResetState&PauseCollisionDetection;
}
////////////////////////////////////////////////

timer()
{
llSay(0, "24 hour timer has expired");
llGiveInventory("Insert avatar key number", "Note");
//llGiveInventory("avatar or object key number", "Note");
//The object destination must be in the same sim.
//The avatar destination does not have to be in the same sim.
llGiveInventory(llGetOwner(), "Note");
//sends note to owner.

llInstantMessage("Insert avatar key number", "24 hour timer has expired");
//llInstantMessage("key user", "24 hour timer has expired");
//Sends an Instant Message specified in the string message to the user specified by key.
llInstantMessage(llGetOwner(), "24 hour timer has expired");
//sends IM to owner
}
}

state ResetState&PauseCollisionDetection
{
state_entry()
{
llSetTimerEvent(720); //2 hour delay in seconds : 12x60x60
//llSay(0, "Resetting and pausing collision detection");
}

timer()
{
llSetTimerEvent(0);
state default;
}
}
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
Daten Thielt
Registered User
Join date: 1 Dec 2006
Posts: 104
10-28-2007 15:43
First of all collision_filter dose not exsist as an event nor is it what u want to use realy

for your collision do soming like this

collision_start
{
key owner = llGetOwner();
key colider = llGetDetectedKey(0);

if(owner == colider)
{
//code here
}
}
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
10-28-2007 15:50
Shouldn't collision_filter be llCollisionFilter and appear within an Event Handler?

llCollisionFilter establishes a filter for the collision event handlers: collision, collision_start, and collision_end


So, llCollisionFilter("", llGetOwner(), TRUE); belongs in state_entry(), and a collision Event Handler should also appear:

collision_start()
{
state ResetState&PauseCollisionDetection;
}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-28-2007 15:57
Haven't figured out exactly what you are trying to accomplish here yet but...............
Give this a go. The collision filter needs to be in the state entry. All it does is set the ground rules for the collision event itself which you need in there.

Also you can not have & in the state name and that was adjusted also.

CODE

// This script sends out messages at a regularly timed interval, unless it is restarted by a collission with the Owner.

default
{
state_entry()
{
//collision filter recognizes only collisions with Owner.
llCollisionFilter("",llGetOwner(),TRUE);
llSetTimerEvent(86400); //time in seconds, 24 hours: 60*60*24--no need to make LSL do this simple calculation
}
on_rez(integer start_param)
{
// Reset script when the object is rezzed
llResetScript();
}
////////////////////////////////////////////////
collision_start(integer total_number)
{
state ResetStateAndPauseCollisionDetection;
}
////////////////////////////////////////////////

timer()
{
llSay(0, "24 hour timer has expired");
llGiveInventory("Insert avatar key number", "Note");
//llGiveInventory("avatar or object key number", "Note");
//The object destination must be in the same sim.
//The avatar destination does not have to be in the same sim.
llGiveInventory(llGetOwner(), "Note");
//sends note to owner.

llInstantMessage("Insert avatar key number", "24 hour timer has expired");
//llInstantMessage("key user", "24 hour timer has expired");
//Sends an Instant Message specified in the string message to the user specified by key.
llInstantMessage(llGetOwner(), "24 hour timer has expired");
//sends IM to owner
}
}

state ResetStateAndPauseCollisionDetection
{
state_entry()
{
llSetTimerEvent(720); //2 hour delay in seconds : 12x60x60
//llSay(0, "Resetting and pausing collision detection");
}

timer()
{
llSetTimerEvent(0);
state default;
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-28-2007 16:01
PS and welcome to the scripting forum. The texture tips forum is alright but were much cooler!!!!!!! :cool:
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
10-29-2007 07:56
Thank you Jesse, Pale and Daten for your help and thank you Jesse for the welcome. Actually I have lurked and participated in the scripting forum for ages, but rarely know enough to contribute much. Although I have contributed several simple script examples to the Library.

I see my misunderstanding now, I was incorrectly treating llcollision_filter like an event similar to collision_start or collission_end. I guess that is where I am the fuzziest on scripting is understanding the structure and relationships of various scripting elements.

I'm looking forward to trying out the ideas and corrections you all shared. Thanks again.

/me goes off to play with scripts...its like magic... I love it... makes me feel like an amature wizard or sorcerer's apprentice. :)

I will report back regarding my success.
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
Last will and testament...
10-29-2007 08:43
From: Jesse Barnett
Haven't figured out exactly what you are trying to accomplish here yet but...............


OK here is what I'm trying to accomplish. There are probably better ways to do this, but I wanted to try to work up one solution before I started asking for other ideas on accomplishing it.

Inspired by this forum discussion Your Second Life Will and an extremely close call in RL to what could have been a fatal automobile accident, I decided to create a Second Life Last Will and Testament. That is a scripted object that would send out the Last Will and Testament notecard to a beneficiary if the Owner were to disappear from Second Life for a period of 30 days or so.

The notecard could contain instructions to the beneficiary on how to gain access to the Owner's account (password or coded information on how to obtain it), instructions regarding the Owner's wishes for distribution of thier property, possessions, lindens, businesses, final personal messages to the recipients, etc.

I intend to make this script available free to the Second Life community. I know that LL says they will transfer the ownership of an SL account to another person if directed to do so by a legal will in RL. But not everyone in SL wants the details of thier Second Life existence to be come available to people in thier RL, but many have valued friends and or a partner in SL who they would like to see inheriet thier stuff in SL.

So I concieved of this script that would detect the Owner's presence in SL. If the Owner disappears for 30 days or more, the script sends out one or several IM's and Notecards to the designated beneficiary's. My scripting approach to accomplishing this may be niave, but it was all I could come up with so far. i.e. Place an object, rug, at the Home landing point of the Owner. Script the rug to detect the Owner's presence using collisions. Once the script is placed, a timer begins counting down to 30 days. Everytime the Owner logs into or TP's to thier home, the collision resets the script and starts the timer over again.

One issue I am very concerned about is how secure the notecard will be against prying eyes. The password could always be encrypted I suppose with the encryption key being provided to the beneficiary in advance or seperatly.
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
10-30-2007 11:13
From: Daten Thielt
First of all collision_filter dose not exsist as an event nor is it what u want to use realy

for your collision do soming like this

collision_start
{
key owner = llGetOwner();
key colider = llGetDetectedKey(0);

if(owner == colider)
{
//code here
}
}


Daten, the method you describe here looks like a good one. I also got llCollisionFilter(); working with "collision_start" as I originally intended. But I'm wondering why you say "nor is it what u want to use realy"? No quibble on my part, I'm just trying to understand/learn from this.
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
Daten Thielt
Registered User
Join date: 1 Dec 2006
Posts: 104
10-30-2007 11:42
Its easeyer to check for things within the event rather than having to use a function to call for the event in my opinion, but everyone scripts in their own way
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
10-30-2007 12:40
llCollisonFilter is a one-time setting of the Event Handler's attributes. A bit like llListen sets the attributes for the listen Event Handler. Maybe listen could default to an open listen on all channels in the absence of an llListen? Good plan. :p

I would like to believe that the llCollisionFilter is more efficient than having coded conditions within the Event Handler... but who knows, LSL is nothing if not quirky at times.

I'm not convinced this is simply a question of coding styles.