[Package Index | Mudlib Index | Effect Index]

File /obj/crafts/pattern_book_inherit.c

An inherit for pattern books. The books can be used with various craft activities to add patterns to things. This doesn't add any actual text to the page and will need to be added to the book with add_read_mess. Once a pattern has been added to a player's object it cannot be changed, therefore be extra careful to ensure that there are no typos. Functions are controlled by the craft tools.

Written by Kaylar

Started June 2005

Method index

Public Functions

These are functions that everyone can access.

add_pattern
void add_pattern(int page_number,
                 string name,
                 string * messages,
                 string difficulty,
                 int times)

This function adds a pattern to the book.

Parameters:
page_number - If used as a single sheet of paper the page number should be set to 0, if used with a book the number should correspond to the page you wish the pattern to appear on.
name - A name for the pattern, this will be seen by the player if the pattern is incomplete.
*messages - An array of eight strings describing the pattern. Firstly successes from marginal to critical then failures from marginal to critical. For engraving and embroidery these must be full sentences ending with "\n" and starting with something like "It is embroidered/engraved with". For those too lazy to write eight different descriptions, just write one that could apply to all conditions (still in an array though). If you want an adjective or adverb use $adjective$ or $adverb$ respectively and $a_adjective$ and $a_adverb$ for the add_a-ised version. $item$ can be used for the short of the item. For embroidery and quilting, $colours$ or $a_colours$ can be used to show the colours of the thread. For cutting out appliques, the patterns must be the short of the applique, without a preceding "a" or "an". They will become "a/an applique". There is no need to use $colours$ or $item$ for appliques.
difficulty - How hard the pattern is to create, either "easy", "medium", "difficult" or "expert".
times - The number of times the pattern needs to be worked on. For embroidery and quilting this is the number of threads required to complete the pattern (this is what allows players to use a number of colours, if more than 4 different colours are used "multicoloured" will be used for the colour short). Set this to 0 for other crafts.

See also:
query_patterns() and query_pattern_info()

Example:
For embroidery:
 add_pattern( 4, "rose",
   ({ "It is embroidered with a single rose created in $colours$ thread.\n",
     "A beautiful rose created from $colours$ thread has been embroidered "
       "on the $item$.\n",
     "A small but beautiful bunch of $colours$ roses has been delicately "
       "embroidered on the $item$.\n",
     "A lovely bouquet of $colours$ roses has been skillfully embroidered "
       "on it.\n",
     "It has an unattractive rose embroidered on it.\n",
     "A rose is embroidered on it with crooked $colours$ stitches.\n",
     "A mess of $colours$ stitches marr the $item$.\n",
     "It is embroidered with chaotic collection of $colours$ stitches.\n" }),
   "difficult", 3 );

For quilting:
 add_pattern( 5, "trailing ivy",
   "It has been quilted all over with a pattern of trailing ivy in "
     "$colours$ thread.\n",
   "A pattern of trailing ivy has been quilted on it in $colours$ "
     "thread.\n",
   "Delicate quilting in a pattern of trailing ivy decorates the "
     "$item$ in $colours$ thread.\n",
   "A beautiful pattern of trailing ivy has been quilted on it in "
     "$colours$ thread.\n",
   "A simple pattern of trailing ivy has been quilted on it in $colours$ "
     "thread.\n",
   "It is quilted with a messy pattern of trailing ivy in $colours$ "
     "thread.\n",
   "A few wobbly $colours$ lines have been quilted on it.\n",
   "A few wobbly $colours$ lines have been quilted on it.\n" }),
 "easy", 3 );

For appliqueing:
 add_pattern( 3, "cat",
   ({ "cat", "neatly cut cat", "cute cat", "elegant cat",
      "poorly cut cat", "crooked cat", "ragged cat", "deformed cat" }),
   "difficult", 0 );

do_tear
int do_tear(int number)
query_craft_type
string query_craft_type()

This returns the type of craft that the book can be used with.

Returns:
the type of craft.

See also:
set_craft_type()


query_flexible
int query_flexible()
query_pattern_book
int query_pattern_book()

This is always true.

Returns:
1, it is a pattern book.


query_pattern_info
mixed query_pattern_info(int page_number)

This returns the information associated with the page number.

Returns:
a mixed array of pattern information: ({ name, messages, difficulty, times })

See also:
add_pattern() and query_patterns()


query_patterns
mapping query_patterns()

This returns all patterns associated with this book.

Returns:
a mapping of patterns, the key is the page number and the value is a mixed array of pattern information.

See also:
add_pattern() and query_pattern_info()


set_craft_type
void set_craft_type(string craft_type)

This function sets the craft type the patterns can be used with. This must be set.

Parameters:
type - The type of craft the patterns can be used with, such as "engraving", "embroidery", etc.

See also:
query_craft_type()

Example:
set_craft_type( "engraving" );