Advertisement
LethBaumann

Notecard Reading Example.

Apr 16th, 2018
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //****************NOTECARD******************//
  2. red
  3. blue
  4. green
  5. yellow
  6. orange
  7. purple
  8. //*******************************************//
  9.  
  10. //this script will grab and chat a random line from the "colors" notecard each time the prim is touched.
  11.  
  12. string card = "colors";
  13. key linecountid;
  14. key lineid;
  15. integer linemax;
  16.  
  17. integer random_integer( integer min, integer max )
  18. {
  19.   return min + (integer)( llFrand( max - min + 1 ) );
  20. }
  21.  
  22.  
  23. default
  24. {
  25.     state_entry()
  26.     {
  27.         //get the number of notecard lines
  28.         linecountid = llGetNumberOfNotecardLines(card);
  29.     }
  30.  
  31.     touch_start(integer total_number)
  32.     {
  33.         lineid = llGetNotecardLine(card, random_integer(0, linemax));
  34.     }
  35.  
  36.     dataserver(key id, string data)
  37.     {
  38.         if (id == linecountid)
  39.         {
  40.             linemax = (integer)data - 1;
  41.         }
  42.         else if (id == lineid)
  43.         {
  44.             llSay(0, data);
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement