Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Can't get scripts in linked prims to work

Xaq Zeno
Registered User
Join date: 30 May 2006
Posts: 9
04-30-2007 18:28
I wrote a test script and put it in all the prims in an object I've linked together:

CODE

default
{
state_entry()
{
llSay(0, "TEST: " + llGetObjectName() + " ready");
}

on_rez(integer nParam)
{
llSay(0, "TEST: " + llGetObjectName() + " rezzed");
}

touch(integer nCount)
{
llSay(0, "TEST: " + llGetObjectName() + " touch_start");
}

touch_start(integer nCount)
{
llSay(0, "TEST: " + llGetObjectName() + " touch_end");
}

touch_end(integer nCount)
{
llSay(0, "TEST: " + llGetObjectName() + " touch_start");
}

attach(key kID)
{
llSay(0, "TEST: " + llGetObjectName() + " attached: key = " + (string) kID);
}

changed(integer nChg)
{
llSay(0, "TEST: " + llGetObjectName() + " changed: what = " + (string) nChg);
}

object_rez(key kID)
{
llSay(0, "TEST: " + llGetObjectName() + " object_rez: key = " + (string) kID);
}

state_exit()
{
llSay(0, "TEST: " + llGetObjectName() + " exiting");
}

timer()
{
llSay(0, "TEST: " + llGetObjectName() + " timer");
}

link_message(integer nSender, integer nNum, string sMsg, key kID)
{
llSay(0, "TEST: " + llGetObjectName() + " link_message");
}


}


Nothing happens in any prim other than tha root.

I did some digged and found this page:http://rpgstats.com/wiki/index.php?title=Link
It make mention of a receiver script but the link doesn't go anywhere.

So, on the belief that it might work, I set about trying to do what it describes and added this code to a script in the root prim:
CODE

SendMessages()
{
integer nPrims = llGetNumberOfPrims();
if (!nPrims)
return;

integer nTemp = nPrims - 1;
llOwnerSay("Sending to " + (string) nPrims);

integer i;
for(i=1; i<nPrims+1; ++i) {
llSay(0, "Sending to " + (string) i);
llMessageLinked(i, 0, "", NULL_KEY);
llSleep(1);
}
}


Only the script in the root prim gets the linkmessage.

What am I doing wrong? or is it just not possible?
Thanks
Xaq
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
04-30-2007 23:01
usefull resources
old wiki most of us learned from
new wiki

kk down to bidness

linked messages are pretty simple .. once you know how to use them

point A to point B
simplest link message
CODE

//sender script

default
{
touch_start(integer total_number)
{
llMessageLinked(2 , 99, "some string", NULL_KEY);
}
}

sending it to prim number 2, becuase once you link prims the root becomes 1 and the next one would be 2
CODE

// receiver script

default
{
link_message(integer sender_num, integer num, string str, key id)
{
llOwnerSay("this message was sent by " + (string) sender_num);
llOwnerSay("i was sent the integer vlaue " + (string) num);
llOwnerSay("its sent a string with " + str);
llOwnerSay("and finally it contained a key = to " + (string) id);
}
}


if you want all your prims to hear the message at the same time you need to use a constant
check out this

theres a table that tells you what constants you can use
CODE

LINK_ROOT 1 root prim in linked set (but not in a single prim, which is 0)
LINK_SET -1 all prims in object
LINK_ALL_OTHERS -2 all other prims in object besides prim function is in
LINK_ALL_CHILDREN -3 all child prims in object
LINK_THIS -4 prim script is in


ill send the message to all the prims including the one that originaly sent the message so ill use LINK_SET (actually i use -1, its better practice to use the words tho)

the setup would be the same drop a receiver in all the prims

messages in some form of sequence
CODE

//sender script

default
{
touch_start(integer total_number)
{
integer total_amout_of_prims = llGetNumberOfPrims();
integer current_place = 1;
do
{
llMessageLinked(current_place, 99, "some string", NULL_KEY);
llSleep(3);
}
while (++current_place <= total_amout_of_prims);
}
}


you could use a for loop, but do whiles are faster ... receiver is the same

once you have the messages going out you can use if/else if test's to filter out the data and get the event to do different things
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
05-01-2007 05:35
I'll ask the obvious no-brainer... are your prims linked? Select them all then Tools -> Link.

Other than that, I would try LINK_SET as your target to see if they get the message then.
Xaq Zeno
Registered User
Join date: 30 May 2006
Posts: 9
05-01-2007 14:36
Yes, the prims are linked

The code I'm calling:
CODE

integer nPrims = llGetNumberOfPrims();
if (!nPrims)
return;

llOwnerSay("Sending to " + (string) nPrims");

integer i;
integer nThis = llGetLinkNumber();
for(i=1; i<nPrims+1; ++i) {
llSay(0, "Sending to #" + (string) i);
llMessageLinked(i, 0, "", NULL_KEY);
llSleep(1);
}


When run, it prints that it will send to 3 prims (I've linked together 3 prims)

I am also already trying to send the message with the llMessageLinked call
The parameters (except the link number are all blank, I don't care about the message, I just want to drive an event. I've tried it with other messages as well -- it doesn't matter.
Furthermore, the none of the events in the child prims EVER fire, not on rez, NEVER, not even if I edit the script in the prim (Edit Linked Prim checked) and Save or Reset.

Still stuck
Any other ideas?
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
05-02-2007 09:36
Are the scripts in the child nodes set to running? If no events at all are triggering thats the first place to look.
Xaq Zeno
Registered User
Join date: 30 May 2006
Posts: 9
05-02-2007 14:16
How do I set the scripts in the child prims to running?
Is there another LSL call to do this in the script running in the root prim?

I just checked -- the scripts were not set to running.

Setting them to running solved the problem.

Thanks
Xaq