Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

position script good for unlinked doors

Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
02-11-2008 00:34
here is a script for moving a prim or linkset relative to another prim thats not linked keeping offset and rotations intact therefore ideal for including in house builds where the door is not linked.The controller script would go in the door frame in a house build and when clicked sends a silent chat string to the "set position" script in the root prim of the door or a single prim.
My greatest thanks to rotation guru Nava Muni for helping me on my way to understand rotations in LSL.
any improvements or enhancements are welcomed.
a working model containing both scripts can be copied at my platform at

http://slurl.com/secondlife/Emerald Isle/41/68/651/

---------------------------------------------------------------------------------------
controller script

CODE

//sends a string position (vector) and rotation to "set position" script
default
{
touch_start(integer total_number)
{
llSay(1101, (string)llGetPos() + ";" + (string)llGetRot() );
}
}
CODE


--------------------------------------------------------------------------------------
set position script

CODE

//Prim Movement Script
//Billy Islander Feb.2008
//
//With greatest of thanks to rotation guru Nava Muni for his patience and help with this script.
//
//feel free to modify ,distribute , use in your builds , if you paid for this script IM me Billy Islander

// Sets the position of a prim or linkset relative to another keeping rotations and offsets intact.

vector myoffset = <0.0,-0.286,0.22>; // difference between x,y,z co-ordinates of controller(doorframe) and door (root prim ,point of rotation)
default
{
state_entry()
{

integer handle = llListen( 1101, "controller", NULL_KEY, "" ); /// rename controller to the name of the object containg the contoller script

}

listen(integer channel, string name, key id, string msg)
{
// "msg" received from controller is a vector and rotation separated by a ";"
// split these "two pieces" into a list for easy access

list pos_and_rot = llParseString2List( msg, [";"], [] );


// take the first list element and convert it from a string to a vector
vector mynewvector = (vector)llList2String( pos_and_rot, 0 ); // 0 is 1st list element


// take the second list element and convert it from a string to a rotation
rotation mynewrotation = (rotation)llList2String( pos_and_rot, 1 ); // 1 is 2nd list element


// llSay(0,"rotation values are" + llDumpList2String(pos_and_rot, "1" )); // allows us to see values sent by contoller

llSetPos(mynewvector + myoffset * mynewrotation);
llSetRot(mynewrotation);
llSay(0,"moving to" + (string)llGetPos());
llOwnerSay((string)llGetPos());
}
}
CODE
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-11-2008 02:26
isn't the point of a move position door that it can be linked? why then use chat messages instead of link messages?
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
02-11-2008 07:52
From: Void Singer
isn't the point of a move position door that it can be linked? why then use chat messages instead of link messages?


Hi Void , many people have basic scripted doors with linked prims attached such as handles ,door knockers so therefore cannot be linked to the main structure.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-11-2008 10:01
yet, if it's unlinked, you can get the same effect from a simple rotation script, and asumming it's unlinked, why does it need to chat from the contoller, since the door parts themselves can be linked, and either move or rotate as a single object...
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
02-11-2008 10:38
From: Void Singer
yet, if it's unlinked, you can get the same effect from a simple rotation script, and asumming it's unlinked, why does it need to chat from the contoller, since the door parts themselves can be linked, and either move or rotate as a single object...

this script is to align the door to the house with same relation (position and rotation) to the house if the house is moved ie you take the house into inventory and rez it somewhere else then move it , plus as you may know objects that do rotations sometimes have a tendency to drift.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-11-2008 11:18
ah the naming threw me. sorry for that.

a suggestion though, instead of a touch handler, you can automate the system for a house or similar stationary structure by using moving_start and moving_end... on moving end it triggers the say, causing the door to follow.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Moundsa Mayo
Registered User
Join date: 21 May 2007
Posts: 16
02-11-2008 11:25
Except if one rotates a build only, must ALSO translate some, since no rotating_start, rotating, rotating_end events in LSL 8^(
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-11-2008 11:49
true, although they are usually in combination with moves, so a timered poll for a short interval checking rotation wouldn't hurt....

you're not the only one that wishes for rot_start/end

which reminds me.. the door/follower should (for safety) have a built in warppos function as well, in case it needs to move more than 10m
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
02-11-2008 15:20
From: Void Singer
ah the naming threw me. sorry for that.

a suggestion though, instead of a touch handler, you can automate the system for a house or similar stationary structure by using moving_start and moving_end... on moving end it triggers the say, causing the door to follow.


i did experiment with moving_start but found it very inconsistent for instance if the distance moved was quite small the controller did,nt report any movement.I.m still very much a novice at scripting but found this a good project to use as a learning tool and hopefully it will help someone along the way lol. btw Void i edited the title ,it did look like it was a door script thanks for pointing that out.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-12-2008 05:18
very small move sometimes won't register with the viewer (same for rotations), but they ARE correct on the sim, leaving and coming back will usually show it correctly, or you can do an edit on the prim that causes a full prim update (such as setting hover text even if it's with spaces) to force a viewer update... this is a long standing problem =/
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Rubee Adelaide
Registered User
Join date: 2 Oct 2006
Posts: 15
02-12-2008 17:17
This looks cool, Billy! I have a house with unlinked doors. I need them to stay unlinked because:
1. I want handles to move with door, not with unsatisfying time delay
2. Because of the unusual geometry of my doors, I want the doors to be phantom when open (without making the whole house phantom so that I fall through the floor).

I was going to write up a notecard to help people position the doors if they move the house around, but having a touch-alignment would be really slick!

Great idea! I'll give it a try next time I log in.
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
02-13-2008 01:06
From: Rubee Adelaide
This looks cool, Billy! I have a house with unlinked doors. I need them to stay unlinked because:
1. I want handles to move with door, not with unsatisfying time delay
2. Because of the unusual geometry of my doors, I want the doors to be phantom when open (without making the whole house phantom so that I fall through the floor).

I was going to write up a notecard to help people position the doors if they move the house around, but having a touch-alignment would be really slick!

Great idea! I'll give it a try next time I log in.


thanks Rubee, being phantom should present no problem as the controller script just reports its position and rotation to the door ,1 thing i did,nt make very clear in my original post (just edited it) was that the "set position" script should be made to listen for the name of the object containing the controller script ,so in the line:
CODE
integer handle = llListen( 1101, "controller", NULL_KEY, "" );
CODE
 
rename controller to the name of the object containg the contoller script , hope that helps.
Tazmania Trefusis
Registered User
Join date: 13 Jan 2008
Posts: 85
05-05-2008 04:17
Hiya billy.
Is there a linked message version of this. As I was directed to this thread when i posted this query....

I'm lookin for something that updates the position all the time (pos & rot) and without chat broadcast

From: someone
If you could imagine a spaceship with a vertical mast coming down from underneath the ship with 2 various sizes satellite dishes, end to end, on the bottom of the mast. (Dishes obviously pointing out horiz 180 degrees to eachother)

When I built the seperate mast & dishes..made the mast the root prim and linked the dishes etc to the mast...it all rotated just fine.

When I link the whole mast & dish segment to the spaceship, which has the root prim in it's center (for flight/flying), how do I then get the dishes to rotate on the lower mast?.

Ive managed to rotate the mast around the Z axis but the dishes stay still..as they are now still connected to the mast, but the mast is no longer the route prim. I had put the slow rotation script in the mast before.

So now..I know I can rotate the dish by putting a rotation script in the dish itself (i think lol) but how do i get the whole assembly to rotate?. Assembly is 2 dishes (small & large), each dish with a center spike plus the larger dish has a little disc halfway along the spike. Am I limited to just having a 1 prim assembly rotating?

Is it anything to do with the order of linking? dishes to mast, mast to ship, ship to center root prim? (naa cant be..doesn't sound right)
Any help would be appreciated as I will be coming across this problem a few times with other projects


Im not a scriptor as such but any guidelines/tips or directions on this would be appreciated

Taz
Tazmania Trefusis
Registered User
Join date: 13 Jan 2008
Posts: 85
05-05-2008 04:30
Ive managed to do something but not what was intended. Ive got the mast linked to the root prim of the ship and it just so happens that the mast protrudes down from under the ship exactly from the middle of the root prim axis, which helps alot.

Instead of the 5 prim 2xsat dish assembly i had before, i now put a sculpty (one of cel edmans sculpties from his geopack 2) which, when stretched inwards, sorta looks like 2 sat dishes back to back. There not really 'bowl' shaped but more like flat discs. I put this this dead center of the vert mast and put a slow rotation script in it. So now it does rotate as required but sculpty shape looks nowhere as good as the prim version I had.
Ive had to make compromises in asthetics and function. If the mast had not been lined up with the root prim Z axiz, it wouldnt have worked so I still need a solution to the above query as i will be doing a projects where masts, rotating objects not be any where enar the root prim and certainly not directly its central axis