need help with llMessageLinked
|
|
Danielz Shackle
Registered User
Join date: 30 Apr 2006
Posts: 100
|
05-08-2006 16:51
im good with scripting but new to sl, i would apprectiate any help on this. ive read that when making an object that consist of other objects, it reduces alot of sim lag if i use llmessage linked instead of talking about objects. im having two problems with this, first, i tried to make it the main object talk to three other objects, but one seems to respond, and the other two dont. How would i seperate which object gets which message? second, im sending a integer, but llmessagelinked works with strings. Ive found how to send a string of my integer, but how would i convert it back to integer on recieve end... ________heres a basic layout of send object code // finds values for the three reels integer r1; integer r2; integer r3; default { touch_start(integer reels) // starts the number gen by touch { r1=llFloor(llFrand(22)); r2=llFloor(llFrand(22)); r3=llFloor(llFrand(22)); llOwnerSay((string)r1); // temp, tells me r1 val llOwnerSay((string)r2); // temp, tells me r2 val llOwnerSay((string)r3); // temp, tells me r3 val state talking; // change to the "talking" state } } state talking { state_entry() { llMessageLinked(-1, 0,(string)r1, "id"  ; state default; } } ________heres a basic layout of receive object code // finds values for the three objects integer r1; default { // Waits for another script to send a link message. link_message(integer sender_num, integer num, string str, key id) { llOwnerSay((string)str); state default; } }
|
|
Teffler Detritus
Registered User
Join date: 14 Dec 2005
Posts: 19
|
05-08-2006 16:58
ive had a similar problem with sending a link message to all prims in an object, i resorted to referencing directly since there were only a couple of prims i needed to contact at the moment but it would be nice to know if anyone could shed some light on it.
To send a integer use the second parameter for llMessageLinked:
llMessageLinked(-1,10,"",id);
should send the integer 10 to all the prims.
|
|
Pru Xingjian
Fnnn
Join date: 1 Oct 2005
Posts: 11
|
05-08-2006 17:03
well with 3 variables you can do: integer r1; integer r2; integer r3; default{ touch_start(integer reels) // starts the number gen by touch { r1=llFloor(llFrand(22)); r2=llFloor(llFrand(22)); r3=llFloor(llFrand(22)); llOwnerSay((string)r1); // temp, tells me r1 val llOwnerSay((string)r2); // temp, tells me r2 val llOwnerSay((string)r3); // temp, tells me r3 val llMessageLinked(LINK_SET, r1,(string)r2,(string)r3); } } // finds values for the three objects default{ // Waits for another script to send a link message. link_message(integer sender_num, integer num, string str, key id){ llOwnerSay((string)num); llOwnerSay(str); llOwnerSay((string)id); } } You seem to have alot of unneeded code in yours
|
|
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
|
05-08-2006 17:09
I guess you have seen the wiki on this: http://secondlife.com/badgeo/wakka.php?wakka=llMessageLinkedNotice that it is better to use LINK_SET rather than -1. Note the other constants. As for your other questions: 1. Put in llOwnerSay statements in each linked prim so you can see what is going on. You would need to preface each statement with the name of the script it is in. Make sure you use the correct LINK_X constant. link_message(integer sender_num, integer num, string str, key id) { llOwnerSay("Script name " + " sender_num=" + (string) sender_num + " num=" + (string) num + " str=" + str + " key=" + (string) key); }
2. just use "  integer) str" to extract the number. I also use if statements to make different scripts respond to different ranges of num. hth (the above code not tested in world)
|
|
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
|
Objects vs. Prims
05-08-2006 17:29
From: Danielz Shackle im good with scripting but new to sl, i would apprectiate any help on this. ive read that when making an object that consist of other objects, it reduces alot of sim lag if i use llmessage linked instead of talking about objects. im having two problems with this, first, i tried to make it the main object talk to three other objects, but one seems to respond, and the other two dont. How would i seperate which object gets which message? I'm not shure about the rest of the problem, but you seem to have some confusion between objects and primitives. - Objects are built from one or more primitives.
- llmessageLinked only works between scripts in primitives within the same object.
Does this help clear things up? [I hope so!] Toodle-oo!
|
|
Danielz Shackle
Registered User
Join date: 30 Apr 2006
Posts: 100
|
05-08-2006 17:41
i understand difference between objects and primitivtes, ive just been up without sleep all night trying to get it to work
my problem is i have the three variables for now (maybe more later) and i want each prim to get and use 1 variable
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
05-08-2006 17:57
From: ed44 Gupte Notice that it is better to use LINK_SET rather than -1. now i know using the typed out constant is ezer for ppl begining the wild world of LSL but other than that how is it better?
|
|
Danielz Shackle
Registered User
Join date: 30 Apr 2006
Posts: 100
|
one question down, 1 old one still and one new one
05-08-2006 17:59
okay Pru Xingjian & ed44 Gupte helped me get each of three prims to have seperate integer passed to it,
i just seperated each prim to part of the message, for eample prim1
default { link_message(integer sender_num, integer num, string str, key id){ llOwnerSay((string)num); }
just uses the integer num, and prim2 uses the string num, etc
**this still leaves the question of how do i then revert thewse three items integer num, string str, and ket id back to integer a, b, c
and new question
this seems like a shortcut way, it might be the only way that works, but it only has rom for three variables. what if i want to work with say 6 prims and 6 variables? is it possible?
i know i can do it with alk and listen, but im trying to doit this way to minimize the lag on my sim
|
|
Teffler Detritus
Registered User
Join date: 14 Dec 2005
Posts: 19
|
05-08-2006 18:25
you could do it with a list as a string. in your root script you have a list ie: list values = [1,4,9,3,4,9];
string str_values = llDumpList2String(values, "+"); // creates a string "1+4+9+3+4+9"
llMessageLinked(-1,0,str_values,id);
then for each child prim: message(integer sender, integer num, string msg, key id) { list values = llParseString2List(msg, ["+"],[]); //convert string back to list
... ... ...
with the list in the client you then just pull the value relevant to the prim its in, so if it is prim 2 you would need to take the second value from the list which would actually be position 1 within the list.
0 1 2 3 4 5 1+4+9+3+4+9
to convert back just use the relevant functions for lists.
integer r1 = llList2Integer(values[1])
Hope this makes sense, its 2am over here in UK and i can barely keep my eyes open.
|
|
Danielz Shackle
Registered User
Join date: 30 Apr 2006
Posts: 100
|
thanks
05-08-2006 18:31
that makes perfect sense, ill have to try that. thank you all for ur help... ill post again if i need more but i think with all ur ideas ill make it work
|
|
Danielz Shackle
Registered User
Join date: 30 Apr 2006
Posts: 100
|
syntax error
05-08-2006 19:10
i like the possibilites the list strings will give me, that will allow me to have many things going on at the same time.
i run into one problem, on part of code
integer r1 = llList2Integer(values[1])
i get a syntax error between the s and [ after values am i missing something?
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
05-08-2006 19:27
From: Osgeld Barmy now i know using the typed out constant is ezer for ppl begining the wild world of LSL but other than that how is it better? Higher readability? doesn't really need more reason than that... ^^;
|
|
Danielz Shackle
Registered User
Join date: 30 Apr 2006
Posts: 100
|
ahhhahhh
05-08-2006 19:49
i took out he [] around the list name and it works... this is perfect, thanks
|