Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sense and Replace Object

Horg Neurocam
Mineralogist
Join date: 28 Sep 2005
Posts: 19
02-02-2008 14:15
I've been searching about to find a simple script that will search for an object in a range (say in a 2 M vicinity), and, if it can't find it, re-rezzing it from its inventory. A simple way to replace a taken or moved object. Is there an uncomlplicated or opensource script architecture that i could use?

I'm pretty good at altering things already written, but making them out of whole cloth is yet beyond me... thanks for any help!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-02-2008 14:35
CODE

default{
state_entry(){
//-- change active to passive if it's not a scripted object being looked for.
llSensorRepeat( "objectname", "", ACTIVE, 2.0, PI, 30.0 );
}

no_sensor(){
llRezObject( "objectname",
llGetPos() + <0.0, 0.0, 1.0> * llGetRot()
ZERO_VECTOR,
llGetRot();
42 );
}
}


searchs a 2m sphere around the object it's in, for 'objectname', every 30 seconds. if not found it rezzes 'objectname' from inventory 1m above the local z axis of the object this prim is in, with the same rotation.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Horg Neurocam
Mineralogist
Join date: 28 Sep 2005
Posts: 19
02-02-2008 15:57
rats. i can't seem to make it work correctly. it either repeatedly rezzes the object, (active) or just rezzes it once once the script is run, then stops. (passive)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-02-2008 17:04
when you say repeatedly rezzes the object, I'll assume you mean keeps rezzing a new object every 30sec even if the old one is still there?

when you say rezzes the object once, but never again, I'll assume you mean it does not rez a new copy more than a minute after you've moved the old copy more than 2m away (or deleted it)?

might be a small error on my part, according to the wiki there needs to be a dummy sensor event or the repeat won't keep firing...

try this instead
CODE

default{
state_entry(){
llSensorRepeat( "objectname", "", PASSIVE, 2.0, PI, 30.0 );
}

sensor( integer vIntSensed ){
//-- don't do anything, lsl is dumb, and your sensor will stop repeating if this isn't here, stupid huh?
}

no_sensor(){
llRezObject( "objectname",
llGetPos() + <0.0, 0.0, 1.0> * llGetRot(),
ZERO_VECTOR,
llGetRot(),
42 );
}
}

EDIT:
fix-ed, thanks to Jesse for the catch(es)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
02-02-2008 18:12
Void had a couple of typos is all (no comma after 1st llGetRot() and semi-colon instead of comma after 2nd llGetRot())
Plus I made it where it will automatically get the name of the inventory object ot check against.

CODE
string objectname;

default {
state_entry() {
objectname = llGetInventoryName(INVENTORY_OBJECT, 0);
//-- change active to passive if it's not a scripted object being looked for.
llSensorRepeat(objectname, "", ACTIVE | PASSIVE, 2.0, PI, 30.0);
}
no_sensor() {
llRezObject(objectname, llGetPos() + <0.0, 0.0, 1.0 > *llGetRot(),
ZERO_VECTOR, llGetRot(), 42);
}
}
_____________________
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
Horg Neurocam
Mineralogist
Join date: 28 Sep 2005
Posts: 19
that did it!
02-02-2008 18:16
beautiful, thank you!

i can't wait to get tinkering with it!

(planning to set up all sorts of surprises at the Cavorite Mines....)
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
02-02-2008 18:20
From: Horg Neurocam
beautiful, thank you!

i can't wait to get tinkering with it!

(planning to set up all sorts of surprises at the Cavorite Mines....)

Had a syntax eror in mine also:) Just corrected it.
_____________________
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
02-02-2008 19:09
Playing with it in beta when I saw the part in the wiki about having to add the dummy sensor:)
_____________________
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
Horg Neurocam
Mineralogist
Join date: 28 Sep 2005
Posts: 19
02-12-2008 20:03
you can see it in action at the cavorite mines in Caledon Moors.. just go collide with some crates, hehehe. : )
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-12-2008 20:14
Very small note. You might want to use llRezAtRoot(). That way the rez point will be the same point the object is sensed at afterwards (if it doesn't move inbetween). It can be easy for an object's geometric center to be a meter from its root prim's location. Might not matter for this application, but it is good to keep in mind.