Jump to content
Sign in to follow this  
Mitzie Mohr

Select a notecard to use within a script

Recommended Posts

I have a script that reads a notecard with:

 

string _notecard = "name of notecard"

From there the code reads information from the notecard.

Is there a way to have multiple notecards in a script and let the user chose which to use?

Share this post


Link to post
Share on other sites

if the script provides a way to select a different notecard and save that name to the variable, yes it is possible...

you can even automate the selection of the notecard in various ways (for instance, the resizer package I have placed in the LSL Libray forum, automatically tries to select the correct language card if it's available, based on what the users language is detected as)

past the script providing some means to select a different one, the only possibility is allowing the user to modify the script, or having them change the name of the notecard.

Share this post


Link to post
Share on other sites

Here is a simple example for a dialog that lets you choose which nc to read.  It's simple and assumes that there aren't more than 12 ncs and that the nc names aren't any longer than 24 characters

list glNoteCards;integer giListener;integer giChannel = -1234567;integer giCurrLine;string gsCurrNC;key gkQuery;default{	touch_start(integer total_number)	{		glNoteCards = [];		integer i = llGetInventoryNumber(INVENTORY_NOTECARD);		while (i) {			glNoteCards += llGetInventoryName(INVENTORY_NOTECARD, --i);		}		llDialog(llDetectedKey(0), "Select a notecard to be read.", glNoteCards, giChannel);		giListener = llListen(giChannel, "", llDetectedKey(0), "");	}	listen(integer channel, string name, key id, string message)	{		integer index = llListFindList(glNoteCards, [message]);		if(index) {			gkQuery = llGetNotecardLine(gsCurrNC = llList2String(glNoteCards, index), giCurrLine = 0);		}		llListenRemove(giListener);	}	dataserver(key requested, string data)	{		if (gkQuery == requested) {			//do stuff here			if (data == EOF) {				//do stuff here after finishishing reading				return;			} else {				//do stuff here			}			gkQuery = llGetNotecardLine(gsCurrNC, ++giCurrLine);		}	}}

 

Share this post


Link to post
Share on other sites

... and if its any use, the script here - http://kimmscripts.wordpress.com/2011/06/07/multiple-notecard-giver/ - does multipage dialog handling which could be combined with Darkie's script if you have more than 12 notecards.

Note that this gives out notecards, but if you replaced the llGiveInventory() call in give_notecard with the call to start the notecard reading, you'd be pretty much there.

Also note the comments on why I didn't open/close the listen on demand.  Aside, if anyone has a better way to handle multiple avs touching it, other than maintaining a stack of listens to open/close, I'd be interested in hearing about it :)

Kimm.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...