Script to keep two separately linked groups together
|
|
Persian Chevalier
Registered User
Join date: 8 Jan 2007
Posts: 68
|
03-25-2008 22:10
Hi all, I originally posted this in the building tips and just now realized I put it in the wrong forum. so.... here it is again.
I'm looking for a script, or some magic solution, to keep pieces together. I have two separate linked sets (parts of a clock) that need to stay together when I pick them up and put them back out. If someone could point me in the right direction, I would greatly appreciate it!!
Thanks!
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
03-26-2008 02:35
well sensors are cool.. they can scan for a certain object key.. one of the things a sensor can do is give you the position and rotation of a detected object
If part A.. rezzed part B.. then Part A would know the key of Part B... it would then be a short order to, say, have part A tell Part B it's key.. and then they can use the relative positions of one another to do things.
Part A is a cabinet, Part B is the pendulum.
Rez cabinet. Cabinet rezzes pendulum. Cabinet says "hey pendulum with key X.. my Key is Key Y" Pendulum thinks.. "oh hey you're talking to me! where was that cabinet?" Pendulum then does a little math and figures out where IT should be, relative to the cabinet, and goes there.
Move the pendulum, and it scans for that cabinet again. if it finds it, it moves there, if not, it dies and uses regionsay to shout to the cabinet "hey I totally died, rez another one"..
Move the cabinet and it talks to the pendulum and says "hey I moved come on over".
It's not code.. but maybe this will help you think of how the code can be written.
Instead of the sensor.. you COULD just use chatter between the cabinet and pendulum.
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
03-26-2008 07:40
Select both objects betore taking into your inventory. When you rez them, they should have the same relative positions. Unless you are rezzing by script, in which case I suggest putting a script in one or both of the objects that'll move it to a point relative to the location it is rezzed when it gets the 'on_rez' event.
|
|
Persian Chevalier
Registered User
Join date: 8 Jan 2007
Posts: 68
|
03-26-2008 12:48
Hi.. Thanks for responding. I'll research sensors and see what I can come up with. The two separate links can't be individually selected because one of them can't be selected from it's position.
Any other help or suggestions would still be appreciated!! Thank you so much for all assistance!! I'm slowly learning - but learning!!!
Persian
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
03-26-2008 18:31
I don't understand. Select one of them, then hold down the SHIFT key and select the other. If you can select each of them individually, you should be able to select both. Anyway, the sensor idea would be good if you can't put scripts in the objects being rezzed themselves. That way you could have the script that does the rezzing keep track of their relative positions and orientations. If it works to put scripts in the rezzed objects, you could easily do something like: vector REL_OFFSET = <...>; rotation DELTA_ROT = <...>;
default { on_rez(integer startParam) { vector rezPos = llGetPos(); rotation rezRot = llGetRot();
vector targetPos = rezPos+REL_OFFSET*rezRot; rotation targetRot = rezRot*DELTA_ROT;
llSetPrimitiveParams( [ PRIM_POSITION, targetPos, PRIM_ROTATION, targetRot ]); } }
or some variant, like one that records the position prior to the rez and/or deletes the positioning script after the call to llSetPrimitiveParams().
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
03-26-2008 20:29
my solution to this most times is to have a main part which rezzes the secondary part... seeing as it's a clock firing a sensor from the secondary is pretty cost effective, if the primary goes, it just self deletes.... you can either rez the secondary part from the primary by menu, or automatically after it's started, or even when it is rezzed itself.
I'm guessing it's a pendulum clock, or a scots clock (the kind that rotate their counterweights)
in both cases you may look into building it slightly different allowing you to make it a single object (I've used half cut textured boxes for pendulums before to good effect in tall case clocks)
_____________________
| | . "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... | - 
|
|
Persian Chevalier
Registered User
Join date: 8 Jan 2007
Posts: 68
|
03-27-2008 00:20
Thank you all for your suggestions. I shall be doing some research!
Hewee, the entire clock (anniversary clock) is under glass which is why the two separate link sets cannot be clicked independently.
The rezzing idea sounds promising so I shall start my research with that.
I've attached a pic of the clock I built. I saw a similar type clock, and wanted to see if I could build one.
|
|
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
03-27-2008 02:25
To select both parts, go into edit mode and drag a box around the objects you wish to select. Anything that lies within the borders of the box will be selected. Therefore you CAN select objects which are normally "not" selectable because they happen to be inside another object.
|
|
Dekka Raymaker
thinking very hard
Join date: 4 Feb 2007
Posts: 3,898
|
03-27-2008 03:37
you can actually move the glass dome, select everything thats under it, then select the dome as well, do undo and the dome moves back over the internal parts while everything is selected and then link.
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
03-27-2008 04:49
I actually needed to work out how to do this, to deal with a cage door. The door, being multiple prims, had to remain a separate object from the rest of the cage.. and unlike some of the "simpler" suggestions in this thread, simply telling customers "group select" isn't good customer service. It's far too easy to move the door out of alignment with the cage, and that's when you really want something that is "smart".
The fact is, that each object "knows" it's own position and rotation, and with a little bit of math, it's easy for "door" to know where it should be, relative to the cage. The trick, is figuring out how to deal with sharing that information between the two objects. Sensors can work, as can channeled chatter and timers.
If object A rezzes object B.. then Object A KNOWS the key of it's child. From there, it's not hard for the parent to tell the child the location of the parent, and from there the child can move where it belongs.
Is it perfect? no.. moving object A, there's always going to be some lag before Object B catches up, and such movement can rarely survive a border crossing. But for purposes of cabinet doors and whatnot.. a solution like this isn't too bad.
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
Cheewha Palen
Registered User
Join date: 27 Nov 2007
Posts: 78
|
03-28-2008 17:13
From: Winter Ventura I actually needed to work out how to do this, to deal with a cage door. Hi winter! Would it be possible to post a version of this script I think many people have this issue and would be great contribution! Thanks
|
|
Rubee Adelaide
Registered User
Join date: 2 Oct 2006
Posts: 15
|
03-28-2008 19:22
Check out this thread: /54/c9/240454/1.htmlBilly Islander posted a script that does something similar. It's for a door that's unlinked from the rest of the house. If you touch the door frame, the door moves to the right position relative to the frame. Helps to keep the door in alignment with the frame, even if the owner moves the house around.
|