Since I’m ridiculously bad at figuring out how to create items, I ended up outright stealing Aaron Reed’s book mechanism to create a book. I added a few basic functions so that the player can turn back pages and consult the book if need be. The problem comes in where there are two books in the same place.
A shoddy example:
[code]
“Waiting Room”
Waiting Room is a room. “A waiting room.”
A thing has some text called printing. The printing of a thing is usually “blank”.
Understand the command “read” as something new. Understand “read [something]” as reading. Reading is an action applying to one thing and requiring light. Carry out reading: say “You read: [paragraph break][printing of the noun][line break]”. Report reading: do nothing.
Check reading:
if the noun is a book, try read-booking the noun instead;
if the printing of the noun is “blank”, say “Nothing is written on [the noun].” instead.
A book is a kind of thing. Understand “book” or “books” or “page” or “pages” as a book. A book has a table name called the contents.
Understand the command “read-book” as something new. Read-booking is an action applying to one visible thing. Understand “read [something]” as read-booking. Check read-booking: if noun is not a book, try examining noun instead.
A book is a kind of thing. Understand “book” or “books” or “page” or “pages” as a book.
A book can be open or closed. A book can be openable. A book is usually closed. A book is always openable. Does the player mean doing something to an open book: it is likely. Check opening a book (called tome): try read-booking tome instead. Check closing a book (called tome): now tome is closed; say “You close [the tome] again.” instead.
A book has a number called current page. The current page of a book is usually 0. To say current page of (tome - a book): let n be the current page of tome; choose row n in the contents of tome; say “[reply entry][paragraph break]”.
A book has a table-name called contents.
Carry out read-booking:
repeat with tome running through books enclosed by location:
now tome is closed;
now noun is open;
if current page of noun is 0, now current page of noun is 1;
say “[if current page of noun is 1]You open [the noun].[paragraph break][end if][current page of noun][if the current page of noun is at most the number of rows in contents of noun - 1]Turn to the next page? Turn back a page?[otherwise][The noun] is turned to the last page.[end if]”.
Check read-booking:
if the player is not holding the book:
say “You can’t read anything from this distance.” instead.
The contents of a book is usually Table of No Contents.
Table of No Contents
topic reply
“BLAH” “BLAH”
Forward-turning is an action applying to one thing.
Back-turning is an action applying to one thing.
Check back-turning book (called tome):
if the book is not open:
try opening the NOUN instead;
if the player is not holding the book:
say “You can’t read anything at this distance.” instead;
otherwise:
decrease the current page of tome by 1;
if current page of tome is less than the number of rows in contents of tome:
now the current page of tome is 0;
say “You close [the tome].” instead;
otherwise:
say “You turn back a page.”;
try read-booking tome instead.
Check forward-turning book (called tome):
if the book is not open:
try opening the NOUN instead;
if the player is not holding the book:
say “You can’t read anything at this distance.” instead;
otherwise:
increase the current page of tome by 1;
if current page of tome is greater than the number of rows in contents of tome:
now the current page of tome is 0;
say “You close [the tome].” instead;
otherwise:
say “You turn to the next page.”;
try read-booking tome instead.
Understand the command “turn” as something new.
Understand “flip to the next [something]” as forward-turning. Understand “flip to next [something]” as forward-turning. Understand “turn [something]” as forward-turning. Understand “turn the [something]” as forward-turning. Understand “turn [something] forward” as forward-turning. Understand “turn to next [something]” as forward-turning. Understand “turn to the next [something]” as forward-turning. Understand “turn next [something]” as forward-turning. Understand “turn the [something] forward” as forward-turning.
Understand “flip to the previous [something]” as back-turning. Understand “flip to previous [something]” as back-turning. Understand “flip back a [something]” as back-turning. Understand “turn back a [something]” as back-turning. Understand “turn back the [something]” as back-turning. Understand “turn [something] back” as back-turning. Understand “turn [something] back one” as back-turning. Understand “turn to [something] previous page” as back-turning. Understand “turn [something] backwards” as back-turning.
The BAD NEWS WEEKLY is a book. BAD NEWS WEEKLY is in the waiting room. The contents of BAD NEWS WEEKLY is the Table of Bad News.
Table of BAD NEWS
topic reply
“Some random pages” “Some ads for life insurance and alarm systems”
“Death” “The headline screams: ‘10 killed in freak balloon accident. Will your child be next?’”
TABLOID NOW is a book. TABLOID NOW is in the waiting room. The contents of TABLOID NOW is the Table of Junk
Instead of consulting a book about a topic listed in the contents of the noun:
say “[reply entry][paragraph break]”.
The current page of TABLOID NOW is 2.
Table of Junk
topic reply
“Babies” “Is that a Baby Bump? YES!”
“Rehab” “Is your favorite star is rehab? YES!”
“Yes” “YES!”[/code]
If you delete one book, the other functions beautifully, but with two, the player can’t turn the page. It simply stays on page 1 forever.
I’m not sure what exactly is causing it, which I suppose is understandable given I didn’t write the base code for the books.
Thanks for any help.