Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Constants
- string SAYINGS_NC = "Sayings";
- // Globals used when reading the notecard
- integer ncLine;
- key ncKey;
- integer ncOK;
- // Storing the list
- list Sayings;
- integer item;
- integer maxitems;
- default
- {
- // When the script starts...
- state_entry()
- {
- Sayings = [];
- // Check the notecard is there...
- if (llGetInventoryType(SAYINGS_NC) == INVENTORY_NONE)
- {
- llOwnerSay("Can't find " + SAYINGS_NC + " notecard!");
- return;
- }
- // Start reading it...
- ncOK = FALSE;
- ncLine = 0;
- ncKey = llGetNotecardLine(SAYINGS_NC, ncLine);
- }
- // When a new line of data has been read from the notecard...
- dataserver(key qid, string data)
- {
- if (qid == ncKey) {
- if (data == EOF) {
- // Notecard finished!
- if (llGetListLength(Sayings) == 0) {
- llOwnerSay("No data in notecard!");
- return;
- }
- else {
- ncOK = TRUE;
- item = 0;
- maxitems = llGetListLength(Sayings);
- Sayings = llListRandomize(Sayings, 1);
- }
- }
- else {
- // We have new data - add the lines to the Sayings list
- // (if it's not a blank line)
- if (llStringTrim(data, STRING_TRIM) != "") Sayings += [data];
- // Request next line
- ncKey = llGetNotecardLine(SAYINGS_NC, ++ncLine);
- }
- }
- }
- touch_start(integer total_number)
- {
- if(ncOK) {
- key avi = llDetectedKey(0);
- llRegionSayTo(avi, 0, llList2String(Sayings, item++));
- if (item >= maxitems) {
- Sayings = llListRandomize(Sayings, 1);
- item = 0;
- }
- }
- }
- changed(integer c)
- {
- if (c & CHANGED_INVENTORY) llResetScript();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement