Problem with llMessageLinked
|
|
Jadeyn Courtois
Registered User
Join date: 30 Sep 2008
Posts: 3
|
10-01-2008 23:39
I'm working on creating a washer and dryer that you turn the clothes spinning on and off, and I keep getting this error message when trying to compile, it's on the llMessageLinked lines: (15, 79) : ERROR : Function call mismatches type or number of arguments I'm relatively new to scripting and have been trying to piece this together for a few days now and I honestly have no clue what exactly the problem is. I've tried looking through the lsl wiki but I can't figure it out. Could someone help me see what the error is so I can fix it? Thanks in advance. integer on = FALSE; vector axis = <0,1,0>; float spinrate = 1.5; float gain = 1.0; vector axisoff = <0,0,0>; float spinoff = 0; float gainoff = 0;
default { touch_start(integer total_number) { if(on) { on = FALSE; llMessageLinked(4, 0, llTargetOmega( axisoff, spinoff, gainoff ), ""); } else { on = TRUE; llMessageLinked(4, 0, llTargetOmega( axis, spinrate, gain ), ""); } } }
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
10-02-2008 00:08
It should be:
llMessageLinked(integer linknum, integer num, string str, key id);
What you are trying to do is:
llMessageLinked(integer linknum, integer num, function llTargetOmega(), key id);
That is not possible. You need to put the llTargetOmega in the childprim and use something like "ON" in the linkedmessage to start/stop the rotation.
|
|
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
|
10-02-2008 00:12
I really wish what you're trying to do was possible but no, you can't do it. Here is the definition of llMessageLinked: llMessageLinked(integer link, integer num, string msg, key id) Since llTargetOmega() doesn't return a string, you can't use it directly in llMessageLinked(). I guess you meant to send a message to a linked child to make it rotate with llTargetOmega(). In that case, you have to send just a message meaning ON or OFF to the child. And put a script in the child to interpret that value in a link_message() event. In the main script: touch_start(integer total) { on = ! on; // Invert TRUE/FALSE llMessageLinked(4, on, "", ""  ; } The child script: default { link_message(integer sender, integer on, string msg, key id) { llTargetOmega(<0.0, 1.0, 0.0> * (float)on, 1.5, 1.0); } } To nullify the vector is enough to stop an omega target. Since TRUE/FALSE have the values 1/0, when you multiply by FALSE, you nullify the vector and TRUE just leaves it unchanged. TIP: Tho it isn't important in such a script, always use float numbers when they are expected. Otherwise the compiler --which is very stupid and absolutely not optimized-- will add what is necessary to cast the numbers and your script will lose its time doing these conversions when all you need to do is to add a decimal dot to prevent it.
|
|
Jadeyn Courtois
Registered User
Join date: 30 Sep 2008
Posts: 3
|
10-02-2008 02:10
Ahhhh, alright I understand that now, thank you so much! I guess I really ought to try and familiarize myself better with what exactly all the different variables are like integer string functions etc. Also, noted about the float numbers.
I have another question, though. With using the linkedmessage like that, how would you tell the script to do two different functions based on the state, if it isn't reversible by nulling the vector? By doing something such as link_message() { if on = TRUE { } else { } }
? Like telling it to set the prim params to prim light point on/off. And please understand I'm not asking for the scripts to be written for me, I'm just trying to get some feedback here on whether the format I'm thinking is right or not. Either way, thanks for taking the time to reply before!
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
10-02-2008 02:19
From: Jadeyn Courtois
By doing something such as link_message() { if on = TRUE { } else { } }
Yes. Allthough that would be: link_message(integer sender, integer on, string msg, key id) { if (on == TRUE) do something; else do something else; } or way shorter: if (on) etc. Since on is an integer it can be either true (not zero) or false (zero). So 'if(on)' is the same as 'if (on == true)' and 'if(!on)' (not on) is 'if (on == false)'. Get it?
|
|
Jadeyn Courtois
Registered User
Join date: 30 Sep 2008
Posts: 3
|
10-02-2008 02:20
Got it! Thanks a bunch, I really appreciate the feedback. 
|
|
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
|
10-02-2008 06:19
If you want other data to be passed, such as parameters for the light or whatever, you can encode it into the string parameter. If you have lots of bits of data, you can put them into a list, then use the CSV functions (comma-separated value) to encode and decode them for the link message, like this: Sending the link message: float brightness = 0.8; vector color = <1.0, 0.2, 0.0>; llMessageLinked(0, TRUE, llList2CSV([brightness, color]), NULL_KEY);
Receiving the link message: link_message(integer sender, integer on, string msg, key id) { if (on == TRUE) { list params = llCSV2List(msg); float brightness = (float)llList2String(params, 0); // Extract the brightness vector color = (vector)llList2String(params, 1); // Extract the color
// Set your prim params here... } }
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
10-02-2008 08:44
From: Pedro McMillan If you want other data to be passed, such as parameters for the light or whatever, you can encode it into the string parameter. If you have lots of bits of data, you can put them into a list, then use the CSV functions (comma-separated value) to encode and decode them for the link message.... Just beware if any of your parameters are strings and might have comma characters in them. In that case you might want to encode the string parameters with something like llStringToBase64() (and then decode on the receiving side with llBase64ToString() of course).
|