Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Linking

Dancing Pole
Registered User
Join date: 12 May 2005
Posts: 8
11-06-2005 03:42
Hello.

I have a script that rezzes a lot of marbles. These marbles are separate from its parent. How could I get them linked?

Here is the script:

string boardname="boardv004";
integer checkmarbles=0;

default
{
touch_start(integer num_detected)
{
llSetObjectName(boardname);
if (checkmarbles==0)
{
checkmarbles=1;
// Top Square
llRezObject("marble", llGetPos() + <-0.150, 0.600, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 1);
llRezObject("marble", llGetPos() + <0, 0.600, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 2);
llRezObject("marble", llGetPos() + <0.150, 0.600, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 3);

llRezObject("marble", llGetPos() + <-0.150, 0.450, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 4);
llRezObject("marble", llGetPos() + <0, 0.450, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 5);
llRezObject("marble", llGetPos() + <0.150, 0.450, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 6);

llRezObject("marble", llGetPos() + <-0.150, 0.300, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 7);
llRezObject("marble", llGetPos() + <0, 0.300, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 8);
llRezObject("marble", llGetPos() + <0.150, 0.300, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 9);

// Centre Square
llRezObject("marble", llGetPos() + <-0.150, 0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 11);
llRezObject("marble", llGetPos() + <0, 0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 12);
llRezObject("marble", llGetPos() + <0.150, 0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 13);

llRezObject("marble", llGetPos() + <-0.150, 0, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 14);
// The Empty Space
llRezObject("marble", llGetPos() + <0.150, 0, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 16);

llRezObject("marble", llGetPos() + <-0.150, -0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 17);
llRezObject("marble", llGetPos() + <0, -0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 18);
llRezObject("marble", llGetPos() + <0.150, -0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 19);

// Bottom Square
llRezObject("marble", llGetPos() + <-0.150, -0.300, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 21);
llRezObject("marble", llGetPos() + <0, -0.300, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 22);
llRezObject("marble", llGetPos() + <0.150, -0.300, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 23);

llRezObject("marble", llGetPos() + <-0.150, -0.450, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 24);
llRezObject("marble", llGetPos() + <0, -0.450, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 25);
llRezObject("marble", llGetPos() + <0.150, -0.450, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 26);

llRezObject("marble", llGetPos() + <-0.150, -0.600, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 27);
llRezObject("marble", llGetPos() + <0, -0.600, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 28);
llRezObject("marble", llGetPos() + <0.150, -0.600, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 29);

// Left Square
llRezObject("marble", llGetPos() + <-0.600, 0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 31);
llRezObject("marble", llGetPos() + <-0.450, 0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 32);
llRezObject("marble", llGetPos() + <-0.300, 0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 33);

llRezObject("marble", llGetPos() + <-0.600, 0, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 34);
llRezObject("marble", llGetPos() + <-0.450, 0, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 35);
llRezObject("marble", llGetPos() + <-0.300, 0, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 36);

llRezObject("marble", llGetPos() + <-0.600, -0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 37);
llRezObject("marble", llGetPos() + <-0.450, -0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 38);
llRezObject("marble", llGetPos() + <-0.300, -0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 39);

// Right Square
llRezObject("marble", llGetPos() + <0.300, 0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 41);
llRezObject("marble", llGetPos() + <0.450, 0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 42);
llRezObject("marble", llGetPos() + <0.600, 0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 43);

llRezObject("marble", llGetPos() + <0.300, 0, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 44);
llRezObject("marble", llGetPos() + <0.450, 0, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 45);
llRezObject("marble", llGetPos() + <0.600, 0, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 46);

llRezObject("marble", llGetPos() + <0.300, -0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 47);
llRezObject("marble", llGetPos() + <0.450, -0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 48);
llRezObject("marble", llGetPos() + <0.600, -0.150, 0.05>, ZERO_VECTOR, ZERO_ROTATION, 49);
}
}

}

And while I'm at it, does this look like a good script at all? hehe

God, I'm such a noob.
Zapoteth Zaius
Is back
Join date: 14 Feb 2004
Posts: 5,634
11-06-2005 05:37
I don't believe its possible to link objects with a script, altho I'm sure there are work arounds someone might be able to share with you.. When someone cleverer than me comes and posts :)
_____________________
I have the right to remain silent. Anything I say will be misquoted and used against me.
---------------
Zapoteth Designs, Temotu (100,50)
---------------
Jackal Ennui
does not compute.
Join date: 25 May 2005
Posts: 548
11-06-2005 05:43
It is possible to link objects with a script, from the parent object that is rezzing the child objects. Dancing, what you need to do is add a object_rez event handler in your parent object, which will then call llCreateLink with the ID of the newly rezzed child object (the ID is passed as argument to object_rez by the system). Also, the script in the parent object will need a call to llRequestPermission for PERMISSION_CHANGE_LINKS.
_____________________
Lassitude & Ennui - Fine prim jewelry & footwear, Nouveau(60,60)

http://lassitudeennui.blogspot.com/
Dancing Pole
Registered User
Join date: 12 May 2005
Posts: 8
11-06-2005 06:21
From: Jackal Ennui
It is possible to link objects with a script, from the parent object that is rezzing the child objects. Dancing, what you need to do is add a object_rez event handler in your parent object, which will then call llCreateLink with the ID of the newly rezzed child object (the ID is passed as argument to object_rez by the system). Also, the script in the parent object will need a call to llRequestPermission for PERMISSION_CHANGE_LINKS.


Thank you for that. I'll play around with it and see if I can get it to work. =)
Dancing Pole
Registered User
Join date: 12 May 2005
Posts: 8
11-06-2005 08:55
Well, I have tried for a couple of hours, but I cannot get it right. Is there a script I could look at as an example? Or could someone show me a bit of code? I have looked, and I cannot see anything.
Thank you
Jackal Ennui
does not compute.
Join date: 25 May 2005
Posts: 548
11-06-2005 13:46
Here's a quick script that will demonstrate what I meant:

CODE

default
{
state_entry()
{
// request owner's persmission to change link state
llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS);
}

touch_start(integer n)
{
// rez that child prim
llRezObject("child", llGetPos() + <0,0,0.5>, ZERO_VECTOR, ZERO_ROTATION, 0);
}

object_rez(key id)
{
// and add it to the linkset
llCreateLink(id, TRUE);
}

}


Rez a prim (the parent to be), add the script plus another prim named "child" to the parent's content, and touch the parent prim. If you now highlight the parent prim in edit mode, you will see both prims are in a linkset. If you still can't get it to work, feel free to IM me in-world and I'll try to help you there.
_____________________
Lassitude & Ennui - Fine prim jewelry & footwear, Nouveau(60,60)

http://lassitudeennui.blogspot.com/
Dancing Pole
Registered User
Join date: 12 May 2005
Posts: 8
11-07-2005 00:49
Thank you very much

I'll try it when I get back from work. :)
Tikhon Golitzen
Registered User
Join date: 19 Jan 2007
Posts: 2
Thanks
03-11-2007 17:47
Jackal, thanks for a complete example with llCreateLink! Now it still actual for LSL newbies, because official LSL guide contain very few really useful examples of code.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-12-2007 09:03
Dancing,

Your script could do with a few optimisations.

Unless the object rezzing the marbles is being moved while rezzing them, then the repeated call to llGetPos are not required, get it once then use it repeatedly.

Your code is also highly repetative so could be compacted using a list/loop

Also be aware that the code will only work if the base oblect is at zero rotation, any other rotation willend up with the marbles in the wrong places.