[ Package Index | Mudlib Index | Effect Index ]

File /std/book.c

A nice book object. A book will be a collection of pages. You can tear pages out of a book, you can add pages (though adding a page isnt overly useful, unless you bind it in of course).

Each page is an object. Pages that are torn out are handled as empty spots in the array.

Written by Pinkfish


Inherits

This class inherits the following classes /std/object.c

Includes

This class includes the following files /include/move_failures.h, /include/player.h and /include/playtesters.h

Method index

 o add_page_after(object, int)
This method adds a new page in after the selected page.
 o create_default_page_object()
This method creates a new default page object for this book.
 o is_current_page_torn_out()
This method checks to see if the current page is torn out.
 o is_default_page(int)
This method checks to see if the page is still the default page object or if it is something else altogether.
 o is_page_torn_out(int)
This method checks to see if the specified page is torn out.
 o make_page_blank(int)
This method makes the selected page blank.
 o query_book()
Tells us if this is a book object.
 o query_book_num()
This method returns the current number of the book.
 o query_current_page()
Returns the object associated with the current open page.
 o query_current_page_clone()
This function makes sure the page actually exists.
 o query_default_page_object()
This method returns the default page object.
 o query_ignore_saved_pages()
This method returns the current setting of the ignore saved pages variable.
 o query_num_pages()
Queries the number of pages in the book.
 o query_open_page()
What is the current open page.
 o query_pages()
Returns the pages array.
 o query_player()
This method will return the player associated with the auto loading process.
 o query_selected_page(int)
This method returns the contents of the selected page.
 o query_selected_page_clone(int)
This method returns the contents of the selected page, if a default object is returned a real clone for the page is created instead.
 o replace_page_with(object, int)
This method replaces the selected page with a new page.
 o set_book_num(int)
This method sets the current number of the book.
 o set_default_page_object(string)
Sets the object to use as the default page.
 o set_ignore_saved_pages(int)
This method sets the current setting of the ignore saved pages variable.
 o set_no_pages(int)
Set the number of pages in the book.
 o set_open_page(int)
Sets the currently open page.
 o set_player(object)
This method is called by the auto loading process to set the current player on this object.
 o tear_current_page_out(object)
This method tears the current page out of the book and returns it to us.

Public Functions

These are functions that everyone can access.

.
 * add_page_after
int add_page_after(object page,
                   int after)
This method adds a new page in after the selected page. The pages are numbered from 1, so adding a page after page 0 will place a page on the start and after the last page onto the end.

Parameters:
page - the page to add
after - the page to add it after
Returns:
1 on success, 0 on failure
See also:
query_current_page() and query_num_pages()
 * create_default_page_object
object create_default_page_object()
This method creates a new default page object for this book. THis can be used for whatever nefarious purposes you want.

Returns:
a new default page object
 * is_current_page_torn_out
int is_current_page_torn_out()
This method checks to see if the current page is torn out.

Returns:
1 if torn out, 0 if not
See also:
query_current_page(), query_open_page() and is_page_torn_out()
 * is_default_page
int is_default_page(int num)
This method checks to see if the page is still the default page object or if it is something else altogether.

Returns:
1 if it is the default page object, 0 if not
 * is_page_torn_out
int is_page_torn_out(int page)
This method checks to see if the specified page is torn out.

Parameters:
page - the page number to check
Returns:
1 if it is torn out, - if not
See also:
is_current_page_torn_out()
 * make_page_blank
int make_page_blank(int num)
This method makes the selected page blank. It defaults it back to a default page object as if the book had just been created.

Parameters:
num - the page to make blank
See also:
replace_page_with(), add_page_after() and add_blank_page_after()
 * query_book
int query_book()
Tells us if this is a book object.

Returns:
always returns 1
 * query_book_num
int query_book_num()
This method returns the current number of the book. This is assigned and used in conjunction with the book handler.

Returns:
the current book number
See also:
/obj/handlers/book_handler.c and /std/print_shop.c
 * query_current_page
object query_current_page()
Returns the object associated with the current open page. If the page does not actualy exist yet then the default base object is returned. This object should be handled carefully... If the page is torn out then the next readable page is returned or 0 is returned.

Returns:
the current page object
See also:
query_current_page_clone(), set_open_page(), query_open_page() and query_current_page_clone()
 * query_current_page_clone
object query_current_page_clone()
This function makes sure the page actually exists. If it does not exist, then it will clone one up for us. This one should be used as you will not end up with the base object in this case. If you are planning to modify the page, then use this call.

Returns:
the object of the current page
See also:
query_current_page()
 * query_default_page_object
string query_default_page_object()
This method returns the default page object.

Returns:
the default page object (as a string)
 * query_ignore_saved_pages
int query_ignore_saved_pages()
This method returns the current setting of the ignore saved pages variable. If this is true then the pages form the players auto_load stuff will be ignored totaly and only the page creates in setup would be used.

Returns:
the current ignore saved page attribute
See also:
set_ignore_saved_pages()
 * query_num_pages
int query_num_pages()
Queries the number of pages in the book.

Returns:
the number of pages in the book
See also:
set_no_pages()
 * query_open_page
int query_open_page()
What is the current open page. Returns 0 if the book is not open.

Returns:
the current open page
See also:
set_open_page() and query_current_page()
 * query_pages
mixed * query_pages()
Returns the pages array.

Returns:
the array containing the pages information
 * query_player
object query_player()
This method will return the player associated with the auto loading process.

Returns:
the player in use by the autoloading
See also:
set_player()
 * query_selected_page
object query_selected_page(int num)
This method returns the contents of the selected page. The number must be greator than 0. This will return the exact value of the page, it will not search for non-torn out pages. Becare with the return value of this as the default page object might be returned if the page does not actually exist. If you need a real object remember to use the clone version.

Parameters:
num - the page to return
Returns:
0 on failure or if the page is torn out, the object on success
 * query_selected_page_clone
object query_selected_page_clone(int num)
This method returns the contents of the selected page, if a default object is returned a real clone for the page is created instead.

Parameters:
num - the page to return
Returns:
0 on failure or if the page is torn out, the object on success
 * replace_page_with
int replace_page_with(object page,
                      int num)
This method replaces the selected page with a new page. The old page is dested if it can be and replaced with a nice shiny new page object.

Parameters:
page - the page to replace with
num - the page number to replace
Returns:
1 on success, 0 on failure
See also:
add_page_after()
 * set_book_num
void set_book_num(int num)
This method sets the current number of the book. This is assigned and used in conjunction with the book handler.

Parameters:
num - the new book number
See also:
/obj/handlers/book_handler.c and /std/print_shop.c
 * set_default_page_object
void set_default_page_object(string obj)
Sets the object to use as the default page. If this is not set the the object /obj/misc/paper.c will be used.

Parameters:
ob - the object to use as the default page
 * set_no_pages
void set_no_pages(int no)
Set the number of pages in the book. If there are too many pages in the book, then pages are removed from the top to create the correct size and if there are too few pages then pages are added onto the end of the pages array.

Parameters:
no - the number of pages
See also:
query_pages() and query_num_pages()
 * set_open_page
void set_open_page(int i)
Sets the currently open page. This does all the magic needed to make the book appear as if it is the currently opened page. If the open page is 0 then the book is closed. If it is out of the upper bound then the book is opened to the last page.

Parameters:
i - the page to open to
See also:
query_open_page() and query_current_page()
 * set_player
void set_player(object player)
This method is called by the auto loading process to set the current player on this object.

Parameters:
player - the player to set
See also:
query_player()
 * tear_current_page_out
object tear_current_page_out(object dest)
This method tears the current page out of the book and returns it to us. This object will be moved into the destination so that it is no longer inside us. If it cannot be moved of the page has already been remove then the function will return 0.

Parameters:
dest - the destination to move the page to
Returns:
the torn out page, or 0 on failure

Protected Functions

These are functions that only objects inheriting the class can access.

 * set_ignore_saved_pages
void set_ignore_saved_pages(int saved)
This method sets the current setting of the ignore saved pages variable. If this is true then the pages form the players auto_load stuff will be ignored totaly and only the page creates in setup would be used. This can only be called from an object which inherits this one (hence the protected method).

Parameters:
saved - the new value of the saved attribute
See also:
query_ignore_saved_pages()

Discworld MUD's distribution world wide web pages.
brought to you by
Cut Me Own Throat Dibbler's Sensational Sausages; buy one while they are hot.
File last modified: Sat, 06 Sep 2003 02:22:46 GMT

Lost? Try Discworld's home page.