Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //read poem from notecard
- integer counter;
- key queryid;
- key notecarduuid;
- list poem;
- string notecard;
- read_notecard(){
- notecard = llGetInventoryName(INVENTORY_NOTECARD,0);//get the name of the first notecard in my inventory
- if(notecard){//if there is one
- if(llGetInventoryKey(notecard)!=notecarduuid){//and if it's been changed since last time we looked
- counter = 0; // zero the counter
- queryid = llGetNotecardLine(notecard,counter); // and ask for the first line of the card (lsl starts counting at 0, not 1
- }
- }
- }
- default
- {
- state_entry()
- {
- read_notecard();
- }
- changed(integer change)
- {
- if (change & CHANGED_INVENTORY){
- read_notecard();
- }
- if(change & CHANGED_OWNER){//force it to read aloud for the new owner
- llResetScript();
- }
- }
- dataserver(key requested, string data)
- {
- if(queryid == requested){//it's for us
- if(data !=EOF){//not finished reading yet
- data = llStringTrim(data,STRING_TRIM);//get rid of leading and trailing spaces, tabs and so on
- if(data){// if there's anything left
- if (llGetSubString(data,0,1)!="//"){//and it's not commented out
- llOwnerSay(data);
- poem+=[data];//add it to the poem list so we don't need to read it again
- }
- }
- ++counter;//advance the counter
- queryid = llGetNotecardLine(notecard,counter); //and request the next line
- }
- else{
- notecarduuid = llGetInventoryKey(notecard);
- llSleep(1.0);
- llOwnerSay("Finished reading the card. Touch me to hear the poem read again");
- }
- }
- }
- attach(key attached)
- {
- if(attached){
- read_notecard();
- }
- }
- touch_start(integer total_number)
- {
- counter = -llGetListLength(poem);
- do {
- llOwnerSay(llList2String(poem,counter));
- llSleep(0.5);
- }
- while(++counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment