Tallulah Bourjade
Registered User
Join date: 16 Oct 2006
Posts: 2
|
12-29-2007 09:09
will deliver random parts of the notecard to chat. I have a script that reads the entire notecard to chat, but, I want one that will read like random quotes from one card.
|
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
|
12-29-2007 12:44
// This script does an llSay on channel 0 of a random line of text read from a // notecard. It does the llSay every 10 seconds, but it can be modified to // use a different trigger (such as a touch event, or a listen event) by modifying // the code in the "state_entry()" lfunction in the "ready" state // // This code reads the entire notecard into a list of strings, so is limited by // how big the notecard is. You may have to modify the code to read a // random line directly from the notecard if the list overflows available // memory.
string gNotecardName = "YOUR NOTECARD NAME HERE"; integer gNumNotecardLines; integer gNumLinesRead; list gSayingsList;
default { state_entry() { llGetNumberOfNotecardLines(gNotecardName); }
dataserver(key queryID, string data) { gNumNotecardLines = (integer) data; state readList; } }
state readList { state_entry() { gNumLinesRead = 0; llGetNotecardLne(gNotecardName, gNumLinesRead+1); }
dataserver(key queryID, string data) { gSayingsList = gSayingsList + data; gNumLinesRead++; if gNumLinesRead < gNumNotecardLines ) llGetNotecardLine(gNotecardName, gNumLinesRead+1); else state ready; } }
state ready { state_entry() { // put code here to setup whatever you want to trigger the random saying // In this example, its setup to say every 10 seconds llSetTimerEvent(10.0); }
timer() { llSay(0, llList2String(llSayingsList, llFloor(llFrand(gNumNotecardLines)))); } }
_____________________
"Free your mind, and your ass will follow" - George Clinton
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
12-29-2007 13:09
// // Simple script example - // says one random line from a notecard when touched. // Written by Boss Spectre // // // string notename = ""; // insert the name here if you wish to use a specific note. // // internal variables, changing these changes nothing. key queryCount; key queryLine; // default { touch_start(integer num) { // get the name of the first note in inventory // substitute the name for this if you prefer // to use a specific note. if ( llGetInventoryNumber( INVENTORY_NOTECARD ) > 0 ) { // remove the following line if you inserted a note name above. notename = llGetInventoryName( INVENTORY_NOTECARD, 0 ); // get name of first note
// pick a random line number in the note queryCount = llGetNumberOfNotecardLines( notename ); } } // triggered when a line of the notecard is read dataserver(key QID, string queryData) { if (QID == queryCount) { // pick a random line number in the note // queryData contains the line count in a string queryLine = llGetNotecardLine( notename, llFloor( llFrand( (float)queryData ) ) ); } else if (QID == queryLine) { // just say the line // queryData contains a line read from the note llSay( 0, queryData ); } } }
|