Jump to content

llMessageLinked and dataserver event


Lilah Munster
 Share

You are about to reply to a thread that has been inactive for 3672 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I am tring to activate a script that reads a notecard from a dialog menu in another script, using llMessageLinked.  The problem is, I am not real familiar with dataserver events, and am trying to adapt an existing script that reads the notecard on touch.  I strongly suspect I am putting the dataserver event in the wrong place.

The menu script appears to be sending the message correctly, at least, according to this little debugging script I got from the wiki:

default
{ 
    // Quick and dirty debugging link_messages
    link_message(integer sender_num, integer num, string msg, key id) 
    {
        llSay(DEBUG_CHANNEL, llList2CSV([sender_num, num, msg, id]));
    }
}

 That returns :"Object Name: 1, 0, Start," on the debug channel.

 

My attempt to modify the notecard reading script looks like this:

integer numread; 
string line; 
key request2; 
integer reading; 
string msg;
default {     
    link_message(integer sender_num, integer num, string msg, key id)  
    {
    }
    
    dataserver(key queryid, string data) { 
        while (msg == "Start")        
        if(queryid == request2) { 
            if(data != EOF) { 
                llSetObjectName("~");      
                llOwnerSay(data);
                request2 = llGetNotecardLine(llGetInventoryName(INVENTORY_NOTECARD,0),++numread);
            } else {
                llSetObjectName("Object Name Goes Here");                          
                llResetScript(); 
            }
        }              
    } 
}

That compiles, but fails silently.  The original notecard reading script works fine, on a touch event.  However, as this is a more complex item than the one I used the original script in, with multiple menu options, I really don't want it reading off the notecard every time it's clicked.  Any advice or pointers would be greatly appreciated.

Link to comment
Share on other sites

You need to ask for the first line of the notecard inside the link_message event, to get things started.   Something like this

integer numread;string line;key request2;integer reading;string msg;string myname;string notecard;default {	link_message(integer sender_num, integer num, string msg, key id)	{		if ("Start"==msg){			myname = llGetObjectName();			notecard = llGetInventoryName(INVENTORY_NOTECARD,0);//get the notecard's name			if(llGetInventoryType(notecard)==INVENTORY_NOTECARD){//make sure there is a notecard to read				numread=0;//zero the counter				llSetObjectName("~");				request2 = llGetNotecardLine(notecard,numread);//and ask for the first line			}		}	}	dataserver(key queryid, string data) {		if(queryid == request2) {			if(data != EOF) {				data = llStringTrim(data,STRING_TRIM);//chop off leading and trailing spaces				if(data){//if there's anything to read					llOwnerSay(data);				}				request2 = llGetNotecardLine(notecard,++numread);//and ask for the next line			}			else {//reached end of file				llSetObjectName(myname);				llResetScript();			}		}	}}

 Having said that, I would always, unless there was a compelling reason not to, read the notecard once, when the script starts (or when the notecard changes),  into a list or a series of variables, and then refer to that at run-time.  

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3672 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...