Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How can I have a prim that changes the position of another prim?

joebaldwin Beleza
Registered User
Join date: 27 May 2007
Posts: 4
03-28-2009 22:21
I'm new to LSL and maybe this question is silly, but I could not find an answer on the web.

I would like to have one prim (let's say CubeA) that, via script, tells another prim (let's say CubeB) to move to a certain position.
I know that CubeA can send a message to CubeB with llSay, so that CubeB can llListen to that message and llSetPos to a different x,y,z point.
But what I'm looking here is something different.

I'm trying to build a structure that requires a lot of communication back and forward among several prims. So, I'd like to simplify this communication, and I want to have one prim that somehow controls the motions of the other prims without sending them messages that the prims have to interpret via scripts. In other words, rather than having CubeA that tells CubeB that there is a message, so that CubeB can read that message and do something with it, I'd like to have CubeA that says something like: SetPos of CubeB to x,y,z.

How can I do this?

Thanks a lot

joe
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
03-29-2009 01:44
the only way to achieve this without communications is to link the controller and controlled prims and use llSetLinkPrimitiveParams. beware of changes that are out of range (size to small/big, distance too far / outside link distance) some will fail without a warning (I can't remember if moving outside of link distance breaks the link, just fails, or only moves to the max link distance)
_____________________
|
| . "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...
| -
Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
03-29-2009 09:51
Yeah, it sounds like you need llSetLinkPrimitiveParams.



Void: What IS the max link distance? I've linked at least five 10x10 prims together in a line, but sometimes it won't even let me go beyond a few meters.
_____________________
Life is a highway... And I just missed my exit.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
03-29-2009 10:31
There's no other way other than to use chat and listen events. However, you can limit lag by having the listening prims listen only for chat from the controller prim... such as:

llListen (channel, "controller",NULL_KEY,"";);

that way, chat from other nearby objects and avatars isn't processed by the listening prims.

As far what to communicate, you're basically wanting to convey the target prim's name and the the vector you want to move it to, so, the best way to achieve that is to just send that information. To keep things simple, name your controller prim 'controller', and each of the moving prims, give a 1 letter name (A,B,C,D, etc).

Then, to communicate your info, create an output string with both pieces of information separated by a delimiter, like a colon, (name:vector), such as...

output = "A:<1,2,3>";

and when the listening prims receives the data, you'll have to parse out each piece of information, (assuming incoming messages stored in a variable named input)...

string primName = llSubStringIndex (input, 0,0); // grabs first character only.

Then, if primName is not equal to llGetObjectName(), then that data is not for this prim, just disregard. if it IS equal, then you need to parse out the vector. You have to bear in mind that all the prims are going to receive the message, so the script in each prim has to check the name and compare against it's name. The vector in string form, and has the prim name and a colon, so...

integer delimiter = llSubStringIndex (input, ":";);
vector Vec2Set = (vector)llGetSubString (input, delimiter + 1, -1);

In the last line, I'm retrieving the vector portion of input string as a string, but casting it to a vector, and dumping into the vector Vec2Set which can be used with llSetPos().

Hope that helps.
_____________________
My tutes
http://www.youtube.com/johanlaurasia
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
03-29-2009 11:22
From: Cypher Ragu
What IS the max link distance? I've linked at least five 10x10 prims together in a line, but sometimes it won't even let me go beyond a few meters.
From the wiki:
From: someone
If the distance between two or more objects is too large, they cannot be linked.
The allowed distance is larger for large objects, and smaller for small objects.
The real rules are quite complicated.
and it then goes on to demonstrate the final point. http://wiki.secondlife.com/wiki/Linkability_Rules
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
03-29-2009 11:26
Note, however, that while you may not be able to link prims if they are at a certain distance and too small, or to move a prim too far from the others if it is too small, I BELIEVE it is still possible to link/move the prim while it is large, then resize it so that it is smaller than would normally be allowed by the link distance rules. You used to be able to do that, and to the best of my knowledge it hasn't changed.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
03-29-2009 13:04
From: Innula Zenovka

and it then goes on to demonstrate the final [quite complicated] point. http://wiki.secondlife.com/wiki/Linkability_Rules

holy frak, there's no way in hell I'd try to code that algorithm into a script... I'd just break down, use communications and be aware of moves >10 and outside the sim
_____________________
|
| . "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...
| -