Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Prim book scripts

Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
03-29-2005 10:22
(obsolete scripts deleted, please see end of thread for latest version of the book)
_____________________
Vincit omnia Chaos
From: Flugelhorn McHenry
Anyway, ignore me, just listen to the cow
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
05-30-2005 09:10
Hello Issarlk,

I love your prim book's approach. And I'd like to make some books by using this.
So I chanded number_of_pages and put my textures. It worked fine by myself.
But when I give it to someone, he/she reported that it showed some permission error and the backcover was turned over insted of pages.
I managed to fix it, but I couldn't.

Can you help me?

Edit: fixed the odd line break.
_____________________
:) Seagel Neville :)
Mhaijik Guillaume
Chadeaux Vamp
Join date: 18 Jun 2004
Posts: 620
same same
05-30-2005 10:22
I also used the scripts - made some nice books - but when I give them to someone else they are borked. :(

I can get the exact error message..... in a bit

Also I would like to make them no transfer - is this possible ?

Thank you.
_____________________
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
05-30-2005 12:15
This script might have problems being transferred because it doesn't ask for link permissions from its new owner. Im still in the process of understanding this script, but adding an on_rez() event to state open and closed, that switches to state default might help. Here is the script that has to be changed:

This goes into the cylindrical prim used as an axe for the pages:
CODE

//Prim book scripts, animate a 3d prim book
//Copyright (C) 2005 Issarlk
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


vector initialPos;
rotation initialRot;

//the variable where we store the back cover link number
integer backcover_link_number = 0;
//the back cover key
key backcover_key = NULL_KEY;


list page_keys = [];
list page_commands = [];
integer page_listener_id = 0;

//Put the number of page here, a page is a two sided sheet of paper (bad name)
integer number_of_pages = 2;

//Comments for each page, display next to pointer
list pagecomments = [
"comment 1. ",
"comment 2.",
"comment 3.",
"comment 4."
];

init()
{
initialPos = llGetPos();
initialRot = llGetRot();
backcover_link_number = 0;
backcover_key = NULL_KEY;
page_keys = [];
page_commands = [];
llListenRemove(page_listener_id);
page_listener_id = 0;

//we need perm to change link, so we delink the backcover before rotating to open book
//in hindsight, two backcover turning visible / invisible would be simpler
//
// known bug: if owner is not around, it doesnt delink and everything rotate...
//
if (!(llGetPermissions() & PERMISSION_CHANGE_LINKS)
|| llGetPermissionsKey() != llGetOwner())
{
llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS);
}
llMessageLinked(LINK_ALL_OTHERS, 0, "send backcover link number", NULL_KEY);
}


// utility functions to manage an array of pages and their info
setPage(integer number, key id)
{
resetPage(number);
page_keys = llListInsertList(page_keys, [number, id], llGetListLength(page_keys));
}

resetPage(integer number)
{
integer tmppagepos = llListFindList(page_keys, [number]);
if (tmppagepos != -1)
{
page_keys = llDeleteSubList(page_keys, tmppagepos, tmppagepos+1);
}
}

key getPage(integer number)
{
integer tmppagepos = llListFindList(page_keys, [number]);
return llList2Key(page_keys, tmppagepos+1);
}

integer getPageNumber(key id)
{
integer tmppagepos = llListFindList(page_keys, [id]);
if (tmppagepos == -1)
{
llWhisper(0, "error, number of page "+ (string)id + " not fouund");
}
return llList2Integer(page_keys, tmppagepos - 1);
}

integer hasPageCommands(integer number)
{
if (llListFindList(page_commands, [number]) == -1)
{
return FALSE;
}
else
{
return TRUE;
}
}

setPageCommands(integer number, string commands)
{
resetPageCommands(number);
page_commands = llListInsertList(page_commands, [number, commands], llGetListLength(page_commands));
}

string getPageCommands(integer number)
{
integer tmppagepos = llListFindList(page_commands, [number]);
return llList2String(page_commands, tmppagepos+1);
}

resetPageCommands(integer number)
{
integer tmppagepos = llListFindList(page_commands, [number]);
if (tmppagepos != -1)
{
page_commands = llDeleteSubList(page_commands, tmppagepos, tmppagepos+1);
}
}

//in case two book are near, check if an id we hear talking is one of our page
integer isOurPage(key id)
{
if (llListFindList(page_keys, [id]) == -1)
{
//not one of our pages
return FALSE;
}
else
{
//one of our pages
return TRUE;
}
}


//open book
open()
{
if (backcover_key != NULL_KEY && backcover_link_number != 0)
{
//leave back cover on the ground
llBreakLink(backcover_link_number);
backcover_link_number = 0;
}
//rotate
llSetRot(llEuler2Rot(<0, 0, PI_BY_TWO>)*initialRot);
llSetRot(llEuler2Rot(<0, 0, PI>)*initialRot);
if (backcover_key != NULL_KEY)
{
//relink backcover
llCreateLink(backcover_key, TRUE);
//ask the back cover to send us its link number
llMessageLinked(LINK_ALL_OTHERS, 0, "send backcover link number", NULL_KEY);
}
llSetTimerEvent(0.2);
}


//same, but closes
close()
{
//kill all pages
llSetTimerEvent(0.5);
//close book
if (backcover_key != NULL_KEY && backcover_link_number != 0)
{
llBreakLink(backcover_link_number);
backcover_link_number = 0;
}
llSetRot(llEuler2Rot(<0, 0, PI_BY_TWO>)*initialRot);
llSetRot(initialRot);
llSetPos(initialPos);
if (backcover_key != NULL_KEY)
{
llCreateLink(backcover_key, TRUE);
//ask the back cover to send us its link number
llMessageLinked(LINK_ALL_OTHERS, 0, "send backcover link number", NULL_KEY);
}
}

//rez a page
//number is number of page
//open tells if page is on the left (when you browse the book backward) or the righ (normal reading)
//commands is various commands to send to the page, not used
rez_page(integer number, integer open, string commands)
{
rotation tmprot;
if (open)
{
tmprot = llGetRot();
//had a command so the page know its already on the left
setPageCommands(number, "alreadyopen");
}
else
{
tmprot = initialRot;
resetPageCommands(number);
}
//0.205 depends on the size of the book... to change for different sizes (PITA)
llRezObject("Page", initialPos + <0.205, 0, 0>, ZERO_VECTOR, tmprot, number);
}

//kill a page that is no longer visible.
kill_page(integer number)
{
//tell it to die
llWhisper(101,(string)getPage(number)+",die");
//remove from lists
resetPage(number);
resetPageCommands(number);
}

//cleanup when book closes
kill_all_pages()
{
integer i;
for (i=llGetListLength(page_keys) - 2 ; i >= 0 ; i-=2)
{
kill_page(llList2Integer(page_keys, i));
}
}

//send commands to a page, to tell it which texture to use and so on
send_page_commands(integer number)
{
//send page commands
if (hasPageCommands(number))
{
string commands = getPageCommands(number);
send_page_command(number, commands);
}
//set texture
key idtexture = llGetInventoryKey("page"+(string)number);
if (idtexture != NULL_KEY)
{
send_page_command(number, "texturefront,"+(string)idtexture);
}
//textures must be copy mod transfer, or else it doesnt work
idtexture = llGetInventoryKey("page"+(string)number+"b");
if (idtexture != NULL_KEY)
{
send_page_command(number, "textureback,"+(string)idtexture);
}
integer nbofcom = llGetListLength(pagecomments);
//send page descriptions
if ((number - 1)*2 < nbofcom)
{
send_page_command(number, "descfront,"+llList2String(pagecomments, (number - 1)*2));
}
if ((number - 1)*2+1 < nbofcom)
{
send_page_command(number, "descback,"+llList2String(pagecomments, (number - 1)*2+1));
}
}

send_page_command(integer number, string command)
{
key id = getPage(number);
llWhisper(101, (string)id+","+command);
}


default
{
state_entry()
{
init();
}

on_rez(integer start_param)
{
init();
}

run_time_permissions(integer perm)
{
//ask for perm
if ((perm & PERMISSION_CHANGE_LINKS) != 0)
{
state closed;
}
}

link_message(integer sender_number, integer number, string message, key id)
{
if (message == "backcover ready")
{
//store backcover link id
backcover_link_number = number;
backcover_key = llGetLinkKey(backcover_link_number);
}
}
}


state closed
{
on_rez(integer param) {
// If we dont have permissions from the owner
if (llGetPermissionsKey() != llGetOwner()
// Or if we dont have permission to link
|| !(llGetPermissions() & PERMISSION_CHANGE_LINKS)) {
// Try getting permissions again.
state default;
}
}

touch_start(integer total_number)
{
open();
state opened;
}

moving_end()
{
initialPos = llGetPos();
initialRot = llGetRot();
}


link_message(integer sender_number, integer number, string message, key id)
{
if (message == "user clicked cover")
{
//the cover tells us user clicked: open book
open();
state opened;
}
else if (message == "backcover ready")
{
//store backcover link id
backcover_link_number = number;
backcover_key = llGetLinkKey(backcover_link_number);
}
}

timer()
{
//dead code?
llSetTimerEvent(0.0);
kill_all_pages();
}
}


state opened
{
on_rez(integer param) {
// If we dont have permissions from the owner
if (llGetPermissionsKey() != llGetOwner()
// Or if we dont have permission to link
|| !(llGetPermissions() & PERMISSION_CHANGE_LINKS)) {
// Try getting permissions again.
state default;
}
}
touch_start(integer total_number)
{
//user clicked book, close
close();
state closed;
}

link_message(integer sender_number, integer number, string message, key id)
{
if (message == "user clicked cover")
{
//user clicked cover: close
close();
state closed;
}
else if (message == "backcover ready")
{
//store backcover link id
backcover_link_number = number;
backcover_key = llGetLinkKey(backcover_link_number);
}
}

timer()
{
llSetTimerEvent(0.0);
rez_page(1, FALSE, "");
}

object_rez(key id)
{
//page rezed, put it in our array
string tmpobjname = llKey2Name(id);
//page number is in its name
integer pagenumber = (integer)llGetSubString(tmpobjname, 5, -1);
setPage(pagenumber, id);
//send commands to page so it display the good texture and descriptions
send_page_commands(pagenumber);
}

listen(integer channel, string name, key id, string message)
{
//skip if not sent by one of our pages
if (!isOurPage(id))
{
return;
}
integer tmppagenumber = getPageNumber(id);
//one of our pages tell us something
if (llGetSubString(message, 0, 9) == "pageopened")
{
//The page has been flipped to the left, time to display next one
//rez next page
integer tmpnextpagenumber = tmppagenumber + 1;
if (tmpnextpagenumber <= number_of_pages)
{
rez_page(tmpnextpagenumber, FALSE, "");
}
integer tmppreviouspagenumber = tmppagenumber - 1;
if ( tmppreviouspagenumber > 0)
{
//tell previous page to die, it is no longer visible
kill_page(tmppreviouspagenumber);
}
}
else if (llGetSubString(message, 0, 9) == "pageclosed")
{
//The page has been flipped to the right, time to display the previous one
//rez previous page
integer tmppreviouspagenumber = tmppagenumber - 1;
if (tmppreviouspagenumber > 0)
{
rez_page(tmppreviouspagenumber, TRUE, "");
}
integer tmpnextpagenumber = tmppagenumber + 1;
if ( tmpnextpagenumber <= number_of_pages )
{
//tell next page to die
kill_page(tmpnextpagenumber);
}
}
}

moving_start()
{
//close the book when moved
close();
state closed;
}

state_entry()
{
llListenRemove(page_listener_id);
page_listener_id = llListen(102, "", NULL_KEY, "");
}

state_exit()
{
//clean up listener
if (page_listener_id == 0)
{
llListenRemove(page_listener_id);
}
}
}
Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
05-31-2005 05:47
sorry, I didn't get notification about this thread.

I didn't foresee the problem, thanks Christopher for the fix ; I'll test it later.


For those who want a no brainer for self use book to put pictures in, I saw a nice one at Thinc ; it's not free nor opensource though.
_____________________
Vincit omnia Chaos
From: Flugelhorn McHenry
Anyway, ignore me, just listen to the cow
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
05-31-2005 06:20
Thank you Christopher!
It was perfect. :)
_____________________
:) Seagel Neville :)
Ameretto Fredericks
Registered User
Join date: 11 Apr 2004
Posts: 48
Thank You.....but i need help
06-29-2005 22:14
I got a copy of your book in game but i would like it to be 1 meter by 1 meter in size. I tried resizing it myself in a number of different ways ... even took out the page and resized it seprately. But no matter how i resize it it ends up opening wierd or the pages are out of alignment with the book. Could ya tell me how i can make it bigger and still keep it in tact or maybe meet me in game with one that is the size i need????

Thank you. :)
_____________________
Second Life....My First Home.

Ameretto's Designs @ SL Exchange

Ameretto's Designs @ SL Boutique

My Main Store In Game
Selby 217,35

Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
06-30-2005 21:58
Hello Ameretto,

I've changed the size of this book, too.
Did you tweak the value of the last line? There is this in the first script.
CODE
rez_page(integer number, integer open, string commands)
{
rotation tmprot;
if (open)
{
tmprot = llGetRot();
//had a command so the page know its already on the left
setPageCommands(number, "alreadyopen");
}
else
{
tmprot = initialRot;
resetPageCommands(number);
}
//0.205 depends on the size of the book... to change for different sizes (PITA)
llRezObject("Page", initialPos + <0.205, 0, 0>, ZERO_VECTOR, tmprot, number);
}
Hope this helps you.
_____________________
:) Seagel Neville :)
Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
07-01-2005 04:44
Resizing the book is difficult, you have to change the value that Mr. Neville pointed. It takes several tries to find a good one. I've not found a way to make it automated in the script.
_____________________
Vincit omnia Chaos
From: Flugelhorn McHenry
Anyway, ignore me, just listen to the cow
Ameretto Fredericks
Registered User
Join date: 11 Apr 2004
Posts: 48
Thank you
07-01-2005 21:16
Thank you for your most expediant response I will now prolly be found in a corner with thousands of rezzed books trying to get the measurments. This I am sure will be of a great help to me. You guys are A1 on my list. The good one. :)
_____________________
Second Life....My First Home.

Ameretto's Designs @ SL Exchange

Ameretto's Designs @ SL Boutique

My Main Store In Game
Selby 217,35

Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
10-26-2005 12:34
To whoever asked me question about the book and to whom I could not respond because of a crash:
- there is no limit on the number of pages. (plus now with SL1.7 dragging pages in it is not longer a hassle)
- You probably can add a bookmark functionnality if you are a good scripter (or know one).
_____________________
Vincit omnia Chaos
From: Flugelhorn McHenry
Anyway, ignore me, just listen to the cow
Vindi Vindaloo
Registered User
Join date: 18 Aug 2004
Posts: 26
Can anyone of you send me 1 Book in Game pls?
11-17-2005 11:09
I would be very grateful if any of you could send me the primbook, that already contains the permissions for giving it away (xmas present) and with modfiable size if that is possible.

My name in game is always Vindi Vindaloo :) Thank you for your help
Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
11-20-2005 14:54
From: Vindi Vindaloo
I would be very grateful if any of you could send me the primbook, that already contains the permissions for giving it away (xmas present) and with modfiable size if that is possible.


If you can wait a bit more, I'll have a better version of the book out. I visited the place of the SL newspaper and one of my book was there, hopelessly scrambled (backcovers not following front cover... unclickable pages) so guilt made me resume work on it.
I removed the need for permission ; it's far more sturdy now.
The book adapts to the number of pages in it too (no changing it in the script) ; I'm adding an automatic handling of resizes now.

Someone asked for a book mark feature, I'll try to add it next, as well as optionnal table of chapters for quick jumps to them. And something to make the book readable in the japanese way, starting at the "last page".

If you have more suggestion for features, it's the time to do them.
_____________________
Vincit omnia Chaos
From: Flugelhorn McHenry
Anyway, ignore me, just listen to the cow
Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
12-08-2005 13:48
The new book is available and much better.

I removed the need for permission. It doesn't break with backcover going crazy anymore.
The book adapts to the number of pages in it too (no changing it in the script) ; you can resize it all you want, pages will adapt, no manual tweaking of a value in the script.

You put page comments in a notecard now too ; no editing of the script.

I didn't do the bookmark feature nor table of content as I can't see how to materialise it on the book (table of content would need dynamic text imo).
No japanese reading sense either.

But the book is really sturdy now, well worth a look. In all case for new project, use the new version !


Ask me IW for a copy, I couldn't find anywhere to distribute it this month yet.
_____________________
Vincit omnia Chaos
From: Flugelhorn McHenry
Anyway, ignore me, just listen to the cow
Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
12-12-2005 08:36
The book is now available in the GNUbie store. And is sold for a symbolic 1L$ . Thank to the GNUBie folks for the great place to put free stuff.
_____________________
Vincit omnia Chaos
From: Flugelhorn McHenry
Anyway, ignore me, just listen to the cow
Ivorness Steenbock
Registered User
Join date: 21 Jun 2006
Posts: 7
where to get
07-02-2006 01:08
I didn't find it IW. I'd be very glad if somebody could sent it to me: Ivorness Steenbock. Thnx in advance.
Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
Prim book v3
05-12-2007 03:33
The book has been updated. It still had lots of issues, but now I feel it's really rock-solid.

The book can be read in your HUD now. I also changed the licensing: you can make commercial books with it with restrictions on permissions (no-transfer, etc) ; as long as my scripts stay full-perms in your books (The GPL license requires it).

Places to get it:
- The GNUbie Store
http://slurl.com/secondlife/Indigo/250/64/31

- Asparagus Creations:
http://slurl.com/secondlife/Lanestris/14/4/117
_____________________
Vincit omnia Chaos
From: Flugelhorn McHenry
Anyway, ignore me, just listen to the cow
Aaleigh Cullen
Registered User
Join date: 30 Aug 2006
Posts: 1
05-14-2007 16:05
Where exactly in that store is it located, cause I spent over an hour looking everywhere and I didn't it.
Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
05-15-2007 05:35
From: Aaleigh Cullen
Where exactly in that store is it located, cause I spent over an hour looking everywhere and I didn't it.


I suppose you mean at GNUbie store, lots of people have trouble there. Here are snapshots to help you find the book at both store:

GNUbie store:
http://www.issarlk.net/Book_Gnubie_1.jpg
http://www.issarlk.net/Book_Gnubie_2.jpg

Asparagus creations:
http://www.issarlk.net/Book_Asparagus.jpg
_____________________
Vincit omnia Chaos
From: Flugelhorn McHenry
Anyway, ignore me, just listen to the cow
Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
06-01-2007 09:11
Following the recent witch hunt on fantasies on SL (rape roleplay is outlawed now), I'm in the process of downgrading my account.

The book will now only be availlable on the Gnubie store. Also all further developments of the book are on hold indefinitely.
_____________________
Vincit omnia Chaos
From: Flugelhorn McHenry
Anyway, ignore me, just listen to the cow