Book Template
obj/book
{
var/open = 0;
var/page[0];
var/Page/num;
verb/close()
{
set src in view(1);
if(open == 1)
{
icon_state = "close";
open = 0;
num = 0;
}
else
{
usr << "The [name] is closed.";
}
}
verb/previous()
{
set src in view(1);
if(open == 0)
{
usr << "The [name] is closed";
}
else if(num > 1)
{
page[num]--;
}
else
{
close();
}
}
verb/next()
{
set src in view(1);
if(open == 0)
{
usr << "The [name] is closed";
}
else if(num < page.len)
{
page[num]++;
}
else
{
close();
}
}
}
Page
{
var/num as num;
}
Problem description:
The above is a snippet from code I'm working on. It's meant to make a template book with all the basic verbs, so all I have to do is make a sub-object and fill in the blanks.
The problem I'm having is with the next() verb. As shown it will only flip one page then stop working.
I can make it flip through all the pages, but then the second part of the next() verb doesn't work. I also want it so that when you reach the last page it will close the book.
The previous verb also shown works fine. I added it to give an idea of what I'm looking for. (Reversed of coursed.)
I'm stumped so any ideas are much appreciated.
Also, for some reason, you've defined the num variable to be of type Page, which does not make sense.
Also, having the Page type contain a variable for the page number is rather redundant.