Here a very simple script able to read notecards. and display them paging and breaking them with different fonts.
How it works:
Simply drop a (only one!) notecard in the object repository. Script when reset (you can say "RESET" on public chat for resetting).will read the notecard.
Every time you touch the object it will go one page further.
You can easily change the fontsize (look at the code), and in next version of opensim you can change the font :)
Notes:
1\ it uses undocumented functions on osDrawing. I'll try to also document them properly, maybe in the opensim wiki
2\ it uses an undocumented feature of notecard reading I've found reverse engineering the opensim code. I'm a bit afraid the programmers will change this, so I need to be in touch with some scripters to know how notecard reading is going on.
salahzar
//
// Note: very important:
// drawing starts with x-> y v where x, y are in the range 0..255
string drawList="";
integer offset=1;
integer fontsize=10;
integer row=0;
integer rows;
integer cols;
integer start=0;
add(string str)
{
drawList = osMovePen(drawList, offset, (fontsize+2)*row+offset);
row++;
drawList = osDrawText (drawList, str );
}
default
{
state_entry()
{
string nc=llGetInventoryName(INVENTORY_NOTECARD,0);
integer lines=llGetNumberOfNotecardLines(nc);
llSetText("Click for changing page\n# of lines: "+(string)lines,<1,1,1>,1);
// number of rows
rows=255/(fontsize+2)-1;
cols=rows*2.5;
start=0;
row=0;
llOwnerSay("**Reset.. Fontsize: "+(string)fontsize+" Notecard: "+llGetInventoryName(INVENTORY_NOTECARD,0)+" **");
llListen(0,"",llGetOwner(),"");
}
touch_start(integer count)
{
//drawList = osSetFontName(drawList,"Courier");
drawList ="";
drawList = osSetFontSize (drawList, fontsize ); row=0;
integer wbline=0;
string nc=llGetInventoryName(INVENTORY_NOTECARD,0);
integer lines=llGetNumberOfNotecardLines(nc);
if(start>=lines)
{
llOwnerSay("Restarting from top");
start=0;
}
while( start < lines )
{
string data=llGetNotecardLine(nc,start+1);
integer i;
integer numrows=llStringLength(data)/cols; // number of rows to use
integer offset=0;
for(i=0;i<=numrows;i++){
string str=llGetSubString(data,offset,offset+cols-1);
if(str!=""){
wbline++;
if(wbline<rows) {
//llOwnerSay((string)start+"-"+(string)wbline+":"+str);
add(str);
offset+=cols;
} else {
osSetDynamicTextureData("", "vector", drawList, "", 0);
return;
}
}
}
// fetch next line
start++;
}
osSetDynamicTextureData("", "vector", drawList, "", 0);
}
listen(integer channel,string str, key id, string data)
{
if(data=="RESET")
{
llResetScript();
return;
}
}
}