Change font size
It is currently Sun Jul 22, 2018 3:23 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 4 posts ]
Author Message
 Post subject: Easy 1-Prim Book & 3-Prim Book
PostPosted: Tue Feb 07, 2012 4:38 pm 
OSG Elite
User avatar

Joined: Wed Mar 11, 2009 3:57 pm
Posts: 444
Hi again folks.

1-Prim Book Page REVISED Mar.23.2012,
( see next posting for 3-Prim Book )


Please Note:
The scripts in this posting work in OpenSim Master Dev and I have not tested them in SL but they should work without issue or incident. They are written & commented in such a fashion as to help assist people to learn from & extend for their own use. As a result of being written in this fashion, some optimizations and tweaks that are possible have been left out for the purposes of readability & understanding.


Someone a few days ago asked me to adjust a book script.... after looking at that and several others avalable out there, I decided to make another one. This one works fairly straight forward and no modifying of the script is required for use. Edit a notecard and away you go.

Quick Description:
- responds to touch, opens / closes book
-- if open, touch the page face to change pages forward/backward
- pre-caches the next 2 or previous 2 pages to reduce rez time of texture.
- can be set to Owner Only use in script (only thing to edit there if needed)


All the details are in the script header & the notecard header.

1-prim-book.lsl
{L_CODE}:
// ----------------------------------------------------------------
// Script Title:    1-Prim Book
// Created by:      WhiteStar Magic
// Creation Date:   Feb.06.2012
// Platforms:
//    SecondLife:    Not Tested
//    OpenSim:       Yes
//
// Revision:        V.0.3
// Revision History:
//
// Origination:
// Initially Based loosely off the Improved book script Script @ http://forums.osgrid.org/viewtopic.php?f=5&t=2400
//
// Revision Contributors:
// WhiteStar V.0.3 March.23.2012
// - small mod, adding BLANK_TEXTURE @ end of pages list IF the list is an odd number
//   corrects for the last page not being shown properly if odd pages in list
// WhiteStar V.0.2
// - Streamlined page handling
// - Divided pages up so each inside face holds a full texture
// - Modified texture pre-caching to use "spine & bottom" edges to preload up coming textures
// - added facility to use front & back covers
// - add states for "run" and "GET_NOTECARDS"
// - Installed Notecard reader facility to eliminate script from having to be edited.
// -    Size=    allows use of REG, LG & XLG book sizes depending on material
// -    CoverFR= for front Cover entry into NoteCard
// -    CoverBK= for back Cover entry into NoteCard
// -    Page=    to specify the pages. 1 per line using name(if contained in prim) or UUID, in sequential order.  Page-1, Page-2 Page-3 etc
//
// ================================================================
// ** SCRIPT NOTES **
//
// drop script & notecard into a BOX prim and it will set up.
// edit the Book.CFG and add the texture UUID's or Texture Names if contained in prim.
// -- sit back & enjoy your new book.
//================================================================
// ** Licence **
// !Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
// http://creativecommons.org/licenses/by-nc-sa/3.0/
//================================================================
// adjust below to make book only respond to owner
integer OWNER_ONLY  = FALSE;  // default FALSE allows anyone to use book
//
// ====================================== \\
// Make changes below at your own peril ! \\
// ====================================== \\
//
// Global Variables
vector  sz_open;    // open & closed changed in notecard reader
vector  sz_closed;
vector  sz_reg_o    = <0.050,1.00,0.75>;    // reg sizes
vector  sz_reg_c    = <0.025,0.50,0.75>;
vector  sz_lg_o     = <0.050,1.50,1.00>;    // lg sizes
vector  sz_lg_c     = <0.025,0.75,1.00>;
vector  sz_xlg_o    = <0.050,3.00,2.00>;    // xlg sizes
vector  sz_xlg_c    = <0.025,1.50,2.00>;
//
list    pcut_close  = [PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.0,1.0,0.0>, 0.0, <0.0,0.0,0.0>, <1.0,1.0,1.0>, <0.0,0.0,0.0>];
list    pcut_open   = [PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.0,0.700,0.0>, 0.0, <0.0,0.0,0.0>, <1.0,1.0,1.0>, <0.0,0.0,0.0>];
//      FR=Front, BK=Back covers. from notecard. UUID or TextureName if contained
string  cover_FR;
string  cover_BK;
//
string  bookstate   = "closed";
string  bookconfig  = "Book.CFG";
key     NChandle    = NULL_KEY;
integer line        = 0;
//
list    Lst_pages;          // page= data from notecard (uuid or name)
integer page_qty;           // # of pages in Lst_pages
integer page_crnt   = 0;
integer page_next   = 1;
//
integer tLT         = 6;    // Left page Touchface
integer tRT         = 5;    // Right page Touchface
float   timer_delay = 5.0;
//
// ==================== \\
// SCRIPT STARTS HERE ! \\
//======================\\
set_pages() // set textures for both inner pages
{
    key Lt_pg = (key)llList2String(Lst_pages,page_crnt);     // ODD Pages on left
    key Rt_pg = (key)llList2String(Lst_pages,(page_crnt+1)); // EVEN pages on Right
    llSetPrimitiveParams([PRIM_TEXTURE, 5, Rt_pg, <1.0,1.0,0.0>, <0.0,0,0>, 0.0]); // Right Face: full image
    llSetPrimitiveParams([PRIM_TEXTURE, 6, Lt_pg, <1.0,1.0,0.0>, <0.0,0,0>, 0.0]); // Left Face: full image
}

pre_cache()
{
    llSetTimerEvent(0.0);       // do this only once
    if(bookstate=="closed") return;
    key oddcache=llList2Key(Lst_pages,page_next+1);
    key evencache=llList2Key(Lst_pages,page_next+2);
    //llSetColor(<0,0,0>, 3);   // colour over left face
    llSetTexture(oddcache,3);  // left face edge (spine) when open
    //llSetColor(<0,0,0>, 4);   // colour over bottom face
    llSetTexture(evencache,4); // bottom face edge when open
}

openbook()
{
    bookstate="open";
    llSetPrimitiveParams([PRIM_SIZE, sz_open]); // set new size
    llSetPrimitiveParams(pcut_open);               // set the cut params
    llSetPrimitiveParams([PRIM_TEXTURE, 2, cover_BK, <2.0,1.0,0.0>, <0.50,0,0>, 0.0]); // set back cover & scale for display on new prim form
}

closebook()
{
    bookstate="closed";
    page_crnt=0;
    page_next=1;
    //
    llSetPrimitiveParams([PRIM_SIZE, sz_closed]);
    llSetPrimitiveParams(pcut_close);   
    llSetPrimitiveParams([PRIM_TEXTURE, 4, cover_FR, <1.0,1.0,0.0>, <0.0,0,0>, 0.0]);  // Front Cover
    llSetPrimitiveParams([PRIM_TEXTURE, 2, cover_BK, <1.0,1.0,0.0>, <0.0,0,0>, 0.0]);  // Back Cover, rescaled for prim form
    //
    //llSetColor(<1.0,1.0,1.0>, 4);  // re-colour cover white IF bottom face edge was blackened in pre_cache()
    //
    llSetTexture(TEXTURE_BLANK,0); // top face edge
    llSetTexture(TEXTURE_BLANK,1); // rigt side edge
    llSetTexture(TEXTURE_BLANK,3); // left side edge (spine)
    llSetTexture(TEXTURE_BLANK,5); // bottom face adge
}

// START //
default
{
    state_entry()
    {
        state GET_NOTECARDS;
    }
}
// RUNNING //
state run
{
    state_entry()
    {
        closebook();
        llOwnerSay("[ "+ llGetListLength(Lst_pages)+" ] Pages loaded. Ready, click on cover to read");
        page_qty = llGetListLength(Lst_pages);
        float d = ((float)page_qty / 2);
        integer e = (page_qty / 2);
        if((float)d != (float)e) {Lst_pages += [TEXTURE_BLANK]; page_qty = llGetListLength(Lst_pages);} // ODD # so add BLANK TEXTURE to make EVEN #

    }

    touch_start(integer num_times)
    {
        if(OWNER_ONLY && llDetectedKey(0)!=llGetOwner()) return; // only owner is set, to ignore others
        //
        if(bookstate=="closed")
        {
            openbook();
            set_pages();
            pre_cache();
        }
        else if(bookstate=="open")
        {
            if(llDetectedTouchFace(0) == tRT) // RTface touched
            {
                page_crnt=page_crnt + 2;

                if(page_crnt>(page_qty-2))
                {
                    closebook();
                }
                else
                {
                    set_pages();
                    page_next = page_crnt+1;
                }

                if ( page_next < llGetListLength(Lst_pages) )
                {
                    llSetTimerEvent(timer_delay);
                }
                else llSetTimerEvent(0.0);
            }
            else if(llDetectedTouchFace(0) == tLT) // LTface touched
            {
                page_crnt=page_crnt - 2;
                if(page_crnt< 0)
                {
                    closebook();
                }
                else
                {
                    set_pages();
                    page_next = page_crnt-1;
                }
                if ( page_next < llGetListLength(Lst_pages) )
                {
                    llSetTimerEvent(timer_delay);
                }
                else llSetTimerEvent(0.0);
            }
        }
    }

    timer()
    {
        pre_cache();            // preload next page after a delay
    }

    changed(integer change)
    {
        if (change & CHANGED_INVENTORY)
        {
            llOwnerSay("The inventory changed. Restarting book");
            llResetScript();
        }
        if (change & 1024) llResetScript();
    }
}
//-------------------\\
// Get Notecard Data \\
//-------------------\\
state GET_NOTECARDS
{
    state_entry()
    {
        line = 0;
        NChandle = llGetNotecardLine(bookconfig, 0);
    }
    dataserver(key query_id, string data)
    {
        if(query_id == NChandle) // Filtering the call
        {

            if (data == EOF)
            {
                state run;
            }
            else
            {
                data = llStringTrim(data, STRING_TRIM_HEAD);
                if (llGetSubString (data, 0, 0) != "#") // If it's # skip the line, it's a comment
                {
                    integer s = llSubStringIndex(data, "=");
                    if(~s) // does it have an "=" in it? if YES it's Valid!
                    {
                        string token = llToLower(llStringTrim(llDeleteSubString(data, s, -1), STRING_TRIM)); // trim up token & lower case it
                        data = llStringTrim(llDeleteSubString(data, 0, s), STRING_TRIM);

                        if(token == "size")             // Set Sizing
                        {
                            if(llToLower(data)=="reg")
                            {
                                sz_closed  = sz_reg_c;
                                sz_open    = sz_reg_o;
                            }
                            else if(llToLower(data)=="lg")
                            {
                                sz_closed  = sz_lg_c;
                                sz_open    = sz_lg_o;
                            }
                            else if(llToLower(data)=="xlg")
                            {
                                sz_closed  = sz_xlg_c;
                                sz_open    = sz_xlg_o;
                            }
                        }

                        if (token == "coverfr")         // Set Front Cover
                        {
                            if(data=="") llOwnerSay("CoverFR= is not identified in "+bookconfig+" No Front Cover will be shown");
                            else cover_FR = data;
                        }
                        else if (token == "coverbk")    // Set Back Cover
                        {
                            if(data=="") llOwnerSay("CoverBK= is not identified in "+bookconfig+" No Back Cover will be shown");
                            else cover_BK = data;
                        }
                        else if (token == "page")
                        {
                            if(data !="")
                            {
                                //llOwnerSay("The Data is: "+(string)data);
                                Lst_pages += [data];

                            }
                            else llOwnerSay("Loading Page= from "+bookconfig+" NoteCard: Data is Empty ! No Pages Available");
                        }
                    }
                }
                NChandle = llGetNotecardLine(bookconfig,++line);
            }
        }
    }
}


Book.CFG notecard
{L_CODE}:
# 1-Prim Book V.0.2 Configuration File
# by WhiteStar Magic  Feb.06.2012
# the # symbol is a COMMENT.  These lines are ignored
#
# size=   reg, lg, xlg
#       reg    =  (0.50m W x 0.75m H) closed    -- (1.00m W x 0.75m H)
#       lg       =   (0.75m W x 1.00m H) closed  -- (1.50m W x 1.00m H)
#       xlg     =   (1.50m W x 2.00m H) closed  -- (3.00m W x 2.00m H)
#
#  CoverFR= Front Cover of book.   Texture UUID or ( Texture Name if contained in book prim. )
#  CoverBK= Back Cover of book.  Texture UUID or ( Texture Name if contained in book prim. )
#
#  Page= Texture UUID or ( Texture Name if contained in book prim. )
#        NOTE:  Pages must be in sequence, 1,2,3,4,5 etc....
#  SPECIAL NOTE !!!   
#   IF using UUID then DO NOT INCLUDE <>  Just the UUID Only
#   IF using Texture Name place the name in "quotes"  DO NOT INCLUDE <>
# ============================================
size=reg
CoverFR=<uuid or texture name>
CoverBK=<uuid or texture name>
#
##  insert your pages below, in sequence from 1,2,3,4 etc
#
Page=<uuid or texture name>
Page=<uuid or texture name>
Page=<uuid or texture name>
Page=<uuid or texture name>


Enjoy, Good Luck & Have FUN !

_________________
No further support of any kind, for any of my materials. Use as/is whereis.
PLEASE UNSTICKY Any Stickied Posting by myself.


Last edited by WhiteStar Magic on Fri Sep 28, 2012 12:52 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Easy 1-Prim Book & 3-Prim Book
PostPosted: Wed Feb 08, 2012 11:08 am 
OSG Elite
User avatar

Joined: Wed Mar 11, 2009 3:57 pm
Posts: 444
3-Prim Book page REVISED Mar.23.2012

Description:
This is a more conventional type of prim book which uses 3 prims. The Spine is used as the root prim and the two pages are a 50% Cut box prim with the "cut edges" attached to the root. The question as to why this is done has already been raised and the answer is simple. They are made this way to allow for easier Stretching / Shrinking and keeping the prims aligned correctly as well as allowing the Cover to swing open & closed freely (hinged fashion).

Usage:
Almost identical to the 1-Prim Book in the previous posting. All you have to do is edit the Book.CFG notecard, set permissions and voila. This does not offer re-sizing capabilities at this time.

3-Prim-Book.lsl
{L_CODE}:
// ----------------------------------------------------------------
// Script Title:    3-Prim Book
// Created by:      WhiteStar Magic
// Creation Date:   Feb.08.2012
// Platforms:
//    SecondLife:    Not Tested
//    OpenSim:       Yes
//
// Revision:        V.0.3 March.23.2012
// Revision History:
//
// Origination:
// Initially Based loosely off the Improved book script Script @ http://forums.osgrid.org/viewtopic.php?f=5&t=2400
// This script evolved from "1-Prim Book" written by me @ http://forums.osgrid.org/viewtopic.php?f=5&t=3914
//
// Revision Contributors:
// WhiteStar V.0.3 March.23.2012
// - small mod, adding BLANK_TEXTURE @ end of pages list IF the list is an odd number
//   corrects for the last page not being shown properly if odd pages in list
//
// WhiteStar V.0.2 Feb.08.2012
// - Streamlined page handling
// - Optimized pages so each inside face holds a full texture
// - Modified texture pre-caching to use the spine (root prim, cylinder) top & bottom" faces to preload up coming textures
// - added facility to use front & back cover textures
// - add states for "run" and "GET_NOTECARDS"
// - Installed Notecard reader facility to eliminate script from having to be edited.
// -    CoverFR= for front Cover entry into NoteCard
// -    CoverBK= for back Cover entry into NoteCard
// -    Page=    to specify the pages. 1 per line using name(if contained in prim) or UUID, in sequential order.  Page-1, Page-2 Page-3 etc
//
// ================================================================
// ** SCRIPT NOTES **
// The following must be in the root prim:  This script, Book.CFG notecard, Textures if desired (best for portability).
//
//** PRIM NOTES **
// ROOT prim (spine) = cyl.  Face=0 top, Face=2 bottom, face=1 = long (visible) face
// PAGE prims are rectangles with 50% cut.  The Cut Edge is linked to the root prim.
//      done this way to allow for easy stretching & shrinking.
// COVER prim is 0.010 shorter & narrower than Back prim.  Done so that it folds closed nicely without flickering
//      NOTE it's X position is offset by -0.05 to keep cover always visible when closed without flickering.
//
//================================================================
// ** Licence **
// !Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
// REFERENCE http://creativecommons.org/licenses/by-nc-sa/3.0/
//================================================================
//
// adjust below to make book only respond to owner
integer OWNER_ONLY  = FALSE;  // default FALSE allows anyone to use book
//
// ====================================== \\
// Make changes below at your own peril ! \\
// ====================================== \\
//
// Global Variables
//
integer root_id;            // holder for Root Prim ID number
integer cover_id;           // holder for Front Cover Prim ID number
integer back_id;            // holder for Back Cover Prim ID number
//      FR=Front, BK=Back covers. from notecard. UUID or TextureName if contained
string  cover_FR;
string  cover_BK;
//
string  bookstate   = "closed";
string  bookconfig  = "Book.CFG";
key     NChandle    = NULL_KEY;
integer line        = 0;
//
list    Lst_pages;          // page= data from notecard (uuid or name)
integer page_qty;           // # of pages in Lst_pages
integer page_crnt   = 0;
integer page_next   = 1;
//
integer tLT         = 3;    // Left page Touchface
integer tRT         = 0;    // Right page Touchface
float   timer_delay = 5.0;
//
// ==================== \\
// SCRIPT STARTS HERE ! \\
//======================\\
//
set_texture_parms()
{
    // here the front & back covers are set along with the scaling for this application
    llSetLinkPrimitiveParams(cover_id, [PRIM_TEXTURE, 1, cover_FR, <2.0,1.0,0>, <0.50,0.0,0>, 0.0]); // set front cover & scale
    llSetLinkPrimitiveParams(back_id, [PRIM_TEXTURE, 4, cover_BK, <2.0,1.0,0>, <0.50,0.0,0>, 0.0]);  // set back cover & scale
    //
    llSetLinkPrimitiveParams(cover_id,[PRIM_TEXTURE, 3, llList2Key(Lst_pages,0), <2.0,1.0,0.0>, <0.50,0.0,0>, 0.0]); // LT-page   
    llSetLinkPrimitiveParams(back_id,[PRIM_TEXTURE, 0, llList2Key(Lst_pages,1), <2.0,1.0,0.0>, <0.50,0.0,0>, 0.0]);  // RT-page   
    //
    // Face 1 of the spine (cylinder) is what everyone sees, not changing it.
    llSetColor(<0,0,0>, 0);   // colour over top face of spine (cylinder)
    llSetColor(<0,0,0>, 2);   // colour over bottom face of spine     
}

get_link_ids()
{
    integer i;
    integer len = llGetNumberOfPrims();
    for(i=1;i<=len;i++)
    {       
        string name = llGetLinkName(i);
        if(name==llGetObjectName()) root_id = i;    // should be 1 as root always = 1
        else if(name=="cover") cover_id = i;        // should be 2 or 3 depending on how linked
        else if(name=="back") back_id = i;          // should be 3 or 2  "" ""
        else llOwnerSay("root prim, front cover, back cover have not been identified"+
            "\nThe 'root prim' (spine) can have any name.  Suggest using Descriptive Name for the book"+
            "\nThe 'Cover prim' must be called 'cover'"+
            "\nThe 'Back prim' must be called 'back'");
    }
    if(cover_id=="") llOwnerSay("Cover-ID="+cover_id);
    if(back_id=="")  llOwnerSay("Back-ID="+back_id);
    if(root_id=="")  llOwnerSay("Root-ID="+root_id);
}

set_pages() // set textures for both inner pages
{
    key Lt_pg = (key)llList2String(Lst_pages,page_crnt);     // ODD Pages on left
    key Rt_pg = (key)llList2String(Lst_pages,(page_crnt+1)); // EVEN pages on Right
    llSetLinkTexture(cover_id, Lt_pg, 3); // LT-page   
    llSetLinkTexture(back_id, Rt_pg, 0);  // RT-page
}

pre_cache()
{
    llSetTimerEvent(0.0);       // do this only once
    if(bookstate=="closed") return;
    key oddcache=llList2Key(Lst_pages,page_next+1);
    key evencache=llList2Key(Lst_pages,page_next+2);
    llSetTexture(oddcache,0);  // face 0 = top face of spine cyliner
    llSetTexture(evencache,2); // face 2 = bottom face edge of spine
}

openbook()
{
    bookstate="open";
    // open cover only, Back & Spine stay put.
    // The Hinging Cover
    list prim_rot = llGetLinkPrimitiveParams(cover_id,[PRIM_ROT_LOCAL]);
    rotation rot = llList2Rot(prim_rot,0);
    rotation delta = llEuler2Rot(<0,0,-PI/2>);
    rot = delta * rot;
    llSetLinkPrimitiveParams(cover_id, [PRIM_ROT_LOCAL,rot]);
    llSleep(0.05);
    rot = delta * rot;
    llSetLinkPrimitiveParams(cover_id, [PRIM_ROT_LOCAL,rot]);
}

closebook()
{
    list prim_rot = llGetLinkPrimitiveParams(cover_id,[PRIM_ROT_LOCAL]);
    rotation rot = llList2Rot(prim_rot,0);
    rotation delta = llEuler2Rot(<0,0,PI/2>);
    rot = delta * rot;
    llSetLinkPrimitiveParams(cover_id, [PRIM_ROT_LOCAL,rot]);
    llSleep(0.05);
    rot = delta * rot;
    llSetLinkPrimitiveParams(cover_id, [PRIM_ROT_LOCAL,rot]);
    //
    bookstate="closed";
    page_crnt=0;
    page_next=1;
    //
    // set pages up for next use.  Includes setting page 1 & 2 and pre-caching 3 & 4
    llSetLinkTexture(cover_id, (key)llList2String(Lst_pages,1), 3); // LT-page   
    llSetLinkTexture(back_id, (key)llList2String(Lst_pages,2), 0);  // RT-page
    //
    llSetTexture((key)llList2String(Lst_pages,3),0); // setting pre-cache to pages 3 & 4
    llSetTexture((key)llList2String(Lst_pages,4),2);
    //
}

// START //
default
{
    on_rez(integer start_param)
    {
        llResetScript();
    }
    state_entry()
    {
        get_link_ids();
        state GET_NOTECARDS;
    }
}
// RUNNING //
state run
{
    state_entry()
    {
        set_texture_parms();
        llOwnerSay("[ "+llGetListLength(Lst_pages)+" ] Pages loaded. Ready, click on cover to read");
        page_qty = llGetListLength(Lst_pages);
        float d = ((float)page_qty / 2);
        integer e = (page_qty / 2);
        if((float)d != (float)e) {Lst_pages += [TEXTURE_BLANK]; page_qty = llGetListLength(Lst_pages);} // ODD # so add BLANK TEXTURE to make EVEN #
    }

    touch_start(integer num_times)
    {
        if(OWNER_ONLY && llDetectedKey(0)!=llGetOwner()) return; // only owner is set, to ignore others
        //
        integer touched_Prim = llDetectedLinkNumber(0);
        string  touched_Name = llGetLinkName(touched_Prim);
        if(bookstate=="closed")
        {
            openbook();
            set_pages();
            pre_cache();
        }
        else if(bookstate=="open")
        {
            if(llDetectedTouchFace(0)==tRT && touched_Name =="back") // RTface touched
            {
                page_crnt=page_crnt + 2;

                if(page_crnt>(page_qty-2))
                {
                    closebook();
                }
                else
                {
                    set_pages();
                    page_next = page_crnt+1;
                }

                if ( page_next < llGetListLength(Lst_pages) )
                {
                    llSetTimerEvent(timer_delay);
                }
                else llSetTimerEvent(0.0);
            }
            else if(llDetectedTouchFace(0) == tLT && touched_Name =="cover") // LTface touched
            {
                page_crnt=page_crnt - 2;
                if(page_crnt< 0)
                {
                    closebook();
                }
                else
                {
                    set_pages();
                    page_next = page_crnt-1;
                }
                if ( page_next < llGetListLength(Lst_pages) )
                {
                    llSetTimerEvent(timer_delay);
                }
                else llSetTimerEvent(0.0);
            }
        }
    }

    timer()
    {
        pre_cache();            // preload next page after a delay
    }

    changed(integer change)
    {
        if (change & CHANGED_INVENTORY)
        {
            llOwnerSay("The inventory changed. Restarting book");
            llResetScript();
        }
        if (change & 1024) llResetScript();
    }
}
//-------------------\\
// Get Notecard Data \\
//-------------------\\
state GET_NOTECARDS
{
    state_entry()
    {
        line = 0;
        NChandle = llGetNotecardLine(bookconfig, 0); //
    }
    dataserver(key query_id, string data)
    {
        if(query_id == NChandle) // Filtering the call
        {

            if (data == EOF)
            {
                state run;
            }
            else
            {
                data = llStringTrim(data, STRING_TRIM_HEAD);
                if (llGetSubString (data, 0, 0) != "#") // If it's # skip the line, it's a comment
                {
                    integer s = llSubStringIndex(data, "=");
                    if(~s) // does it have an "=" in it? if YES it's Valid!
                    {
                        string token = llToLower(llStringTrim(llDeleteSubString(data, s, -1), STRING_TRIM)); // trim up token & lower case it
                        data = llStringTrim(llDeleteSubString(data, 0, s), STRING_TRIM);


                        if (token == "coverfr")         // Set Front Cover
                        {
                            if(data=="") llOwnerSay("CoverFR= is not identified in "+bookconfig+" No Front Cover will be shown");
                            else cover_FR = data;
                        }
                        else if (token == "coverbk")    // Set Back Cover
                        {
                            if(data=="") llOwnerSay("CoverBK= is not identified in "+bookconfig+" No Back Cover will be shown");
                            else cover_BK = data;
                        }
                        else if (token == "page")
                        {
                            if(data !="")
                            {
                                //llOwnerSay("The Data is: "+(string)data);
                                Lst_pages += [data];

                            }
                            else llOwnerSay("Loading Page= from "+bookconfig+" NoteCard: Data is Empty ! No Pages Available");
                        }
                    }
                }
                NChandle = llGetNotecardLine(bookconfig,++line);
            }
        }
    }
}



Book.CFG notecard
{L_CODE}:
# 3-Prim Book V.0.1 Configuration File
# by WhiteStar Magic  Feb.08.2012
# the # symbol is a COMMENT.  These lines are ignored
#
#  CoverFR= Front Cover of book.   Texture UUID or ( Texture Name if contained in book prim. )
#  CoverBK= Back Cover of book.  Texture UUID or ( Texture Name if contained in book prim. )
#
#  Page= Texture UUID or ( Texture Name if contained in book prim. )
#        NOTE:  Pages must be in sequence, 1,2,3,4,5 etc....
#
# ============================================
CoverFR=FR_Cover
CoverBK=BK_Cover
#
##  insert your pages below, in sequence from 1,2,3,4 etc
#
Page=pg_1
Page=pg_2
Page=pg_3
Page=pg_4

_________________
No further support of any kind, for any of my materials. Use as/is whereis.
PLEASE UNSTICKY Any Stickied Posting by myself.


Last edited by WhiteStar Magic on Fri Mar 23, 2012 4:21 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Easy 1-Prim Book & 3-Prim Book
PostPosted: Wed Feb 08, 2012 5:49 pm 
OSG Elite

Joined: Wed Aug 05, 2009 1:59 am
Posts: 417
Thanks, whiteStar.

(Now I have to learn how to write :) )

Odd


Top
 Profile  
 
 Post subject: Re: Easy 1-Prim Book & 3-Prim Book
PostPosted: Fri Mar 23, 2012 4:51 pm 
OSG Elite
User avatar

Joined: Wed Mar 11, 2009 3:57 pm
Posts: 444
Scripts Updated Mar.23.2012

- small mod, adding BLANK_TEXTURE @ end of pages list IF the list is an odd number
corrects for the last page not being shown properly if odd pages in list


Enjoy!

_________________
No further support of any kind, for any of my materials. Use as/is whereis.
PLEASE UNSTICKY Any Stickied Posting by myself.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 4 posts ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net