Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

round robin llmessagelinked?

Whispering Hush
Join date: 20 Mar 2007
Posts: 277
05-21-2007 13:16
wanted, function to send a message to a prim selected from a pool of prims in sequential order, newgy, feel free to step up and lay some lsl on me :-)

humbly,

Whisper.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
Newgy isnt a performing seal.
05-21-2007 15:02
He also doesnt understand the request.
_____________________
I'm back......
Cryas Tokhes
Great Googley Moogley...
Join date: 8 Feb 2006
Posts: 124
05-21-2007 15:58
I really have no idea if this will work, but I beleive it is a point in the right direction. This will most likely have errors since this is one of my first improvisational scripting. I would like a second opinion.

Sender:
CODE

string message = "I like kibbles and bits!";

default
{
touch_start{

integer x;
integer PrimSum = llGetNumberOfPrims();

for (x = 1; x <= PrimSum; x++)
{

llMessageLinked(LINK_ALL_OTHERS,x,message, NULL_KEY);
}
}
}


Receiver:
CODE

default
{
link_message(integer sender_num, integer num, string message, key id)
{
if (message == "I like kibbles and bits!")
llSay(0,"I, too, like kibbles and bits!");
}
}


Any other thoughts from others?

PS: the receiver code will have to be in EACH child prim.
Cryas Tokhes
Great Googley Moogley...
Join date: 8 Feb 2006
Posts: 124
05-21-2007 16:00
Remember that the prim number selected by 'x' will have to be selected when you link it. All the selection happens in reverse order. so you will have to select each prim in reverse order of the pattern you will want them to be messaged.

hope this helps or allows others to clarify
Whispering Hush
Join date: 20 Mar 2007
Posts: 277
05-21-2007 20:04
From: Newgate Ludd
He also doesnt understand the request.


lol! (hides a bucket of fish).

Sorry newgate, i meant it in this sense http://en.wikipedia.org/wiki/Round_robin_DNS.

Hope that sheds some light for you, be well!

whisper.
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
05-21-2007 20:11
So.. You've got a master prim and bunch of worker prims. You want the master to distribute some work load throughout the worker prims?

Are these prims all linked together?

How much data does it take to get a working going? Is it just a number or a big, complicated list of instructions?

Any idea how quickly new tasks will need to be sent to workers and how quickly they will be able to do the work?
Whispering Hush
Join date: 20 Mar 2007
Posts: 277
05-21-2007 20:28
From: Cryas Tokhes
Remember that the prim number selected by 'x' will have to be selected when you link it. All the selection happens in reverse order. so you will have to select each prim in reverse order of the pattern you will want them to be messaged.

hope this helps or allows others to clarify


Close cryas, and thank you for the lsl. Not quite what i'm after though. i'll post you what i have.

this is the sender touch event, using your donation.

CODE


string test = "test";
default
{
state_entry()
{

}

touch_start(integer total_number)
{
integer x;
integer PrimSum = llGetNumberOfPrims();

for (x = 1; x <= PrimSum; )
{

llMessageLinked(x, 0, test, NULL_KEY);

x++;
}


}
}


and then i have 2 reciever prims linked, and the root making 3 prims in totall for the pool.
each script says it's linkname on receipt of linkmessage with this script.
CODE


default
{
// Waits for another script to send a link message.
link_message(integer sender_num, integer num, string str, key id)
{
llSay(0,str + " one");
}
}


the output is :

Object: test two
Object: test three
Object: test one

which is the entire pool. instead of sending data to the entire pool, i want to send it to one prim from the pool, then when the next event comes in, select the next prim from the pool and send to it.

Sorry in advance for any confusion :-)

Whisper.
Whispering Hush
Join date: 20 Mar 2007
Posts: 277
05-21-2007 22:32
Can someone please point out my mistake? I must be missing something obvious, here's my second attempt.

CODE

string test = "test";
integer x;
integer i=1;
default
{
state_entry()
{
integer x =llGetNumberOfPrims();
i++;
if (i =x)
{
i = 1;
}
}

touch_start(integer total_number)
{

state runcode;
}

}
state runcode
{
state_entry()
{
integer x =llGetNumberOfPrims();

llSay(0,(string)i);
llSay(0,(string)x + " " +(string)i);
llMessageLinked(i, 0, test, NULL_KEY);
state default;
}

}


which outputs:

Object: 1
Object: 3 1
Object: test one

i was expecting (string)i to increment on the next touch event, where am i going wrong?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-21-2007 23:47
From: Whispering Hush
Can someone please point out my mistake? I must be missing something obvious, here's my second attempt.

CODE

string test = "test";
integer x;
integer i=1;
default
{
state_entry()
{
integer x =llGetNumberOfPrims();
i++;
if (i =x)
{
i = 1;
}
}

touch_start(integer total_number)
{

state runcode;
}

}
state runcode
{
state_entry()
{
integer x =llGetNumberOfPrims();

llSay(0,(string)i);
llSay(0,(string)x + " " +(string)i);
llMessageLinked(i, 0, test, NULL_KEY);
state default;
}

}


which outputs:

Object: 1
Object: 3 1
Object: test one

i was expecting (string)i to increment on the next touch event, where am i going wrong?

your mistake is if( i = x) instead of if( i == x)

i = x will always return be true as its assigning i the value of x which is 3. As this is non zero it counts as true so the i = 1 assignment takes palce.

As a point of 'good' code design try not to use single letter variable names for globals.
If its significant enough to be a global it should also be important enough to have a meaningful name.
_____________________
I'm back......
Whispering Hush
Join date: 20 Mar 2007
Posts: 277
05-22-2007 00:07
From: Newgate Ludd
your mistake is if( i = x) instead of if( i == x)

i = x will always return be true as its assigning i the value of x which is 3. As this is non zero it counts as true so the i = 1 assignment takes palce.

As a point of 'good' code design try not to use single letter variable names for globals.
If its significant enough to be a global it should also be important enough to have a meaningful name.



Thank you newgate :-)