Skip to content

Instantly share code, notes, and snippets.

@nebadon2025
Created June 19, 2014 04:57
Show Gist options
  • Save nebadon2025/61e5dc3dffdc0fed888b to your computer and use it in GitHub Desktop.
Save nebadon2025/61e5dc3dffdc0fed888b to your computer and use it in GitHub Desktop.
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()
{
llSay(0,"Touch to see osGetNotecard read in a notecard and display the text retrieved");
}
touch_end(integer num)
{
// get the first notecard in inventory (default max is 255 lines and would not show in std chat)
// each Line Return is reflected in output
string name = llGetInventoryName(INVENTORY_NOTECARD,0);
if(name == "")
{
llSay(0,"There is no notecard in prim inventory. Please place a notecard with some text in the prim to display it's contents");
return;
}
else
{
string text = osGetNotecard(name);
llOwnerSay("NoteCard Name is: "+name);
string CommandList = ""; // Storage for our drawing commands
string FontName = "Arial"; // Arial is the default font used, if unspecified
integer FontSize = 24; // default to 24 point for sample
CommandList = osSetFontName(CommandList, FontName);
CommandList = osSetFontSize(CommandList, FontSize);
CommandList = osMovePen(CommandList, 10, 10);
CommandList = osDrawText(CommandList, WrapText(text, 52));
// Now draw the image
osSetDynamicTextureData( "", "vector", CommandList, "width:1024,height:1024", 0 );
llSay(0,WrapText(text,52));
}
}
}
Take a copy and rez it to the ground to start using!
To use this board edit it and go to the contents tab
edit the file named "Note" and save it.
34 lines total.
52 characters per line.
1768 characters total.
Then click the panel board to display updated text!
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris cursus et nunc nec cursus. Vestibulum viverra risus magna, ac egestas enim accumsan in. Donec sodales ac enim ut vulputate. Phasellus lacus turpis, mollis sed vulputate at, volutpat ut magna. Quisque gravida nec leo tincidunt semper. Fusce in nisi sit amet enim luctus rutrum. Nulla volutpat viverra ligula sed luctus.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment