Michael Psaltery
Registered User
Join date: 6 Jun 2004
Posts: 57
|
04-12-2005 16:53
I'm trying to make a building in pieces that self-rez when the base of the tower is placed somewhere.
string objectname = "TowerSection2"; default { on_rez(integer startparam) { if (llGetInventoryKey(objectname)) { llSleep(2); llRezObject(objectname, llGetRootPosition() + <0,0,10>, <0,0,0>,ZERO_ROTATION, 0); } } }
The above code does rez each section, but I'm seeing the pieces rezzed all over the place. The original tower was constructed with identical pieces exactly 10m apart, so they should appear one atop the other. However, I'm seeing some pieces appear LESS than 10m above, and some appear MORE than 10m.
I know about the concept of recoil, but these are non-physical objects, with NO velocity.
For five objects (base plus 4 levels), I saw the following deltas (SHOULD be <0,0,10> for each case): 1: <.004,-1.168,10.02> 2: <.001,-1.493,10.025> 3: <.55,-1.492,7.531> 4: <0,0,17.524>
The last one is especially disturbing, as the X and Y are correct, but the Z is almost twice! what it should be. I've turned this in via bug report, but am I missing something???
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
04-12-2005 18:08
Did you know you can take several objects as a single object, and rez them as one piece? Just select all of them and choose "Take" or "Take Copy," then take it out as needed. 
_____________________
---
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
04-12-2005 18:47
I had exactly this problem. This solution worked for me. Rez the object at the "delivery box", then tell it to move into position. What I did was to put a self-deleting script into each of the objects' contents that listened to the "delivery box" on a predefined control channel. The use the box to tell the rez objects where to move. More explicitly - in each deployable item add a script like... // Builder Script - Escort DeFarge 2004 integer CONTROL_CHANNEL = 1234; integer listen_handle;
default { // Open up the listen on_rez(integer start_param) { listen_handle = llListen(CONTROL_CHANNEL, "", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { list coords = llParseString2List(message, ["<", ","], []); if (llList2String(coords, 0) == llGetObjectName()) { vector target = <llList2Float(coords, 1), llList2Float(coords, 2), llList2Float(coords, 3)>; while (llVecDist(llGetPos(), target) > 0.001) { llSetPos(target); } // Tidy up by closing the listen and self-removing this script... llListenRemove(listen_handle); llRemoveInventory(llGetScriptName()); } } }
...then in your "delivery box" script you can simply add a function like which you can call for each object you want to deploy... integer CONTROL_CHANNEL = 1234; // Call me with the component name and desired final position deploy(string name, vector pos) { pos += <0.25, 0.0, -0.25>; llRezObject(name, llGetPos(), ZERO_VECTOR, llGetRot(), 5); llSleep(1.0); llSay(CONTROL_CHANNEL, name + "," + (string)(llGetPos() + pos * llGetRot())); }
...I usually have the delivery box llDie() itself once it's done its job. When you do it this way, it all looks kinda cool  /esc
_____________________
http://slurl.com/secondlife/Together
|
Michael Psaltery
Registered User
Join date: 6 Jun 2004
Posts: 57
|
04-12-2005 22:15
Thanks, Escort. I was afraid I'd have to do something like that. There are so very many functions in LSL that just seem to do CRAZY stuff. Wish I knew why weird stuff like this happens.
|
Malachi Petunia
Gentle Miscreant
Join date: 21 Sep 2003
Posts: 3,414
|
probably not as hard as all that
04-13-2005 05:14
Michael, I think the big issue in your original post was that you were using llGetRootPosition which returns *global* coordinates rather than sim-local coordinates which almost every other function uses. llGetPos() gives you the sim-local coordinates you want. I'm guessing that the weirdness you were seeing in rez positions was due to some truncation from global-coords (big) to sim-cords (<= 255). Assuming you want a self-building structure, and don't wish to link it up and rez it as one piece, here is a simpler way of doing what I think you are shooting for. // not tested - but close to right // this script is in the "base", no other scripts needed // assumes that the base is not rotated once created
integer deltaZ = 10; integer stackN = 4 string primName = "segment"; vector basePos;
buildStack() { integer i;
for(i = 0; i < stackN; i++) { basePos.z += deltaZ; llRezObject(primName, basePos, ZERO_VECTOR, ZERO_ROTATION, 0); } }
default { on_rez() { basePos = llGetPos(); }
touch_start(integer n) { buildStack(); llRemoveInventory(llGetScriptName()); } } Hope that helps. Escort, you went to a lot of extra work to change a component of a vector, which can be much more easily accessed as vec.x, vec.y, and vec.z.
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
04-13-2005 08:24
From: Malachi Petunia Escort, you went to a lot of extra work to change a component of a vector, which can be much more easily accessed as vec.x, vec.y, and vec.z. Actually, on looking more carefully at what is going on there, you may appreciate that the reason I did it that way was to be able to pass the object target name as well as the vector in the llSay() so that the scripts in the target objects would all be the same script. Admittedly, a small amount of additional elegance is possible, but hell - it works. Also, your solution may be ok for some deployments, but the rez distance will do you a mischief when you are building something like a 30-odd meter structure. /esc
_____________________
http://slurl.com/secondlife/Together
|
Malachi Petunia
Gentle Miscreant
Join date: 21 Sep 2003
Posts: 3,414
|
04-13-2005 11:24
From: Escort DeFarge ... Also, your solution may be ok for some deployments, but the rez distance will do you a mischief when you are building something like a 30-odd meter structure. You are so right; my apologies. Indeed, if llRezObject() was limited to 300m offset as I "remembered" instead of the 10m that is actually true, the script I posted would not be horribly broken.
|