Semi-Dumb Question...
|
|
Tasman Perth
Geekette Extraordinaire
Join date: 7 Jun 2005
Posts: 225
|
09-23-2006 16:23
Hi! I've been building an underwater habitat for the last 6 months or so, and finally got to where I'm adding (or trying to add) some cool scripted stuff.. One of the recent additions to the place is an airlock-like chamber which I have working hatches on both the inside and outside entry. What I'm trying to do is this: Have a semi-transparent, phantom "box", which when clicked on by someone in the airlock, will increment its Z value from .010 to 3m to simulate the lock filling with water. I've got this working, somewhat, but what I get when the script runs, is the box expands, but not only in the "up" Z direction, but in the "down" Z direction too, ie: if the initial box (3mX3mX.010m) is sitting on a flat surface, when the script runs and completes, expanding the Z of the box from .010m to 3m, about half of the z of the box is below the surface the "box" is sitting on... I suspect I'm doing something stupid, but I'm not into scripting enough to know what that might be... Here's what I'm using... Thanks Tas vector vInitialSize = <3.00,3.00,0.010>; vector vIncZ; default { state_entry() { // Initialize the prim that this script is placed in.. // Set to box llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]); // Set to blue/phantom/50% transparent llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0, 0, 255>, 0.50,PRIM_PHANTOM, TRUE]); // Set size to initial size llSetPrimitiveParams([PRIM_SIZE, vInitialSize]); // Set to fullbright llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]); vIncZ = vInitialSize; } touch_start(integer total_number) { float ZInc = 0.010; llWhisper(0, "Filling chamber"); while (ZInc <= 3.00) { vIncZ.z = ZInc; llSetPrimitiveParams([PRIM_SIZE, vIncZ]); ZInc = ZInc + .020; } } }
|
|
Tuach Noh
Ignorant Knowlessman
Join date: 2 Aug 2006
Posts: 79
|
09-23-2006 16:30
I believe you'll need to move the prim up by half of zInc each time to get this to work. Fortunately you can do this in the same llSetPrimitiveParams() call, so it should be relatively smooth.
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
09-23-2006 16:33
That's the expected behaviour... what you have to do is move the water prim up a bit with each step too. It gets bigger by 0.2 on z per step, so needs to go up by half that, 0.1. llSetPos(llGetPos() + <0.0, 0.0, 0.1>  ; or setting it directly in the llSetPrimitiveParams() call will work nicely. btw, for just resizing llSetScale for some reason doesn't have the 0.2s delay that most of the other things like this do.
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
09-23-2006 16:34
WOW!!! I am jealous. My questions haven't gotten to the semi-dumb level yet. They are still at the completely stupid level.  Changing the size in the Z direction wouldn't be any different then clicking "edit"/"stretch"/"both sides". You are making it larger from the centerpoint out in both directions. I don't know how to write the code but you could add to the script so that it also increments the Z location. This would raise it up as it gets larger. You will also need to half your ZInc value to keep it looking the same as you have now.
_____________________
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
|
|
Tuach Noh
Ignorant Knowlessman
Join date: 2 Aug 2006
Posts: 79
|
09-23-2006 17:01
Try this: vector vInitialSize = <3.00,3.00,0.010>; vector vInitialPos; vector vIncZ; default { state_entry() { // Initialize the prim that this script is placed in.. llSetPrimitiveParams([ // Set to box PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, // Set to blue/phantom/50% transparent PRIM_COLOR, ALL_SIDES, <0, 0, 255>, 0.50, PRIM_PHANTOM, TRUE, // Set size to initial size PRIM_SIZE, vInitialSize, // Set to fullbright PRIM_FULLBRIGHT, ALL_SIDES, TRUE ]); vIncZ = vInitialSize; vInitialPos = llGetPos(); } touch_start(integer total_number) { float ZInc; vector vPos = vInitialPos; vIncZ = vInitialSize; llWhisper(0, "Filling chamber"); for (ZInc = 0.010; ZInc <= 3.00; ZInc += 0.020) { vIncZ.z = ZInc; vPos.z = vInitialPos.z + (ZInc / 2); llSetPrimitiveParams([ PRIM_SIZE, vIncZ, PRIM_POSITION, vPos ]); } } } Seems to work. I coalesced all your llSetPrimitiveParams() calls in the state entry, and added the necessary movement to the loop. Note that in both versions, the loop ends at 2.990. Change the start to 0.020 if you want it to go to 3.000 even. Sounds like an interesting habitat.
|
|
Tasman Perth
Geekette Extraordinaire
Join date: 7 Jun 2005
Posts: 225
|
09-23-2006 17:05
Thanks, guys!! That worked great... I figured I was missing something.. Tas
|
|
Tasman Perth
Geekette Extraordinaire
Join date: 7 Jun 2005
Posts: 225
|
09-23-2006 17:11
From: Tuach Noh Try this: vector vInitialSize = <3.00,3.00,0.010>; vector vInitialPos; vector vIncZ; default { state_entry() { // Initialize the prim that this script is placed in.. llSetPrimitiveParams([ // Set to box PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, // Set to blue/phantom/50% transparent PRIM_COLOR, ALL_SIDES, <0, 0, 255>, 0.50, PRIM_PHANTOM, TRUE, // Set size to initial size PRIM_SIZE, vInitialSize, // Set to fullbright PRIM_FULLBRIGHT, ALL_SIDES, TRUE ]); vIncZ = vInitialSize; vInitialPos = llGetPos(); } touch_start(integer total_number) { float ZInc; vector vPos = vInitialPos; vIncZ = vInitialSize; llWhisper(0, "Filling chamber"); for (ZInc = 0.010; ZInc <= 3.00; ZInc += 0.020) { vIncZ.z = ZInc; vPos.z = vInitialPos.z + (ZInc / 2); llSetPrimitiveParams([ PRIM_SIZE, vIncZ, PRIM_POSITION, vPos ]); } } } Seems to work. I coalesced all your llSetPrimitiveParams() calls in the state entry, and added the necessary movement to the loop. Note that in both versions, the loop ends at 2.990. Change the start to 0.020 if you want it to go to 3.000 even. Sounds like an interesting habitat. Thanks, everybody!! I knew I was missing something.. Just havent scripted enough in LSL to know what that thing was... If you want to see the habitat, its at Rainbow Sands (107, 33, 21).. Some friends and I are planning to open it soon as a club, thinking about "Club Abyss".. Feel free to drop by and check it out... Tas
|
|
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
|
Alternate Solution
09-24-2006 10:03
Nothing wrong with your original script, if you use a half-cube instead of a cube. - Go edit your cube.
- Change it into a sphere.
- Dimple it to 50% on one side.
- Rotate it so that the flat side is down.
- Change it back to a cube.
- Done.
Have fun!
|
|
Tasman Perth
Geekette Extraordinaire
Join date: 7 Jun 2005
Posts: 225
|
09-24-2006 18:33
From: Llauren Mandelbrot Nothing wrong with your original script, if you use a half-cube instead of a cube. - Go edit your cube.
- Change it into a sphere.
- Dimple it to 50% on one side.
- Rotate it so that the flat side is down.
- Change it back to a cube.
- Done.
Have fun! Thanks.. Will try that... Tas
|