Fileref:lsl/sloodle setup notecard.lsl

From SLIS Second Life Wiki

Jump to: navigation, search

Image:folder.gif (parent)

The purpose of this script is to read a configuration notecard provided in the prim's inventory, and communicate its contents to other scripts in the same prim/object via link messages. It is currently used in nearly all Sloodle objects, allowing configuration via sloodle_config notecards.


Note: if this script detects that the object's inventory has changed, and that there is a sloodle_config notecard present, then it will automatically re-process the notecard.


Contents

Usage

Drop this script into an object, and in your main script(s) add a customized sloodle_handle_command function which is called whenever a link message is received on the object dialog channel (see Sloodle channels). Whenever the object is reset or the notecard is changed, the configuration commands from that notecard will be disseminated to all other scripts in the same prim via link message.


Note: be sure that your script will receive and process configuration commands robustly when necessary, but will delay or ignore them when it needs to (i.e. do not normally change configuration while processing something else).


Future Work

There are certain issues with this script which need attention:

  • currently, it extracts commands and then re-packages them in exactly the same way for dissemination -- this is inefficient
  • it need not store the configuration details itself, but simply hand them on as they are
  • it should allow the processing and dissemination of any configuration setting, not just the standard ones
  • it should process all the way to the end of the notecard, rather than waiting for specific settings to be specified
  • the processing of the notecard should take place in a dedicated state, leaving the 'default' state to indicate that the script is idle


Data

This script stores the following data:

Constants

  • integer SLOODLE_OBJECT_DIALOG_CHANNEL = communication channel used for object dialog
  • integer SLOODLE_DO_DISPLAY_STATUS = no longer used - should be removed
  • integer SLOODLE_CONFIG_NOTECARD = the name of the notecard object, sloodle_config

Variables

  • string sloodleserverroot = the root address of the Moodle site
  • string pwd = the Prim Password of the Moodle site
  • integer sloodle_courseid = the ID of the Moodle course to connect to
  • string sloodle_course_title = no longer used - should be removed
  • key sloodle_notecard_key = the UUID of the latest dataserver request for a line from the notecard
  • integer sloodle_notecard_line = number of the latest line retrieved from the configuration notecard


Functions

This script defines the following functions:

  • sloodle_tell_other_scripts(string msg) = passes string msg to other scripts in the same prim
  • sloodle_debug(string msg) = standard Sloodle function - can be used to output debug information
  • sloodle_handle_notecard_line(string str) = processes the given line from the configuration notecard
  • sloodle_handle_command(string str) == standard Sloodle function - handles and executes the given configuration command (whether from notecard or elsewhere)
  • next_step() = passes all data to other scripts (note: deprecated - script should be changed not to use this function anymore)


States

Currently, all execution takes place in the default state.

default

This state cannot transition to any other state, although it can be reset. Events are handled as follows:

  • on_rez = resets the script
  • state_entry = starts reading the configuration notecard if it exists
  • dataserver = processes a line and gets the next
  • link_message = handles a command received from another script
  • changed = resets the script if the configuration notecard exists



This page is part of the Sloodle documentation
SloodleDocs Home | User Documentation | Administrator Documentation | Developer Documentation | Sloodle Wiki Home