Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

A drawbridge request...

Cirius Montale
Don't Mess With The Bot
Join date: 13 Oct 2005
Posts: 28
12-22-2005 03:33
Hi all. I'm struggling daily to try and understand the basics of scripting, and failing on the whole. I have much respect for anyone who can comprehend what appears to me to be a combination of ancient egyptian algebra and sumerian calculations.

What i'm after is a door that opens outwards and downwards, like a drawbridge, to act as an access door for my flying saucer. I want the door to be 'chat' activated, and respond to the owners voice only...I really am awful at scripting, so if anyone can help in the least I would really appreciate it. I check this board frequently, or you can IM me in game. Just look for the little robot with plans for galactic domination, and a doorless flying saucer...

I'm prepared to pay L$50 to anyone who helps me complete this task, that will probably take the best of you approximately 50 seconds to perform...

Please...please...please...help!

Cirius Montale.
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
12-22-2005 05:21
From: Cirius Montale
I have much respect for anyone who can comprehend what appears to me to be a combination of ancient egyptian algebra and sumerian calculations.


The Sumerians had 360 degrees to a circle. Now we have quaternions. I think this is a huge step backwards in terms of understandability. :-)

The voice activated/owners voice only is easy with a listener, but the rotation thing I'll leave up to someone else, although making a rotating drawbridge style door is on my list of things to learn.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
12-22-2005 09:07
I don't really understand quaternions, not deep down intuitively, but I do understand WHY we use them.

Most times you use a rotation you'll also want a move in the direction that you're facing. A quaternion gives you the rotation of a unit vector, which means you can do some fancy maths when you mulitply it by a <x, y, z> displacement vector and move to the right place more easily than any other way of doing it.

Quaternions seem to also give you a single fixed way of refering to any rotation, at least in part because of this - if you play in the edit window you can see that the conversions back jump around sometimes, and the whole object sets itself to a new rotation when you set only one set of numbers directly.

Quaternions also 'add' together smoothly (by multiplying in fact, just to confuse people) - and give you another quaternion, so although for most of us they're not hugely intuitive, they are actually pretty useful.

llEuler2Rot and llRot2Euler let those, like me, that don't grok them to use them pretty efficiently still. Good luck with your journey!

Can I suggest you look at llSetLocalRot and llSetRot for your drawbridge btw, I'll try to dig you out a door script that can be adapted and send it to you.
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
12-22-2005 11:16
I've got a 1 prim door that can easily be turned into a drawbridge...L$250 at NDE for the personal (copy only) version.

Of course...you want it to be part of your flying saucer...so..hmmm...(the doors function ungrouped)...
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
12-22-2005 11:34
From: Eloise Pasteur
I don't really understand quaternions, not deep down intuitively,


I don't know anybody that does, not in the way that addition of vectors is intuitive. I think anybody that does would have to at least be comfortable with visualising things in 4 dimensions.
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Jamie Marlin
Ought to be working....
Join date: 13 May 2005
Posts: 43
Comfort...
12-22-2005 13:09
I have to manipulate 3D geometry all the time as part of my real life job... and I don't understand quaternions. They are just not intuitive. The closest I can come to visualizing them is a shorthand for a mathematical definition of a coordinate system the old and new orientations are related by a single rotation, plus the size of that rotation. But that is not accurate, I know. The math doesn't support that directly. Does anybody have a better way to visualize them? I sure would like to hear it.

I DO know that they make the math simpler. In my software, I do rotations in tensor notation, with 3 element vectors multiplied by 3x3 rotation matricies. It is ugly and messy and I love the elegance of quaternion notation. If only it made more sense! Ah well. I shall just have to settle for the trained monkey approach. And when all else fails, I can stick my code into a prim and watch it spin. Try doing THAT in the real world!
Cirius Montale
Don't Mess With The Bot
Join date: 13 Oct 2005
Posts: 28
12-22-2005 14:43
I never expected that throwaway comment to have some much interest...by the way, the main problem is that this door is to be attached to a vehicle, a couple of you have tried to help, but i think it may be a problem. Any ideas for alternative doors that I could use on a moving ship?
Andy Enfield
Hippo Technologies CEO
Join date: 22 Nov 2005
Posts: 79
12-22-2005 15:02
What about a door that "dissolves" in a space-agey-flying-saucer-esque kind of way? No moving prims there needed at all; just a loop from 0% transparent to 100% and a switch to phantom to open, and reverse that to close ...?

Good luck with it :-)

Andy
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
12-22-2005 15:21
In fact...a door that disappears like that might look something like...

CODE

//------------------------NDE DISAPPEARING WALL------------------------------
//
// By: Kenn Nilsson
// Updated: 12/17/05
// Version: 0.1
//
//---------------------------------------------------------------------------


string name;

float alpha = 1.0;
integer x;

default
{
state_entry()
{

}

touch_start(integer total_number)
{
name = llDetectedName(0);

for(x = 0; x < 10; x++)
{
alpha = alpha - 0.1;
llSetAlpha(alpha, ALL_SIDES);
}
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);
llSetTimerEvent(15);
}

timer()
{
for(x = 0; x < 10; x++)
{
alpha = alpha + 0.1;
llSetAlpha(alpha, ALL_SIDES);
}
alpha = 1;
llSetAlpha(alpha, ALL_SIDES);
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]);
llSetTimerEvent(0);
}
}



(I just happen to use it in my house...heh)

I have the name in there 'cause I restrict who can open the door...but took that part out for you...
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
12-22-2005 15:36
If you still want to have the door move and open, check this script out. IM me in-world if you would like help setting it up.
Sydney Alexander
Registered User
Join date: 19 Feb 2005
Posts: 69
12-22-2005 16:36
I have some simple click or /say to "hollow". They make great space doors, hidden doors and so on. You can also change the shape or cut and so on really simple scripts. I can get them if you are interested...
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
12-22-2005 18:20
You can take nearly any regular freebie door/freebie door script and use that for a drawbridge-type door. The basics of door-making:

Create a cube, and cut it precisely in half by entering cut begin and end values. I believe something like 0.125 B, and 0.625 E will work to cut the cube in half. The importance of this step is to get the prim's axis to an edge of the prim. Since you can't move the axis, cutting the prim in half does the trick. After you've halved your cube, shape it into a door, using the axis-edge as the hinge.... put the axis where the hinge would be, then stretch the door from there.

Finally, you need a simple script that rotates the prim around the axis when touched. I believe there is a door script in the forums script library. Drop that into your prim and you're good to go. If you change the llSetRot() functions to llSetLocalRot(), you should be able to link the single-prim door and have it function as you desire.
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
12-22-2005 19:05
From: Kenn Nilsson
In fact...a door that disappears like that might look something like...
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);



I tried to make a door for Cirius in the sandbox last night; was going to be a simple hack of a prim for open and a second for closed, and swap alpha and phantom status to open/close the door. However I found that llSetPrimitiveParams([PRIM_PHANTOM, TRUE]); changed the entire linked object, and not just the prim it was in. This meant that when the door opened the entire UFO was phantom.
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
12-22-2005 19:19
Depending how the saucer's made you could make the door open using a cut, which is easy and saves on prims. :)
_____________________
Sydney Alexander
Registered User
Join date: 19 Feb 2005
Posts: 69
12-22-2005 19:26
Try:

CODE

//Speak to hollow
//Sydney Alexander


default
{
state_entry()
{
llListen(3,"", llGetOwner(),"");
}

on_rez(integer num)
{
llResetScript();
}
listen(integer channel, string name, key id, string message)
{
if (message == "open")
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_CIRCLE, <0.0, 1.0, 0.0>, 0.9, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
}
if (message == "close")
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_CIRCLE, <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>]);
}
}
}


or:

CODE

//Click to set HOLLOW %
//Sydney Alexander


integer open = FALSE;

default {
state_entry() {
}

touch_start(integer total_number) {
if (!open) {
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_CIRCLE, <0.0, 1.0, 0.0>, 0.95, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
// the 0.95 is how hollow to make it.
open = TRUE;
} else {
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_CIRCLE, <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>]);
open = FALSE;
}
}
}


Might be fun...

From: AJ DaSilva
Depending how the saucer's made you could make the door open using a cut, which is easy and saves on prims. :)
Sydney Alexander
Registered User
Join date: 19 Feb 2005
Posts: 69
12-22-2005 19:32
Oh and let us not forget our friend...

CODE

//Click to CUT

integer open = FALSE;

default {
state_entry() {
}

touch_start(integer total_number) {
if (!open) {
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_SQUARE, <0.25, 1.0, 0.0>, 0.70, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
// the 0.25 in the "<0.25, 1.0, 0.0>" is how much to cut
open = TRUE;
} else {
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_SQUARE, <0.0, 1.0, 0.0>, 0.70, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
open = FALSE;
}
}
}




From: Sydney Alexander
Try:

CODE

//Speak to hollow
//Sydney Alexander


default
{
state_entry()
{
llListen(3,"", llGetOwner(),"");
}

on_rez(integer num)
{
llResetScript();
}
listen(integer channel, string name, key id, string message)
{
if (message == "open")
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_CIRCLE, <0.0, 1.0, 0.0>, 0.9, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
}
if (message == "close")
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_CIRCLE, <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>]);
}
}
}


or:

CODE

//Click to set HOLLOW %
//Sydney Alexander


integer open = FALSE;

default {
state_entry() {
}

touch_start(integer total_number) {
if (!open) {
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_CIRCLE, <0.0, 1.0, 0.0>, 0.95, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
// the 0.95 is how hollow to make it.
open = TRUE;
} else {
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_CIRCLE, <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>]);
open = FALSE;
}
}
}


Might be fun...
Cirius Montale
Don't Mess With The Bot
Join date: 13 Oct 2005
Posts: 28
12-26-2005 09:14
I'm really irritated that i'm at my parents for the next week. They live in the stone age...I can't wait to try these ideas out...Thanks for all the advice...
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
12-26-2005 10:28
From: AJ DaSilva
Depending how the saucer's made you could make the door open using a cut, which is easy and saves on prims. :)

I had a door design involving changing a cut 5 times in succession. Looked very cool but had a habit of crashing my client straight to desktop. Bug reported it, but obviously not going to work as a permanent fixture until they track it down.
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
drawbridge how to
12-27-2005 03:56
Create a sphere.
Set dimple end to 0.5 (giving you a hemisphere)
Change the sphere to a box.

Notice that the box had been cut in half, but that the axis of rotation is now on one end.

Reshape the box to form your drawbridge and use a llSetLocalRot()-based door script to open and close it.

I usually use something like this when building doors (not in-world at the moment, so I can't verify syntax)
CODE
default
{
touch_start(integer num_detected)
{
llOwnerSay( (string)llGetLocalRot() );
}
}
Drop that into the prim, and after linking the door to the rest of the saucer position it in the closed position, then touch it. Record the quat it gives you.
Rotate it to its open position and touch it again. Record the open quat.
(You'll need to redo this if you ever change which prim of the saucer is the root)

Then kill that script and add something along the lines of this.
CODE
vector Position; // remember the initial position and reset it after each rotation to eliminate drift

default
{
state_entry()
{
Position = llGetLocalPos();
state closed;
}
}

state closed
{
state_entry()
{
llSetLocalRot(</*insert closed quat here*/>);
llSetPos(Position);
llSetTouchText("Open");
}
touch_start(integer num_detected)
{
state open;
}
}

state open
{
state_entry()
{
llSetLocalRot(</*insert open quat here*/>);
llSetPos(Position);
llSetTouchText("Close");
}
touch_start(integer num_detected)
{
state closed;
}
}
This is of course just one way to skin the cat - but I find that builders seem to prefer this way of doing it, while scripters are often more comfortable with a base angle + rotation way of doing things.