Difference between revisions of "User:Lum Pfohl/LSL Goodies/LumVision Presentation Script v0.1"

From Second Life Wiki
Jump to navigation Jump to search
(New page: {| width="100%" |- |valign="top"| <div id="box"> ==LumVision Presentation Script v0.1== <div style="padding: 0.5em"> This is my script for an in-world slide show. Rez a cube and fill it w...)
 
m (typo correction)
 
(One intermediate revision by the same user not shown)
Line 8: Line 8:


Touch the cube to start.  A drop down menu will provide options to go back, go forward in the sequence of textures, or reset the script.
Touch the cube to start.  A drop down menu will provide options to go back, go forward in the sequence of textures, or reset the script.
<pre>
<font color="green">//
//
// LumVision-Presentation Script v 0.1
// LumVision-Presentation Script v 0.1
//
//
// Written by Lum Pfohl December 11, 2007
// Written by Lum Pfohl December 11, 2007
//
//
 
 
// set to TRUE if you want debug messages written to chat screen</font>
// set to TRUE if you want debug messages written to chat screen
integer __debug=FALSE;
integer __debug=FALSE;
string __version_id = "LumVision-Presentation Script v 0.1";
string __version_id = "LumVision-Presentation Script v 0.1";
 
<font color="green">// global variables</font>
// global variables
integer interval;
integer interval;
integer currentTexture = 0;
integer currentTexture = 0;
integer totalTextures = 0;
integer totalTextures = 0;
list textureList = [];
list textureList = [];
integer messageChannel = 999888;
<font color="green">// these variables are used to make the drop down menues work.</font>
list dynMenu = ["Back", "Version", "Forward", "Reset"];
integer messageChannel = 999888;
 
list dynMenu = ["Back", "Version", "Forward", "Reset"];
// this is a list of all the possible inventory types, as constants.
list list_types = [INVENTORY_NONE, INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_LANDMARK,
<font color="green">// this is a list of all the possible inventory types, as constants.</font>
                  INVENTORY_CLOTHING, INVENTORY_OBJECT, INVENTORY_NOTECARD, INVENTORY_SCRIPT,
list list_types = [INVENTORY_NONE, INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_LANDMARK,
                  INVENTORY_BODYPART, INVENTORY_ANIMATION, INVENTORY_GESTURE];
                    INVENTORY_CLOTHING, INVENTORY_OBJECT, INVENTORY_NOTECARD, INVENTORY_SCRIPT,
 
                    INVENTORY_BODYPART, INVENTORY_ANIMATION, INVENTORY_GESTURE];
// this list is of the string names corresponding to the one above.
list list_names = ["None", "Texture", "Sound", "Landmark", "Clothing", "Object", "Notecard",
<font color="green">// this list is of the string names corresponding to the one above.</font>
                  "Script", "Body Part", "Animation", "Gesture"];
list list_names = ["None", "Texture", "Sound", "Landmark", "Clothing", "Object", "Notecard",
 
                    "Script", "Body Part", "Animation", "Gesture"];
default {
  state_entry() {
default {
     
  state_entry() {
    // read in the textures in the prim and store it
     
    integer typeCount = llGetInventoryNumber(INVENTORY_TEXTURE);
    <font color="green">// Read in the texture names in the prim and store it
 
    // This list will be in alphanumeric order, as found in the prim</font>
    integer j;
    integer typeCount = llGetInventoryNumber(INVENTORY_TEXTURE);
 
    for ( j = 0; j < typeCount; j++) {
    integer j;
      string invName = llGetInventoryName(INVENTORY_TEXTURE,j);
      if (__debug) {
    for ( j = 0; j < typeCount; j++) {
        llWhisper(0,"Inventory " + invName );
      string invName = llGetInventoryName(INVENTORY_TEXTURE,j);
      }
      if (__debug) {
      textureList += invName;
        llOwnerSay("Inventory " + invName );
      totalTextures++;
      }
    }
      textureList += invName;
 
      totalTextures++;
    if (__debug) {
    }
      llWhisper(0,"Found " + (string)totalTextures + " textures");
    }
    if (__debug) {
 
      llOwnerSay("Found " + (string)totalTextures + " textures");
    llSetTexture( llList2String(textureList, 0), 0 );
    }
 
 
 
    <font color="green">// If there are textures found, set the very first texture in the list
    // initialize the channel on which the vendor will talk to the owner via dialog
    // onto face 0 of the prim.</font>
    messageChannel = (integer)llFrand(2000000000.0);
    if (totalTextures > 0) {
    llListen(messageChannel, "", NULL_KEY, "");
      llSetTexture( llList2String(textureList, 0), 0 );
    // llOwnerSay((string)messageChannel);
      currentTexture = 0;
    currentTexture = 0;
  }
    }
 
  on_rez( integer start_param ) {
    llResetScript();
  }
    <font color="green">// initialize the channel on which the Presentation Script will talk to the owner via dialog</font>
 
    messageChannel = (integer)llFrand(2000000000.0);
 
    llListen(messageChannel, "", NULL_KEY, "");
  touch_start(integer total_number) {
   
 
    if (__debug) {
    if (llDetectedKey(0) == llGetOwner()) {
      llOwnerSay("Listenting on " + (string)messageChannel);
      llDialog(llDetectedKey(0), "What do you want to do?", dynMenu, messageChannel);
    }
    }
 
  }
  }
 
  // listen for for dialog box messages and respond to them as appropriate
  <font color="green">// Reset the script when the object is rezzed - so that the Presentation is ready-to-go
 
  //</font>
  listen(integer channel, string name, key id, string message) {
  on_rez( integer start_param ) {
   
    if( id != llGetOwner() ) {
    llResetScript();
      return;
  }
    }
   
    if ( message == "Version" ) {
  <font color="green">//Activate the menus, when the Presentation object is clicked (Touched)
        llWhisper(0, __version_id);
  //</font>
        return;
  touch_start(integer total_number) {
    }
   
    if (llDetectedKey(0) == llGetOwner()) {
    if ( message == "Reset" ) {
      llDialog(llDetectedKey(0), "What do you want to do?", dynMenu, messageChannel);
        llResetScript();
    }
    }
   
  }
    if ( message == "Back" && currentTexture > 0 ) {
        currentTexture--;
    } else if ( message == "Forward" && (currentTexture >= 0) && (currentTexture < totalTextures)) {
  <font color="green">// listen for for dialog box messages and respond to them as appropriate
        currentTexture++;
  //</font>
       
  listen(integer channel, string name, key id, string message) {
    } else {
   
        llDialog(llGetOwner(), "What do you want to do?", dynMenu, messageChannel);
   
        return;
    <font color="green">// If someone other than the owner attempts to click, do nothing and return
    }
    //</font>
   
    if( id != llGetOwner() ) {
    // If there are textures to apply, do so now.  Otherwise - quietly
      return;
    // do nothing.
    }
    if ( totalTextures > 0 ) {
 
      // Ensure that we do not go out of bounds with the index
    <font color="green">// Evaluate the button presses
      if (currentTexture >= totalTextures) {
    //</font>
        currentTexture = 0;
    if ( message == "Version" ) {
      }
      llWhisper(0, __version_id);
 
      return;
      // Set the new prim texture
    }
      llSetTexture( llList2String(textureList, currentTexture), 0 );
   
        
    if ( message == "Reset" ) {
      llDialog(llGetOwner(), "What do you want to do?", dynMenu, messageChannel);
      llResetScript();
    }
      return;
  }
    }
}
</pre>
    if ( message == "Back" && currentTexture > 0 ) {
      currentTexture--;
    } else if ( message == "Forward" && (currentTexture >= 0) && (currentTexture < totalTextures)) {
      currentTexture++;
       
    } else {
      llDialog(llGetOwner(), "What do you want to do?", dynMenu, messageChannel);
      return;
    }
   
    // If there are textures to apply, do so now.  Otherwise - quietly
    // do nothing.
    if ( totalTextures > 0 ) {
      // Ensure that we do not go out of bounds with the index
      if (currentTexture >= totalTextures) {
        currentTexture = 0;
      }
      // Set the new prim texture
      llSetTexture( llList2String(textureList, currentTexture), 0 );
      <font color="green">// Pressing a menu button dismisses the blue card menu.
      //We need to show a new one, and wait for the user</font>        
      llDialog(llGetOwner(), "What do you want to do?", dynMenu, messageChannel);
    }
  }
}
</div>
</div>
</div>
</div>

Latest revision as of 15:09, 2 February 2008

LumVision Presentation Script v0.1

This is my script for an in-world slide show. Rez a cube and fill it with textures followed by this script. If the textures are named to be sequential, this presentations script will display each texture in that order.

Touch the cube to start. A drop down menu will provide options to go back, go forward in the sequence of textures, or reset the script.

//
// LumVision-Presentation Script v 0.1
//
// Written by Lum Pfohl December 11, 2007
//


// set to TRUE if you want debug messages written to chat screen
integer __debug=FALSE;
string __version_id = "LumVision-Presentation Script v 0.1";

// global variables
integer interval;
integer currentTexture = 0;
integer totalTextures = 0;
list textureList = [];

// these variables are used to make the drop down menues work.
integer messageChannel = 999888;
list dynMenu = ["Back", "Version", "Forward", "Reset"];

// this is a list of all the possible inventory types, as constants.
list list_types = [INVENTORY_NONE, INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_LANDMARK,
                   INVENTORY_CLOTHING, INVENTORY_OBJECT, INVENTORY_NOTECARD, INVENTORY_SCRIPT,
                   INVENTORY_BODYPART, INVENTORY_ANIMATION, INVENTORY_GESTURE];

// this list is of the string names corresponding to the one above.
list list_names = ["None", "Texture", "Sound", "Landmark", "Clothing", "Object", "Notecard",
                   "Script", "Body Part", "Animation", "Gesture"];

default {
  state_entry() {
      
    // Read in the texture names in the prim and store it
    // This list will be in alphanumeric order, as found in the prim
    integer typeCount = llGetInventoryNumber(INVENTORY_TEXTURE);

    integer j;

    for ( j = 0; j < typeCount; j++) {
      string invName = llGetInventoryName(INVENTORY_TEXTURE,j);
      if (__debug) {
        llOwnerSay("Inventory " + invName );
      }
      textureList += invName;
      totalTextures++;
    }

    if (__debug) {
      llOwnerSay("Found " + (string)totalTextures + " textures");
    }


    // If there are textures found, set the very first texture in the list
    // onto face 0 of the prim.
    if (totalTextures > 0) {
      llSetTexture( llList2String(textureList, 0), 0 );
      currentTexture = 0;

    }



    // initialize the channel on which the Presentation Script will talk to the owner via dialog
    messageChannel = (integer)llFrand(2000000000.0);
    llListen(messageChannel, "", NULL_KEY, "");
    
    if (__debug) {
      llOwnerSay("Listenting on " + (string)messageChannel);
    }

  }


  // Reset the script when the object is rezzed - so that the Presentation is ready-to-go
  //
  on_rez( integer start_param ) {

    llResetScript();
  }


  //Activate the menus, when the Presentation object is clicked (Touched)
  //
  touch_start(integer total_number) {

    if (llDetectedKey(0) == llGetOwner()) {
      llDialog(llDetectedKey(0), "What do you want to do?", dynMenu, messageChannel);
    }

  }


  // listen for for dialog box messages and respond to them as appropriate
  // 
  listen(integer channel, string name, key id, string message) {
    
    
    // If someone other than the owner attempts to click, do nothing and return
    //
    if( id != llGetOwner() ) {
      return;
    }


    // Evaluate the button presses
    //
    if ( message == "Version" ) {
      llWhisper(0, __version_id);
      return;
    }
    
    if ( message == "Reset" ) {
      llResetScript();
      return;
    }

    if ( message == "Back" && currentTexture > 0 ) {
      currentTexture--;

    } else if ( message == "Forward" && (currentTexture >= 0) && (currentTexture < totalTextures)) {

      currentTexture++;
        
    } else {

      llDialog(llGetOwner(), "What do you want to do?", dynMenu, messageChannel);
      return;

    }

    
    // If there are textures to apply, do so now.  Otherwise - quietly
    // do nothing.
    if ( totalTextures > 0 ) {

      // Ensure that we do not go out of bounds with the index
      if (currentTexture >= totalTextures) {
        currentTexture = 0;
      }

      // Set the new prim texture
      llSetTexture( llList2String(textureList, currentTexture), 0 );


      // Pressing a menu button dismisses the blue card menu.
      //We need to show a new one, and wait for the user       
      llDialog(llGetOwner(), "What do you want to do?", dynMenu, messageChannel);
    }
  }
}

Lum Pfohl 20:18, 13 December 2007 (PST)

Lum's Quick Links
LumSelfPortrait.jpg
Click to Enlarge


Related topics

edit