Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Multiple Scripts-Mutliple working prims of a Linked Object

Inferniel Solvang
Registered User
Join date: 31 Jan 2005
Posts: 47
02-05-2005 11:31
I am currently trying to add script to an F-14 Tomcat jet a friend made. I can get the plane to fly, I can even get the sitting positions to be correct, but he asked if I could also get the cockpit glass to slide open like on a real F-14 Tomcat. I can get the glass to slide back, but once I link all the prims of the jet together, the sliding door script is transfered to the entire jet. I only want the cockpit glass to slide open. How can I correct this?

If any scripting wizzes can help me on this, I'd appreciate it.

Thanx!
Rhombur Volos
King of Scripture & Kebab
Join date: 6 Oct 2004
Posts: 102
02-05-2005 11:47
You can use llSetPrimitiveParams to change between open/shut position and rotation on the linked prim(s) that make the cockpit glass.

I have made a debug script that you can use to get the rotation and local positions needed, and a script you can use to apply these settings to an open/close switch.

IM me ingame if you'd like to take a peek at them :)
Danny DeGroot
Sub-legendary
Join date: 7 Jul 2004
Posts: 191
02-05-2005 12:47
Rhombur,

I found myself puzzled by this very thing today.

If you don't mind, may I hit you up for a copy of the tools as well? I'll send you an IM.

== danny d.
Inferniel Solvang
Registered User
Join date: 31 Jan 2005
Posts: 47
02-05-2005 15:10
thanx...for the ideads

i've found help in the forums that i should use a joint...which makes the entire thing work...except now...the cockpit works great the first time activated...then when it returns to the original spot...it jumps away from the plane...even though i have the cockpit glass as phantom and the cylinder used to make the glass is hollowed and cut to make the shape...i'm wondering if it's because the objects are intersection...this is the code i'm using...it was from the script library...can anyone tell me what is wrong and how to correct this


---------------------------------------------------------------------------

key owner;
// Will be used to retrieve owner's key.

integer iChan = 1000;
// Channel door will listen on if other doors are touched;
// also the channel this door will broadcast on.

integer iSteps = 15;
// How many steps the door will open in, used to provide the
// illusion of sliding. Fewer steps means it opens faster,
// but more steps will make it "slide" smoother.

vector vOffset = <0.15, 0, 0.0>;
// Indicates how far the door will move with each step.
// Multiply by iSteps to calculate the total distance the
// door will move.

vector vBase;
// Used to "un-stick" the door if something blocks it.
// Not sure if this is needed since 0.5.1, objects don't
// seem to block the door any more. Leaving it in just
// in case, though. I think attempting to edit the door
// while it's moving may make it stick. This will solve
// that problem as well.

float fOpenTime = 4;
// How long the door stays open

string sSKeyword = "open1";
// Keyword door broadcasts when it's touched, to make
// other doors open. You can chain these to make multiple
// doors open when any one is touched.
// NEVER make sSKeyword and sRKeyword the same, or you may
// get some doors stuck in an infinite loop, continuously
// re-triggering each other.

string sRKeyword = "open2";
// Keyword door listens for from other doors. Will open
// when it "hears" this keyword.
// Again, NEVER make sSKeyword and sRKeyword the same.

integer bMove = FALSE;
// Is the door moving?

integer bLock = FALSE;
// Is the door locked?

integer bVerbose = FALSE;
// Confirm when owner locks/unlocks the door.

//*********************************************
// open() -- the meat and taters of the code,
// makes the door actually move.
//*********************************************
open()
{
bMove = TRUE;
integer i;
vector basepos = llGetPos();
for (i = 0; i < iSteps; i++)
{
llSetPos(basepos + i*vOffset);
}
vOffset *= -1;
llSleep(fOpenTime);
basepos = llGetPos();
for (i = 0; i < iSteps; i++)
{
llSetPos(basepos + i*vOffset);
}
vOffset *= -1;
if (llGetPos() != vBase) {
llSetTimerEvent(5);
} else {
bMove = FALSE;
}
}

default
{
//************************************************** *
// state_entry() -- set up our global variables and
// initialize the listen events.
//************************************************** *
state_entry()
{
vBase = llGetPos();
owner = llGetOwner();
llListen(0,"",owner,"";);
llListen(iChan,"",NULL_KEY,sRKeyword);
}

//************************************************** *
// listen() -- listen for other doors opening, and
// if owner wants to lock/unlock doors.
//************************************************** *
listen(integer chan, string name, key id, string msg)
{
if (chan == iChan && msg == sRKeyword) {
if (!bMove && !bLock) open();
if (bLock && bVerbose) llSay(0,"Locked!";);
}
if (chan == 0 && id == owner && msg == "lock";) {
bLock = TRUE;
if (bVerbose) llWhisper(0,"Locked!";);
}
if (chan == 0 && id == owner && msg == "unlock";) {
bLock = FALSE;
if (bVerbose) llWhisper(0,"Unlocked!";);
}
}

//********************************************
// touch_start() -- what to do when someone
// touches the door.
//********************************************
touch_start(integer count)
{
if (bLock) {
llSay(0,"Locked!";);
} else {
if (!bMove) {
llWhisper(iChan,sSKeyword);
open();
}
}
}

//************************************************** **
// timer() -- this is only used to un-stick the door
// (see vBase definition above).
//************************************************** **
timer()
{
llSetPos(vBase);
if(llGetPos() == vBase) {
llSetTimerEvent(0);
bMove = FALSE;
}
}
}
Inferniel Solvang
Registered User
Join date: 31 Jan 2005
Posts: 47
Problem Solved
02-06-2005 04:45
This post is to let all my Fellow Second Lifers know that the problem I was working on is now fixed. I'd like to give a shout out to Rhombur Volos. He's very good with the scripting. So if any of you get a chance go ahead and give him a good rating.

Thanks again so much, Rhombur.
Simon Oz
Perpetual Noob
Join date: 26 Dec 2004
Posts: 61
02-06-2005 19:09
This particular thread is really helpful. Vehicle doors seem to be a trick that's difficult to pull off.

I have a related question that probably has a much simpler answer; I've got a 'vehicle' that's going to have a door. Rather than have the door actually move, I just want to have a prim or two go phantom. I apply the script below to the prim I want to phantom on touch, and then I link. The script seems to stay with the individual prim (as in it's not visible when you edit, only if you select individual). It works so far as I can only activate the script when I touch that specific prim, but the problem is every prim that is linked goes phantom rather than just the intended door.

Code below, it's really simple stuff..

CODE

default
{
state_entry()
{
llSetStatus(STATUS_PHANTOM,0);
}

touch_start(integer total_number)
{

if (llDetectedKey(0) == llGetOwner()) {
integer status;
status = llGetStatus(STATUS_PHANTOM);

if(status == '1') {
llSetStatus(STATUS_PHANTOM,0);
} else {
llSetStatus(STATUS_PHANTOM,1);
}
}

}
}


Is this a mechanism of llSetStatus that it sets the status on any prim that's linked?
Vortex Saito
Quintzee Creator
Join date: 10 Sep 2004
Posts: 73
02-07-2005 02:39
You can't make a single prim phantom in a linked set.
Reitsuki Kojima
Witchhunter
Join date: 27 Jan 2004
Posts: 5,328
02-07-2005 04:58
Using a joint is asking for trouble.

llSetPrimativeParameters doesn't work on an object an avatar is sitting on.

What you want is llSetLocalRot if your trying to rotate the door object, or simple llSetPos if you want it to 'slide'. When used in a linked child prim, llSetPos becomes relative to the root prim.
Simon Oz
Perpetual Noob
Join date: 26 Dec 2004
Posts: 61
02-07-2005 09:13
From: Vortex Saito
You can't make a single prim phantom in a linked set.

Ah curses! So I'll have to get off my lazy arse and figure out this door thing (which has seemingly been figured out for me above). I'll come back with results here.

I think I should put together a step-by-step newbie tutorial for making doors on a vehicle after this, for my benifit as much as anyone's :)
Rhombur Volos
King of Scripture & Kebab
Join date: 6 Oct 2004
Posts: 102
02-07-2005 09:27
From: Reitsuki Kojima

llSetPrimativeParameters doesn't work on an object an avatar is sitting on.


This is correct, but it only applies to the one prim of a linked set that the avatar is sitting on, which would most likely be the main prim. All other objects can be moved and rotated with llSetPrimitiveParams without any problems.

llSetLocalRot can be emulated for llSetPrimitiveParams using only one line of code to convert from global to local rotation, thus achieving a much more fluid movement than would be possible using separate llSetLocalRot and llSetPos commands.
Reitsuki Kojima
Witchhunter
Join date: 27 Jan 2004
Posts: 5,328
02-07-2005 09:52
From: Rhombur Volos
This is correct, but it only applies to the one prim of a linked set that the avatar is sitting on, which would most likely be the main prim. All other objects can be moved and rotated with llSetPrimitiveParams without any problems.

llSetLocalRot can be emulated for llSetPrimitiveParams using only one line of code to convert from global to local rotation, thus achieving a much more fluid movement than would be possible using separate llSetLocalRot and llSetPos commands.


Interesting. I had never thought to try to simply emulate existing functions with it.. I know you can't do other things with llSetPrimativeParameters, such as hollow.
Rhombur Volos
King of Scripture & Kebab
Join date: 6 Oct 2004
Posts: 102
02-07-2005 10:01
From: someone

llSetLocalRot can be emulated for llSetPrimitiveParams using only one line of code to convert from global to local rotation.


Whoops.

Correction: the one line of code is used to convert from local to global, since llSetPrimitiveParams only rotates prims on the global axis.
Haven't tried hollow yet, but i'm fairly sure that Rejitsuki Kojima is right about that one, particularly when used in physical linked objects.
Belenos Stardust
Registered User
Join date: 1 Nov 2006
Posts: 10
fellow tomcatters
06-08-2007 06:51
Hmmm good thing I stumbled on this thread. This is exactly what I am trying to do also... create a F-14 Tomcat... My next projects tonight are the variable geometry of the wings and the canopy.

Anyone definitively figure this all out yet? Point me in the right direction please.