Skip to content

Instantly share code, notes, and snippets.

@nebadon2025
Created June 19, 2014 04:05
Show Gist options
  • Save nebadon2025/6dc58ac63479a5a05057 to your computer and use it in GitHub Desktop.
Save nebadon2025/6dc58ac63479a5a05057 to your computer and use it in GitHub Desktop.
string CommandList = "";
key queryID;
integer lineNo;
string FontName = "Verdana, Geneva, sans-serif"; // Arial is the default font used, if unspecified
integer FontSize = 24; // default to 24 point for sample
clear() {
CommandList = "";
}
drawText(string text, integer line) {
CommandList = osSetFontName(CommandList, FontName);
CommandList = osSetFontSize(CommandList, FontSize);
CommandList = osMovePen(CommandList, 10, 10 + (30 * line));
CommandList = osDrawText(CommandList, text);
}
flipImage() {
osSetDynamicTextureData( "", "vector", CommandList, "width:1024,height:1024", 0);
}
string str_replace(string str, string search, string replace) {
return llDumpList2String(llParseStringKeepNulls((str = "") + str, [search], []), replace);
}
string WrapText(string pcText, integer piWidth) {
list laLines = [];
integer liIndex;
integer liKeep; // Specifies if we keep the char pointed at or not
integer liLen = llStringLength(pcText);
list llSearch = [" ", "\n"];
while (liLen > 0) {
liIndex = piWidth;
if (!(liKeep = (liLen <= piWidth))) {
while ((liIndex >= 0) && (-1 == llListFindList(llSearch, (list)llGetSubString(pcText, liIndex, liIndex))))
--liIndex;
if (liIndex <= 0) {
liIndex = piWidth;
liKeep = 1;
}
}
laLines += llGetSubString(pcText, 0, liIndex - 1);
pcText = llDeleteSubString(pcText, 0, liIndex - liKeep);
liLen -= (1 + liIndex - liKeep);
}
return llDumpList2String(laLines,"\n");
}
default
{
state_entry()
{
}
touch_start(integer num) {
if (llDetectedKey(0) == llGetOwner()) {
if (llGetInventoryType("Note") == INVENTORY_NOTECARD) {
lineNo = 0;
clear();
queryID = llGetNotecardLine("Note", lineNo);
} else {
llOwnerSay("No notecard named \"Note\" found.");
}
}
}
changed(integer change) {
if (change & CHANGED_INVENTORY) {
if (llDetectedKey(0) == llGetOwner()) {
if (llGetInventoryType("Note") == INVENTORY_NOTECARD) {
lineNo = 0;
clear();
queryID = llGetNotecardLine("Note", lineNo);
} else {
llOwnerSay("No notecard named \"Note\" found.");
}
}
}
}
dataserver(key query_id, string data) {
string lineData;
if (query_id == queryID) {
if (data != EOF) {
if (lineNo < 25) {
lineData = str_replace(data, ";", ":");
drawText(WrapText(data,52) + "\n", lineNo);
lineNo++;
queryID = llGetNotecardLine("Note", lineNo);
}
} else {
if (lineNo == 25) {
llOwnerSay("Notecard too long for display, truncating.");
}
flipImage();
}
}
}
}
To use this board edit it and go to the contents tab
edit the file named "Note" and save it
Then click the panel board to display updated text!
*There is no word wrap & 52 characters per line!
Take a copy and rez it to the ground to start using!
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment