|
David Bournemouth
Registered User
Join date: 8 Oct 2006
Posts: 13
|
04-10-2008 08:32
Throwing myself at the mercy of the forum here - I'm a beginning scripter, who maybe doesn't know what can't be done ... maybe someone will be so kind as to point me in the right direction. OK, here's the challenge. I've got an object (call it "OBJ"  that I want to put into some form of pad or similar on the ground. The pad is to be scripted in such a way that it rezzes a copy of "OBJ" at a certain offset from the pad, on the condition that there isn't already a copy of "OBJ" there already. In other words - there will constantly be an "OBJ" available for residents to ride/use/whatever - but if they've taken it away with them, another one then appears. I've worked out the concept of a llDie script within OBJ, just in case anyone is worried about exponential prim count on my behalf - it's more how do I get the "pad" to check if OBJ is present and if not to rez a fresh one. Many thanks in advance for your contributions - either full scripts (cheeky of me to ask) or even just pointers towards the correct LSL function.
|
|
Xhawkx Holden
Registered User
Join date: 1 Nov 2006
Posts: 86
|
04-10-2008 08:58
use an llSensorRepeat checking every 10 seconds or so to see if the OBJ is still there. The sensor can be set to only check.. say 5 or 10 meters away from the pad. When it is no longer detected (NO_SENSOR).. go ahead and rez another one.
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
Sample code
04-10-2008 09:25
From: OK, here's the challenge. I've got an object (call it "OBJ") that I want to put into some form of pad or similar on the ground. The pad is to be scripted in such a way that it rezzes a copy of "OBJ" at a certain offset from the pad, on the condition that there isn't already a copy of "OBJ" there already. In other words - there will constantly be an "OBJ" available for residents to ride/use/whatever - but if they've taken it away with them, another one then appears. [/QUOTE
list my_children = []; // list of object keys obtained when objects are rezzed
create_prim( string objName, vector objPos, rotation objRot, integer startParm ) { llRezAtRoot( objName, llGetPos() + objPos * llGetRot(), ZERO_VECTOR, objRot * llGetRot(), startParm ); }
recall_prims( integer startn ) { for (objIndex = 0; objIndex < llGetListLength( objekter ); objIndex += 3 ) create_prim( llList2String( objekter, objIndex ), llList2Vector( objekter, objIndex+1 ), llList2Rot( objekter, objIndex+2 ), startn ); }
default {
/// something ///
object_rez(key id) { my_children += [id]; // get keys of children }
sensor(integer num_detected) { integer alive = 0; integer i; for (i = 0 ; i < num_detected ; i++) alive += llListFindList( my_children, [llDetectedKey(i)]) >= 0 ; if ( !alive ) // do only make children when all are gone { my_children =[]; recall_prims( 2 ); } }
no_sensor() { my_children =[]; recall_prims( 2 ); } /// something else /// }
_____________________
From Studio Dora
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
04-10-2008 10:18
I'd suggest use of llGetObjectDetails() instead of sensors now, unless you need to cross sim boundaries (in which case I'd suggest chat anyway). In applications where you already know the keys of the objects you are checking up on (and as shown above you can generally figure that out using things like the 'object_rez' event), it is likely to cause less lag and be a lot more reliable (gets around distance limits, limits on the number of detected objects, etc.). llGetObjectDetails() doesn't have to iterate over bunches of objects and do distance calculations; it can simply lookup the object you are talking about and return the appropriate properties (or tell you the object isn't found by returning an empty list).
|
|
David Bournemouth
Registered User
Join date: 8 Oct 2006
Posts: 13
|
thank you all so much
04-10-2008 10:41
Thanks everyone for your generous contributions  As soon as I've translated it all back into Rookiescriptese (tm) and made it all work, I'll report back. In the meantime, I'm extremely grateful and impressed, as always, at the community spirit in here.
|