LSL: Notecard Selector

One of my friendly librarian colleagues in SL asked if I had a script to generate dialogs and allow users to select notecards handy. I didn’t, so I coded it up. It seems like it could be useful to others, so here you go:

This script is in LSL, for Second Life. Just copy and paste it into a script, throw a few notecards into the object, and you’ll be ready to go!

//  Notecard Selector
//  by Ann Enigma
//  This script presents users with a list of notecards in a dialog box, and allows them to select one
//  Note: The names of the notecards must be less than 24 characters long

// This script is licenced under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
// http://creativecommons.org/licenses/by-nc-sa/3.0/us/

// configurable options
string message = "Which notecard would you like to read?"; // the message on the dialog box
integer command_channel = 616; // the channel on which to listen for commands (you probably won't need to change this)

// the script
list notecards;

default
{
     state_entry() {
          integer i = 0;

          // read the title of each notecard into a list
          for(i=0;i
						
  • James/Calisto

    Hi Hilary,

    What a great script! Does this script work if you copy and paste from the post? I tried and got a syntax error at (9, 23).

    Thanks!

    Calisto/James

  • http://www.3greeneggs.com Hilary

    It looks like the code rendering engine is replacing the double quotes (“) with curly quotes. Just replace them all and it works great.

    -Hilary

  • Ciaran

    Thanks for this excellent script – (as mentioned the quotes need to be replaced) :)

  • Lesya

    Hi, Hillary:

    Thank you for the wonderful website – learning quite a few things from you. I am terribly sorry, but I am daring to ask you a question as you stand as a SL scripting expert in my eyes. Please, forgive me for taking your time, but your answer will be much appreciated.

    In this one script we need to automatically unlink objects. We have used llbreakalllinks(), llbreaklink and similar. We need to request permissions of the owner and have used llrequespermissions and similar functions. It just doesn’t work. We suspect there is some little trick we just don’t know about.

    Any help will be greatly appreciated!

  • djmurray

    eh im getting errors can someone help?

  • http://www.3greeneggs.com Hilary

    Hi DJ,

    Did you see the note above about the double-quotes?

    If you’re still getting an error, please comment back and let me know what it is.

    Best,

    Hilary

  • Martin

    I got it to compile correctly, place 3 notecards but it doesn’t do anything on the TOUCH_START event. No Dialog pops up.

  • PrinceLot

    Re edit this post with a working one telling people to fix it kind of annoying. and i did the changes noted but still got errors.

  • http://notfrom-here.info Notfrom Luxemburg

    It gives me the following error:

    Object: llDialog: button labels must be 24 or fewer characters long

    I figured it was the crazy characters used in some of the notecards, but changing that did not help.

  • http://notfrom-here.info Notfrom Luxemburg

    Ah, figured it out. The titles of all notecards together cant be longer then 24 chars.

  • Nick Noakes

    Hilary

    I keep getting a syntax error at line 23 when saving the script: i.e. for the line beginning notecards

    for(i=0;i
    notecards = (notecards=[]) + notecards + [llGetInventoryName(INVENTORY_NOTECARD,i)];

    Any ideas what I’m doing wrong?

    Thanks

    Nick

  • Markle Marksman

    Thanks Hilary. I have been bouncing around SL for over a year now and just getting serious about writing LSL scripts. Thanks for taking the time to share this.
    Best regards …….

  • Ren

    Dear Hilary,
    I just wanted to say: thank you so much for your generosity in writing and sharing this script.

  • Aaron

    Wanted to know if theres a way to show more than 12 objects, So it would go to another page?

    Thanks Great script <3