1
0

GrafittiBoard.lsl 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Grafitti board 0.0.2 for OpenSim
  2. // By Justin Clark-Casey (justincc)
  3. // http://justincc.wordpress.com
  4. // This script is available under the BSD License
  5. string text = "";
  6. integer LISTENING_CHANNEL = 43;
  7. // XXX Only putting this here as well to get around OpenSim's int -> string casting oddness
  8. string LISTENING_CHANNEL_STRING = "43";
  9. // FIXME: Should be dynamic!
  10. integer CHARS_WIDTH = 42;
  11. // Add some additional graffiti
  12. addGraffiti(string message)
  13. {
  14. while (llStringLength(message) > CHARS_WIDTH)
  15. {
  16. text += "\n\n" + llGetSubString(message, 0, CHARS_WIDTH - 1);
  17. message = llDeleteSubString(message, 0, CHARS_WIDTH - 1);
  18. }
  19. text += "\n\n" + message;
  20. }
  21. // Clear the existing graffiti
  22. clearGraffiti()
  23. {
  24. text = "";
  25. }
  26. // Actually fires the graffiti out to the dynamic texture module
  27. draw()
  28. {
  29. //llSay(0, text);
  30. string drawList = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text " + text + ";";
  31. osSetDynamicTextureData("", "vector", drawList, "1024", 0);
  32. }
  33. default
  34. {
  35. state_entry()
  36. {
  37. llSetText(
  38. "Say /" + LISTENING_CHANNEL_STRING + " <message> to add text."
  39. + " Say /" + LISTENING_CHANNEL_STRING
  40. + " !clear to clear board",
  41. <0.0, 1.0, 0.0>, 1.0);
  42. llListen(LISTENING_CHANNEL, "", NULL_KEY, "");
  43. addGraffiti("justincc's graffiti board v0.0.2");
  44. addGraffiti("Now with primitive word wrap!");
  45. draw();
  46. }
  47. listen(integer channel, string name, key id, string message)
  48. {
  49. if (message == "!clear")
  50. {
  51. clearGraffiti();
  52. }
  53. else
  54. {
  55. addGraffiti(message);
  56. }
  57. draw();
  58. }
  59. }