Dynamic Book Template

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.
User avatar
andylegate
Posts: 2348
Joined: Mon Oct 01, 2007 7:47 am
MOULa KI#: 0

Re: Dynamic Book Template

Post by andylegate »

Sure......give me a few
"I'm still trying to find the plKey for Crud!"
Image
Blender Age Creation Tutorials
3DS Max Age Creation Tutorials
D'Lanor
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Dynamic Book Template

Post by D'Lanor »

Hang on, it may be my error after all. I am going to try something. But go ahead and add the debugging print anyway.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
andylegate
Posts: 2348
Joined: Mon Oct 01, 2007 7:47 am
MOULa KI#: 0

Re: Dynamic Book Template

Post by andylegate »

Done. Here's what it said this time:

(01/30 15:23:26) __init__CampbravoBookGUI v.1
(01/30 15:23:30) CampbravoBookGUI: OnFirstUpdate called
(01/30 15:23:37) CampbravoBookGUI: OnNotify called
(01/30 15:23:37) Someone clicked on object welcomebk
(01/30 15:23:37) It was you
(01/30 15:23:37) CampbravoBookGUI: OnNotify called


So, yah, I've got the object named right. :?
"I'm still trying to find the plKey for Crud!"
Image
Blender Age Creation Tutorials
3DS Max Age Creation Tutorials
D'Lanor
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Dynamic Book Template

Post by D'Lanor »

I guess I never tested it with less than 2 books. :oops: The quick workaround for now is to add a dummy book until I have made the code smarter.

Code: Select all

ageBooks = ('welcomebk', 'dummy')
bookPages = (['cbjournal1'], ['dummy'])
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
andylegate
Posts: 2348
Joined: Mon Oct 01, 2007 7:47 am
MOULa KI#: 0

Re: Dynamic Book Template

Post by andylegate »

Okay! I'll give it a try here in a few. I got to take Wendy out, she's barking at me, and when a Basset Hound has to go, they have to go!

BTW-- while waiting, and out of curiosity. I emptied out my pak file, and put my old Campbravo.py in it, the one that uses the uam.showbook junk.
Went into blender and changed the click file name, etc.


er....it worked! Journal popped up, opened up and read just fine.

BUT! D'Lanor, I've got like 4 books in my Age, and I would MUCH rather use your stuff.

So give me a few. BRB.
"I'm still trying to find the plKey for Crud!"
Image
Blender Age Creation Tutorials
3DS Max Age Creation Tutorials
User avatar
andylegate
Posts: 2348
Joined: Mon Oct 01, 2007 7:47 am
MOULa KI#: 0

Re: Dynamic Book Template

Post by andylegate »

SUCCESS!!!!!!!!!!!!!! YeeeeeeHAAAAAWWWWWWW!

Okay, I didn't use your Dummy books. Like I said, I've got 4 books in my Age, 2 Journals, and 2 notebooks. So I added my Assignment Book.

Bingo! Both books pop up and work!

this is great! As I need to add two more books too.

Oh, last question. Uhm, how do I tell it to present a different texture for each book when it pops up?

You've got this in the CampbravoPageDefs:

Code: Select all

# BookDef sets cover and margins of the book. The cover can be the same texture as used for the book object itself.
BookDef = '<cover src="welcomebook"><margin right=32 left=32>'


Uhm, this allows for only one book cover when it pops up.
"I'm still trying to find the plKey for Crud!"
Image
Blender Age Creation Tutorials
3DS Max Age Creation Tutorials
D'Lanor
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Dynamic Book Template

Post by D'Lanor »

Yes, I am afraid that cannot be changed easily. Support for multiple books was a last minute addition and I didn't think about different covers. And like many last minute additions it messed a few things up that were working fine before.

I am going to do an overhaul soon to address those issues.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
andylegate
Posts: 2348
Joined: Mon Oct 01, 2007 7:47 am
MOULa KI#: 0

Re: Dynamic Book Template

Post by andylegate »

Do you think putting in <cover src="Your_Texture"> in the journals would work?
"I'm still trying to find the plKey for Crud!"
Image
Blender Age Creation Tutorials
3DS Max Age Creation Tutorials
D'Lanor
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Dynamic Book Template

Post by D'Lanor »

You could change IOpenBook like this:

Code: Select all

    def IOpenBook(self, bkPages = None, forceOwned = 0):
        global ourBook
        global bkLinks
        print ('%s: IOpenBook: Page request for %s' % (self.__class__.__name__, bkPages))
        if (type(bkPages) == type(None)):
            return
        #PageDef = CampbravoPageDefs.BookDef + CampbravoPageDefs.BookFont
        PageCount = xLinkingBookDefs.kFirstLinkPanelID
        bkLinks = []
        for bkPage in bkPages:
            if (not bkPage in CampbravoPageDefs.LinkDestinations):
                print ('skipping %s because definition does not exist' % bkPage)
                continue
            # setting up the destination from the definition
            params = CampbravoPageDefs.LinkDestinations[bkPage]
            (bkAge, spawnPoint, spTitle, linkRule,) = params
            alink = 1
            if (type(bkAge) != type(None) and forceOwned):
                print ('ownership check for %s book' % bkAge)
                vault = ptVault()
                ainfo = ptAgeInfoStruct()
                ainfo.setAgeFilename(bkAge)
                alink = vault.getOwnedAgeLink(ainfo)
            if alink:
                print ('showing page for %s' % bkAge)
                if (type(bkAge) != type(None)):
                    t = (PageCount, bkAge, spawnPoint, spTitle, linkRule)
                    bkLinks.append(t)
                    PageDef = CampbravoPageDefs.BookPages[bkPage] % (PageCount) + '<pb>'
                else:
                    PageDef = CampbravoPageDefs.BookPages[bkPage] + '<pb>'
                PageCount = PageCount + 1
            else:
                print ('No %s book on your shelf so we are not showing the link' % bkAge)
        if (PageCount == xLinkingBookDefs.kFirstLinkPanelID):
            print 'no pages created'
            return
        print ('linkingpages created: %d' % (len(bkLinks)))
        PageDef = PageDef[:-4]
        ourBook = ptBook(PageDef, self.key)
        ourBook.setSize(1.0, 1.0)
        ourBook.setGUI('BkBook')
        ourBook.show(0) # 0 = closed book, 1 = open book

And then put the cover plus font definitions in front of the definition in CampbravoPageDefs.BookPages
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
andylegate
Posts: 2348
Joined: Mon Oct 01, 2007 7:47 am
MOULa KI#: 0

Re: Dynamic Book Template

Post by andylegate »

Hey, I'll give it a whirl. Now that the books are working, this shouldn't be that hard (he says as an evil laugh can be heard from far, far away....) :D
"I'm still trying to find the plKey for Crud!"
Image
Blender Age Creation Tutorials
3DS Max Age Creation Tutorials
Post Reply

Return to “Scripting”