link_message problems for me
|
BronYAurStomp Lightworker
Beep Boop Boop Bop
Join date: 11 Dec 2005
Posts: 25
|
12-20-2005 17:23
I'm stuck on what's going wrong here. I'm trying to send some variables (which i've tested to be 'working' and such) to another prim in the linked set. the prim returns that the message is received, but i can't unpack the data right. the llsays return this: Message received...Here's the raw Command = Nothing <-- this is from Null() I'm fairly new at LSL, heh. here's some of the script: [ if (command == 0) { //Null Command list scommand = ["NULL",OwnerRot,MyRot]; } if (command == 1) { //Stop Command list scommand = ["STOP",OwnerRot,OwnerPos,MyPos,MyRot]; } if (command == 2) { //Come Command list scommand = ["COME",OwnerRot,OwnerPos,MyPos,MyRot]; llSay(0,"Command is " + (string)command + (string)llList2String(scommand,0)); } // NERVOUS SYSTEM // llMessageLinked( LINK_SET, MyChannel, llDumpList2String(scommand, "0.0"), ""); ----that's the sending script----- here's the receiving script link_message(integer sender,integer num, string str, key id) { if(num == MyChannel) { llSay(0, "Message received...Here's the raw" + str); list message = llParseStringKeepNulls( str, ["0.0"], [] ); string RCommand = llList2String(message,0); NewRot = (rotation)llList2String(message,1); NewLoc = (vector)llList2String(message,2); llSay(0, "Command = " + (string)RCommand); if(RCommand == "NULL") { llSay(0,(string)RCommand); Command0(); } if(RCommand == "COME") { llSay(0,(string)RCommand); Command2(); } Null(); } } ]
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
12-20-2005 17:28
You need to define list scommand before you start all the if checks. Each variable you define "lives" within the { } pair it's defined in. So you're basically defining the list inside the if() { } code block, then the variable is dead by the time you leave the code block, so the llMessageLinked doesn't send anything.
Try this. Put an llSay in the sender, outside all the if() { } blocks, right before you call llMessageLinked. See what the value of scommand is there. it'll be empty.
A proper compiler would catch this as a syntax error, because in llMessageLinked you're trying to use a variable scommand that's dead, or out of scope. For some reason the LSL compiler doesn't catch this. Or, it's possible that you have another list scommand defined somewhere, either in that function or globally, and you're doing a duplicate definition inside the if() { } blocks. Then the compiler won't catch anything, but your code saves the data to one scommand, and ends up sending a different scommand, so once again, your data is missing.
|
Jora Welesa
Dark Lady of the Sith
Join date: 11 Jul 2005
Posts: 153
|
12-20-2005 18:04
I had the same problem starting out with Link messages and mutli-veriable sends. I found this, though: http://secondlife.com/badgeo/wakka.php?wakka=ExampleArgumentMultiplexing It saved me worlds of trouble. From what I can tell, right now there's no seperator between list elements when they're returned as a string, so literally they are all running together as one long string with no spaces.
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
12-21-2005 00:29
I think they're both right - but it's hard to read code pasted that way. The correct tag is php in [] and with a / at the end to get it nicely formated, pretty please!
Anyway, your llDumpList2String line defines no spacer between the elements, that makes parsing them back at the other end tricky. You can define any spacer you want, things like |, ^, & are all pretty common if you know they're not going to occur in the messages you're sending. At the other end you use llParseString2List(list foo, ["|", "^", "&"], []); to constitute your list (you don't need all the separators if you're only using one obviously) and thus your original commands.
|
BronYAurStomp Lightworker
Beep Boop Boop Bop
Join date: 11 Dec 2005
Posts: 25
|
12-21-2005 12:39
I actually did define list scommand earlier, so an llsay outside of the if statements do return the values correctly (sry). I think i've narrowed the problem down to either (1) something wrong with my 'packing' of data. Eloise says there are no spacers in the llDumpList2String(scommand, "0.0") , but i thought 0.0 -was- the spacer. (2) The other problem would be 'unpacking' the data, which is what this does (i think): message = llParseString2List( str, ["0.0"], ["|"] ); (message is defined before as global var) I thought it took out and split at 0.0...which would leave the data nice and split. But the variables defined afterwards, like string RCommand = llList2String(message,0) have no value. So i'm really confused.
|
BronYAurStomp Lightworker
Beep Boop Boop Bop
Join date: 11 Dec 2005
Posts: 25
|
12-22-2005 13:02
 please help!
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
12-22-2005 13:48
Ok, your logic looks OK to me, and yes there is a spacer, I don't know why I missed it first time, sorry. Can I suggest maybe you use a null spacer ("|"  say, and try unparsing use llParseString2List() rather than the keeping nulls version... No obvious reason it should work, except it might keep your vectors together better. But I'm confused about why, I must admit. There's not anything shouting that it won't work. The only other thing could be that you're using message somewhere else and that's blanking it, but it's hard to see how it could reset in that time.
|
BronYAurStomp Lightworker
Beep Boop Boop Bop
Join date: 11 Dec 2005
Posts: 25
|
12-22-2005 14:09
*uber_edit* goddamnit. problem fixed. argh. i'm such an idiot!!! Thanks for all your help guys.
|