CrystalShard Foo wrote:
No offense, but isn't this a somewhat overly-complicated way to send strings from one script to another? Why not just use the built in link message functionality?
Sending information via Linked Messages is perfectly okay, and I use it all the time. The LSL Library Function System shows the ability of calling functions from other scripts, but returns the function result on the line it is currently executing on. So if you are running some code, but do not want to stop the flow of things, then the Description polling is currently the easiest way around the problem.
So, for example: (CallFunction would be the function in the script to handle the data transfer via the Description)
string strValue = CallFunction("Text","ReverseString","Hello"); // Call ReverseString function in other script, and get the result.
llOwnerSay("Reversed: " + strValue); // Output the result.
But, using the Linked Message appraoch, you would have a complicated setup. You would have to fire the Linked Message, then wait for a Linked Message from the other script. And then call another function / place code in the message event to carry on triggering the rest of the code, which would be very messy.
ReverseString()
{
llLinkedMessage(LINK_THIS,1234,"ReverseString=Hello",NULL_KEY); // Send message to other script. and wait for linked message response.
}
state_entry()
{
ReverseString(); // Start executing.
}
linked_message(...etc..)
{
if(message=="ReverseStringResult") // Message retrieved from other script.
{
strValue = ... Extracted Result.
llOwnerSay("Reversed: " + strValue); // Output the result.
// Carry on executing the rest of the code, etc.
}
}