Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer startchannel=0;
- integer NUMLINES= 10;
- integer MAXWIDTH= 40;
- debug(string x){}//{ llOwnerSay(x); }
- list buffer; string font;
- // important to draw on the 3 objects composing each line
- // Used to read the notecard
- key query;
- integer line;
- integer wbline; // line currently displayed on the whiteboard
- string notecard;
- integer overflow=0; // in case notecard more than 10 lines touching it will scroll
- show(string str, integer row)
- {
- integer index=(row+1)*1000; // 0 maps to 1000, 1 to 2000 and so on
- if(row==-1) index=20000; // -1 maps to 20000 (title)
- debug("sending msg line: "+(string)row+" Index:"+(string)index+" {"+str+"}");
- llMessageLinked(LINK_SET,index,str,"");
- }
- // be sure the whiteboard is clean now
- clean(){
- integer i;
- for(i=0;i<NUMLINES;i++){
- show(" ",i);
- // llSleep(0.1);
- }
- //show(" ",-1);
- }
- readnotecard(){
- debug("Reading notecard "+notecard+"...");
- query = llGetNotecardLine(notecard, line);
- }
- default
- {
- state_entry()
- {
- clean();
- notecard=llGetInventoryName(INVENTORY_NOTECARD,0);
- show(notecard,-1);
- // activate dataserver
- wbline=-1; line=0;
- readnotecard();
- }
- changed(integer change)
- {
- llResetScript();
- }
- // if touched present menu
- touch_start(integer total_number)
- {
- key id=llDetectedKey(0);
- string touched=llGetLinkName (llDetectedLinkNumber(0));
- debug("touched object: "+touched);
- if(touched == "NEXT")
- {
- debug("NEXT action");
- wbline=-1; clean();
- readnotecard();
- return;
- }
- else if(touched == "PREV")
- {
- wbline=-1; line-=15;
- if(line<0) line=0;
- query = llGetNotecardLine(notecard, line);
- }
- return;
- }
- // this is where the fun is: get each line and showing it on the whiteboard (max 10 lines)
- dataserver(key id, string data)
- {
- debug("dataserver received data: "+data);
- if (data != EOF)
- {
- // data in: we must display it fully
- debug("displaying data on line "+(string)wbline);
- integer i;
- integer numrows=llStringLength(data)/30;
- integer offset=0;
- for(i=0;i<=numrows;i++){
- string slice=llStringTrim(llGetSubString(data,offset,offset+40),STRING_TRIM);
- if(slice!=""){
- wbline++;
- if(wbline<=10) {
- show(slice,wbline);
- offset+=40;
- } else {
- // must reread the previous line
- //line--;
- jump over;
- }
- }
- }
- @over;
- if(wbline>10) {
- debug("stopping reading since more than 15 lines");
- // now go fetching next but check if more than lines to be written
- // no more room for this line so we set overflow true
- overflow=1; // when in overflow, touch will display next page
- debug("Will overflow"); //show(notecard,-1);
- //llSetText("There are other pages, touch for them...",<1,0,0>,1);
- wbline=-1;
- return;
- }
- // now go fetching next dont do if line > 9
- line = line + 1;
- query = llGetNotecardLine(notecard, line);
- } else {
- // last line of text
- // clear overflow flag if set
- debug("setting overflow to false");
- //llSetText("Notecard complete",<1,1,1>,1);
- overflow=0; line=0;
- integer i;
- for(i=wbline+1;i<=10;i++) show(" ",i);
- wbline=0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement