Change font size
It is currently Sat Dec 15, 2018 1:17 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 5 posts ]
Author Message
 Post subject: Improved book script
PostPosted: Sun May 02, 2010 9:56 am 
User avatar

Joined: Sun May 02, 2010 9:34 am
Posts: 1
Hello!

Here's an improved version of the script used by OSGazet. After 5 seconds it will start loading the next page, for smoother reading. This helps even if the texture is in the cache already, as that ensures it's decoded.

I'm told the original is by Hiro (Protagonist?) and was posted here, but I couldn't find it.

{L_CODE}:
// 02/05/2010
//   Added preloading of the next page -- Dale Glass
//   


vector opensize=<0.062,1.242,0.82>;
vector closedsize=<0.031,0.414,0.547>;
string book="closed";
integer pagesets=9;
// here enter the number of pages
list pageUUIDs=["e2b9287c-7a25-4b62-9d60-2a5e81426152","810c68b6-93ab-4d9f-b697-c7f15bc2d096","7b8f1587-7267-4c2f-83ff-f14ebe2dc6dc","51cd7b66-0c8c-4633-aa7b-0386cbe4061a","89d1af64-4712-4129-97b3-1f31c58f004a","d76d3b3a-fe85-414b-869d-92087a61abd6","55fbdc64-6914-4233-880d-6abf97ccdd68","0f88b731-179f-4063-96af-be4e58fd5b0e","e9ea43a2-fe91-429e-8f94-4cb95fb2174c"];
// here enter all UUIDs of the pictures that make the double pages
integer pageset=0;
integer next_pageset=1;
float   timer_delay = 5.0;


settexture()
{
   string ID=llList2String(pageUUIDs,pageset);
   key textureID=(key) ID;
   llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",0);
   // texture of upper face
   llSetTexture("810c68b6-93ab-4d9f-b697-c7f15bc2d096",1);
   // texture of right side face on open
   llSetTexture("e2b9287c-7a25-4b62-9d60-2a5e81426152",3);
   // texture of first side face on open
   llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",4);
   // texture below face on open
   llSetTexture("63f5294b-6a33-4219-97cc-d3965b7106fb",2);
   // texture backside on open
   llSetPrimitiveParams([PRIM_TEXTURE, 5, textureID, <0.5,1,0>, <0.25,0,0>, 0.0]);
   llSetPrimitiveParams([PRIM_TEXTURE, 6, textureID, <0.5,1,0>, <-0.25,0,0>, 0.0]);
   //    llSetTexture(textureID,5);
   // texture all inner right pages
   //    llSetTexture(textureID,6);
   // texture all inner left pages
   llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",7);

   // texture below face on open
}

closebook()
{
   llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, <0,1,0>, 0.0, <0,0,0>, <1,1,1>, <0,0,0>]);
   llSetPrimitiveParams([PRIM_SIZE, closedsize]);
   llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",0);
   // texture above face
   llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",1);
   // texture right side face
   llSetTexture("63f5294b-6a33-4219-97cc-d3965b7106fb",2);
   // texture back face
   llSetTexture("63f5294b-6a33-4219-97cc-d3965b7106fb",3);
   // texture left side face
   llSetTexture("8df88c99-8b1e-4807-8324-5efd9588cad1",4);
   // texture cover face
   llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",5);
   // texture below face
}

default
{   
   state_entry()
   {
      closebook();
      book="closed";
      pageset=0;
      next_pageset=1;
      llSetTimerEvent(timer_delay);
   }
   
   touch_start(integer num_times)
   {
      if(book=="closed")
      {
         book="open";
         llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, <0,0.725,0>, 0.0, <0,0,0>, <1,1,1>, <0,0,0>]);
         llSetPrimitiveParams([PRIM_SIZE, opensize]);
         settexture();
      } else if(book=="open")
      {
         pageset=pageset + 1;
         if(pageset>(pagesets-1))
         {
            closebook();
            book="closed";
            pageset=0;
            next_pageset=1;
         } else {
            settexture();
            next_pageset = pageset+1;
         }

         if ( next_pageset < llGetListLength(pageUUIDs) ) {
            // preload next page after a delay
            llSetTimerEvent(timer_delay);
         } else {
            // nothing to preload, stop event if any
            llSetTimerEvent(0.0);
         }
      }
   }

   timer() {
      key textureID=llList2Key(pageUUIDs,next_pageset);
      llSetColor(<0,0,0>, 3);
      llSetTexture(textureID,3);
      

      //llOwnerSay("Preloading page " + (string)next_pageset + ": " + (string)textureID);
      llSetTimerEvent(0.0); // do this only once
   }
}



Top
 Profile  
 
 Post subject: Re: Improved book script
PostPosted: Thu Oct 07, 2010 6:52 am 
Furious Typer

Joined: Tue Aug 18, 2009 2:42 am
Posts: 233
Hi, we have done a further improvement on the book-script by Hiro, this time its pageback. yes, you can turn a page previous now too :)
Its used in the current issue of OSGazet (#6) and all thanks go to Revolution Smythe for his help!

{L_CODE}:
// 29/09/2010
// based on Hiro Protagonist's Bookscript
// includes preloading of the next page by Dale Glass
// and pageback by Revolution Smythe


// Global Variables
vector opensize=<0.062,1.242,0.82>;
vector closedsize=<0.031,0.414,0.547>;
string book="closed";
integer pagesets=9;
// here enter the number of pages
list pageUUIDs=["1234","2345","3456","4567","5678","6789,"7890","8901","9012"];
// here enter all UUIDs of the pictures that make the double pages
integer pageset=0;
integer next_pageset=1;
float   timer_delay = 5.0;

// SCRIPT STARTS HERE !

settexture()
{
    string ID=llList2String(pageUUIDs,pageset);
    key textureID=(key) ID;
    llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",0);
    // texture of upper face
    llSetTexture("810c68b6-93ab-4d9f-b697-c7f15bc2d096",1);
    // texture of right side face on open
    llSetTexture("e2b9287c-7a25-4b62-9d60-2a5e81426152",3);
    // texture of first side face on open
    llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",4);
    // texture below face on open
    llSetTexture("63f5294b-6a33-4219-97cc-d3965b7106fb",2);
    // texture backside on open
    llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",7);
    // texture below face on open
    llSetPrimitiveParams([PRIM_TEXTURE, 5, textureID, <0.5,1,0>, <0.25,0,0>, 0.0]);
    llSetPrimitiveParams([PRIM_TEXTURE, 6, textureID, <0.5,1,0>, <-0.25,0,0>, 0.0]);
// set texture for inner pages - book pages
}

closebook()
{
    llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, <0,1,0>, 0.0, <0,0,0>, <1,1,1>, <0,0,0>]);
    llSetPrimitiveParams([PRIM_SIZE, closedsize]);
    llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",0);
    // texture above face
    llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",1);
    // texture right side face
    llSetTexture("63f5294b-6a33-4219-97cc-d3965b7106fb",2);
    // texture back face
    llSetTexture("63f5294b-6a33-4219-97cc-d3965b7106fb",3);
    // texture left side face
    llSetTexture("63f5294b-6a33-4219-97cc-d3965b7106fb",4);
    // texture cover face
    llSetTexture("041d02c0-b2fa-4ddf-bafb-c438adf72fc4",5);
    // texture below face
}

default
{   
    state_entry()
    {
        closebook();
        book="closed";
        pageset=0;
        next_pageset=1;
        llSetTimerEvent(timer_delay);
    }
   
    touch_start(integer num_times)
    {
        if(book=="closed")
        {
            book="open";
            llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, <0,0.725,0>, 0.0, <0,0,0>, <1,1,1>, <0,0,0>]);
            llSetPrimitiveParams([PRIM_SIZE, opensize]);
            settexture();
        } else if(book=="open")
        {
            if(llDetectedTouchFace(0) == 5)
            {
             pageset=pageset + 1;
             if(pageset>(pagesets-1))
             {
                closebook();
                book="closed";
                pageset=0;
                next_pageset=1;
             }
             else
             {
                settexture();
                next_pageset = pageset+1;
             }
             if ( next_pageset < llGetListLength(pageUUIDs) )
             {
                // preload next page after a delay
                llSetTimerEvent(timer_delay);
             }
             else
             {
                // nothing to preload, stop event if any
                llSetTimerEvent(0.0);
             }
         }
         else if(llDetectedTouchFace(0) == 6)
         {
            pageset=pageset - 1;
            if(pageset< 0)
            {
                closebook();
                book="closed";
                pageset=0;
                next_pageset=1;
            }
            else
            {
                settexture();
                next_pageset = pageset-1;
            }
            if ( next_pageset < llGetListLength(pageUUIDs) )
            {
                // preload next page after a delay
                llSetTimerEvent(timer_delay);
            }
            else
            {
                // nothing to preload, stop event if any
                llSetTimerEvent(0.0);
            }
         }
       }
    }

    timer()
    {
        key textureID=llList2Key(pageUUIDs,next_pageset);
        llSetColor(<0,0,0>, 3);
        llSetTexture(textureID,3);
        llSetTimerEvent(0.0); // do this only once
    }
       
    changed( integer what )
    {
        if (what & 256) llResetScript();
    }
}


Top
 Profile  
 
 Post subject: Re: Improved book script
PostPosted: Mon Nov 21, 2011 1:51 pm 

Joined: Mon Nov 21, 2011 1:45 pm
Posts: 2
Hello! Can anyone help me please with this script? What have I to do to make a book with it? I placed it with the textures in a prim, I linked some prims with textures and script, but it won't work this way...
Thanks!


Top
 Profile  
 
 Post subject: Re: Improved book script
PostPosted: Mon Nov 21, 2011 8:57 pm 
Furious Typer
User avatar

Joined: Sat Jul 16, 2011 3:35 pm
Posts: 164
Flora Firehawk {L_WROTE}:
Hello! Can anyone help me please with this script? What have I to do to make a book with it? I placed it with the textures in a prim, I linked some prims with textures and script, but it won't work this way...
Thanks!


Last edited by Wolf Paws on Tue Feb 28, 2012 9:04 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Improved book script
PostPosted: Wed Nov 23, 2011 3:47 am 

Joined: Mon Nov 21, 2011 1:45 pm
Posts: 2
Hello Wolf,

thank you!

I replaced the UUids now and it works - partly. The result is a bit funny, because the script is only working with one prim and doesn't show the sides properly. So it seems that I didn't start the right way to "build" the book. Can anyone tell me please the steps?

Maybe I'll find out by "trial and error" but this will take me weeks...


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


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron


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