|
Sean Martin
Yesnomaybe.
Join date: 13 Sep 2005
Posts: 584
|
07-24-2006 17:28
I need to understand how several variables can be sent from one unlinked object to another using the llsay. No email.  So that they both have the same data at all times. Would this require a systematic check between the two objects? (Incase one sent amount doesn't match up to the other object somehow.) But how would the listening object figure which value goes to which variable? For example this message was sent to the listener object "Health: 100" How do I get the listener to see this is for the Health variable and then turn the 100 into an integer? And then how do I make sure it was even heard by the listener so the sender doesn't update itself thinking it was succesful? I'm just assuming its done something like this. I'm not sure how it's done. If there is an easier way I'd like to know. But if anyone can show me how I could do this I'd appreciate it. Thanks 
|
|
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
|
07-24-2006 19:08
First, I use llSay, a list, and the llList2CSV / llCSV2List functions. llSay on a particular known channel a list which includes all the variables you wish to communicate. Then parse that list and pull out the variables. Have the second object say the same thing back, and the first can check to see if it heard right. If it heard right, then everything must've been sent right. If you want to make sure you didn't hear some sort of echo (shouldn't happen), you can change the order of variables for the second object to report to the first.
So . . . .
Object 1 might llSay on channel -34953 "Health,100,Intelligence,100,Height,60"
Object 2 knows in what order the things are coming. Then, it can say (either on the same channel or on a different one), "Intelligence,100,Height,60,Health,100".
When Object 1 hears this, it knows for sure that the message was received correctly.
Hope this helps. Ask if you have more questions.
Baron H.
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
07-24-2006 19:38
From: Sean Martin Would this require a systematic check between the two objects? (Incase one sent amount doesn't match up to the other object somehow.)
doesnt have to From: Sean Martin But how would the listening object figure which value goes to which variable?
For example this message was sent to the listener object "Health: 100" How do I get the listener to see this is for the Health variable and then turn the 100 into an integer?
llGetSubString http://secondlife.com/badgeo/wakka.php?wakka=llGetSubStringand sub string index http://secondlife.com/badgeo/wakka.php?wakka=llSubStringIndexyou can combine these 2 to only read parts of the string (message) altho you can skip the whole Health: part if all your looking to keep is the integer ie // lets say i have health endurance and mana string stats = "100|100|100";
integer health; integer endurance; integer mana;
default { state_entry() { list temp = llParseString2List(stats,["|"],[]); // use list to string and typecast, becuase thats how the list stored it health = (integer)llList2String(temp,0); // count starts with 0 in most everything endurance = (integer)llList2String(temp,1); mana = (integer)llList2String(temp,2); llOwnerSay( (string)(health+endurance+mana) ); // just for output } }
that perticular method is probally the ezest , but its not that great with large amounts of data From: Sean Martin And then how do I make sure it was even heard by the listener so the sender doesn't update itself thinking it was succesful? this would require a systematic check between the two objects, numerous ways of doing it, but you have 2x as many listeners in this situation btw CSV seems to be evil, it only works in certian situations, so its not good to rely on it, phrase string to list is better
|
|
Sean Martin
Yesnomaybe.
Join date: 13 Sep 2005
Posts: 584
|
07-24-2006 20:15
Perfect! Thanks! 
|