Skip to content

Instantly share code, notes, and snippets.

@nebadon2025
Created June 19, 2014 01:44
Show Gist options
  • Save nebadon2025/54bce9ce76821b26387c to your computer and use it in GitHub Desktop.
Save nebadon2025/54bce9ce76821b26387c 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);
}
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(data, lineNo);
lineNo++;
queryID = llGetNotecardLine("Note", lineNo);
}
} else {
if (lineNo == 25) {
llOwnerSay("Notecard too long for display, truncating.");
}
flipImage();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment