This was a system for accessing a NoteCard file in an object. It's two scripts, with the main processing script handing off the NoteCard data requests to another script.
Both scripts have to be in the same prim, and communicate by choosing "channels" to talk on.
I'll let the code speak for itself and we can talk about it after...
None of this code has been compiled, as I'm at work and unable to login for testing... Anyone ever thought of making an external "code tester"?
DataUser Script:
CODE
string DataCard = "DataCard";
integer LineNumber = 0;
integer ReturnDataGo = 0;
integer ReturnDataLine;
string ReturnDataString;
// --------------------------------------------------
// Function to trigger string data from line number
// --------------------------------------------------
GetNoteData(integer gsdline, string gsddata) {
llMessageLinked(llGetLinkNumber(), gsdline+100000, (string)gsddata, "");
// wait for datareturn
do
{
llSleep(.5)
} while (ReturnDataGo = 0);
ReturnDataGo = 0;
// -------------------------------------
// Recieve data from datareader script
// -------------------------------------
link_message (llGetLinkNumber(), RDataChannel, RDataString, DataKey)
{
if (RDataChannel>199999 && RDataChannel<300000)
{
ReturnDataLine = RDataChannel - 200000;
ReturnDataString = RDataString;
ReturnDataGo = 1;
} // End if
} // End link_message
}
// --------------------------------------------------
default
{
GetNoteData(0, DataCard)
llSay(0, ReturnDataString);
GetNoteData(1, DataCard)
llSay(0, ReturnDataString);
GetNoteData(2, DataCard)
llSay(0, ReturnDataString);
} // End default
DataReader Script:
CODE
integer DataChannel;
string DataString;
string DataKey; //null string. Not used.
// ---------------------------------------------------------
// This code is made to make the process
// of using NoteCards for data a much
// simpler affair.
//
// The DataChannel variable taken from the message
// is coded to ignore channels 0-99999, and to otherwise
// convert the DataChannel into a line number for reading
// data by subtracting 100000 from it.
//
// Response data is sent back on a DataChannel 100000 higher.
// That means a request for line 24 would be sent as 100024,
// and would be sent back on channel 200024
//
// Example: llMessageLinked(llGetLinkNumber(), line requested + 100000, "NoteCardName", "")
// ---------------------------------------------------------
// --------------------------------
// begin datacard processing code
// --------------------------------
default
{
link_message (llGetLinkNumber(), DataChannel, DataString, DataKey)
{
if (DataChannel>9999 && DataChannel<200000)
{
llGetNotecardLine((DataChannel-100000), DataString);
} // End if
} // End link_message
dataserver(key query_id, string data)
{
// Send the notecard data
llMessageLinked(llGetLinkNumber(), DataChannel+100000, (string)data, "");
}
} // End default