Pythons Driving me nuts!

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

Pythons Driving me nuts!

Postby GPNMilano » Thu Jun 19, 2008 9:18 am

Okay, I'm ready to beat the crap out of my keyboard. Maybe someone can help me.

I'm using D'Lanor's template for my books and journals. Whenever I make a new book or journal I add code to the pre-existing file. I just added four new books to the file, and now the PageDefs are throwing up all sorts of weird errors. It started by giving me an EOF error for the very last line in the file, even when its an empty line. If I try to pack it with Plasmashop, it says there's a syntax error, where there clearly isn't one (I deleted the entire section of code and rewrote the thing just to be sure, when it kept giving me that error. Now its saying there's there's inconsistent indentation detected. I'm seriously at my wits and and just about to start a brand new file. Because I've checked everything for the last hour, and none of the code is wrong, everything's exactly where it should be.
You can't stop the truth. IC Blog
User avatar
GPNMilano
 
Posts: 1155
Joined: Mon Apr 21, 2008 5:50 am

Re: Pythons Driving me nuts!

Postby andylegate » Thu Jun 19, 2008 9:48 am

Can you post it here? Let one of us try to pack it with PlasmaShop and see if it works or not. If it does, I'd say reinstall PlasmaShop.
"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

Re: Pythons Driving me nuts!

Postby GPNMilano » Thu Jun 19, 2008 1:53 pm

It was the code itself Andy. The bookpages were throwing up an exception. The code in the template is

Code: Select all
BookPages = {'BevinBalcony01': (PageStart + ImgStart + 'xLinkPanelBevinBalc01*1#0.hsm' + ImgEnd + AlignCenter),
 'CleftDefault': (PageStart + ImgStart + 'xLinkPanelCleftDesert*1#0.hsm' + ImgEnd + AlignCenter),
 'CleftFissureDrop': (PageStart + ImgStart + 'xLinkPanelCleftDesert*1#0.hsm' + ImgEnd + AlignCenter),
 'CleftSpecial': (PageStart + ImgStart + 'xLinkPanelTomahnaDesert*1#0.hsm' + ImgEnd + '<font size=26 face=Uru color=221166>' + AlignCenter + 'Don\'t even think about it'),
 'KadishPyramid': (PageStart + ImgStart + 'xLinkPanelKadishGlowBalc*1#0.hsm' + ImgEnd + AlignCenter),
 'FontTest': (PageStart + DefFontTest),
 'PradJournal': (PageStart + (DefPradJournal % plyrName))}


But if you enter books exactly like that, the more you have, the more it will throw up the exception. That is the parentheses. Compiling it will usually put in the extra ones you need, but the more lines you have for books, it will eventually crap out. Putting in the code like this

Code: Select all
{'BevinBalcony01': (PageStart + ImgStart) + ('xLinkPanelBevinBalc01*1#0.hsm') + (ImgEnd) + (AlignCenter),


seems to have fixed the problem, and my books all still work fine.
You can't stop the truth. IC Blog
User avatar
GPNMilano
 
Posts: 1155
Joined: Mon Apr 21, 2008 5:50 am

Re: Pythons Driving me nuts!

Postby GPNMilano » Thu Jun 19, 2008 10:48 pm

Nevermind. I'm an idiot. I was reading the code wrong from the template and putting too many parentheses in. Which was causing all the multiline (( )) statement problems. Sorry D'Lanor if I cast doubt on your great work.
You can't stop the truth. IC Blog
User avatar
GPNMilano
 
Posts: 1155
Joined: Mon Apr 21, 2008 5:50 am

Re: Pythons Driving me nuts!

Postby andylegate » Fri Jun 20, 2008 4:21 am

Glad you figured it out then!
"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

Re: Pythons Driving me nuts!

Postby Chacal » Fri Jun 20, 2008 12:45 pm

GPNMilano wrote:Nevermind. I'm an idiot.


This from the girl who single-handedly figured out the MOUL Ages ladder and sound bug, found a fix, found a way to import new MOUL prps in old CC Ages, found a way to attach MOUL python scripts to new objects, and is working on her Age at the same time.
Chacal


"The weak can never forgive. Forgiveness is an attribute of the strong."
-- Mahatma Gandhi
User avatar
Chacal
 
Posts: 2508
Joined: Tue Nov 06, 2007 2:45 pm
Location: Quebec, Canada

Re: Pythons Driving me nuts!

Postby GPNMilano » Fri Jun 20, 2008 4:45 pm

No, Chacal, I'm an idiot. I fixed the errors with the syntax, but the books still don't work. Python leg says the AgeBooks module doesn't exist, but its in both the files. I'm not sure whats going on with it. So, the books are broken until I can fix them.
You can't stop the truth. IC Blog
User avatar
GPNMilano
 
Posts: 1155
Joined: Mon Apr 21, 2008 5:50 am

Re: Pythons Driving me nuts!

Postby Robert The Rebuilder » Fri Jun 20, 2008 8:16 pm

What value do you have for "pythonfile" in your clickable book's AlcScript? Does it match the class name in your Python file?

Could you attach your Python files to your reply so that we can look at them? [First zip them before attaching them, since the forum won't allow .py file attachments]
Can we rebuild it? Yes, we can - here's how.

MOULagain KI# 1299

Myst Movie coming soon - spread the word!
User avatar
Robert The Rebuilder
 
Posts: 1383
Joined: Sat Sep 29, 2007 7:24 am
Location: Virginia, US

Re: Pythons Driving me nuts!

Postby GPNMilano » Fri Jun 20, 2008 10:35 pm

Robert The Rebuilder wrote:What value do you have for "pythonfile" in your clickable book's AlcScript? Does it match the class name in your Python file?

Could you attach your Python files to your reply so that we can look at them? [First zip them before attaching them, since the forum won't allow .py file attachments]


Well, D'Lanor was able to help with my original problem. I'm stuck now with a problem similar to what Andy had awhile back with his books in CampBravo. Several of the linking books don't have linking panels. Namely Gahreesen, Eder Tsogal and Delin and The link to the city. And my link to the GZ throws up a tuple error.

The elf file shows this:

Code: Select all
(06/20 23:06:16) Someone clicked on object EderTsogalLinkBook
(06/20 23:06:16) It was you
(06/20 23:06:16) Trying book M-NegilahnBook with page(s) ['M-NegilahnBook']
(06/20 23:06:16) No match
(06/20 23:06:16) Trying book M-DerenoBook with page(s) ['M-DerenoBook']
(06/20 23:06:16) No match
(06/20 23:06:16) Trying book M-PayiferenBook with page(s) ['M-PayiferenBook']
(06/20 23:06:16) No match
(06/20 23:06:16) Trying book M-TetsonotBook with page(s) ['M-TetsonotBook']
(06/20 23:06:16) No match
(06/20 23:06:16) Trying book jrnlNegilahn with page(s) ['NegilahnJournal']
(06/20 23:06:16) No match
(06/20 23:06:16) Trying book LIBMinkataBook with page(s) ['LIBMinkataBook']
(06/20 23:06:16) No match
(06/20 23:06:16) Trying book LIBJalakBook with page(s) ['LIBJalakBook']
(06/20 23:06:16) No match
(06/20 23:06:16) Trying book DniLinkingBookToGrsn with page(s) ['DniLinkingBookToGrsn']
(06/20 23:06:16) No match
(06/20 23:06:16) Trying book DniLinkingBookToGZ with page(s) ['DniLinkingBookToGZ']
(06/20 23:06:16) No match
(06/20 23:06:16) Trying book EderTsogalLinkBook with page(s) ['EderTsogalLinkBook']
(06/20 23:06:16) Match found! Start opening book...
(06/20 23:06:16) CityBookGUI: IOpenBook: Page(s) requested ['EderTsogalLinkBook']
(06/20 23:06:16) Showing EderTsogalLinkBook, link destination EderTsogal
(06/20 23:06:16) 1 item(s) created, linking page(s): 1
(06/20 23:06:16) CityBookGUI: OnNotify called
(06/20 23:06:16) BookNotify: Show book, event=1
(06/20 23:06:16) CityBookGUI: OnNotify called
(06/20 23:06:18) CityBookGUI: OnNotify called
(06/20 23:06:18) BookNotify: Hide book, event=2
(06/20 23:06:23) CityBookGUI: OnNotify called
(06/20 23:06:23) Someone clicked on object DniLinkingBookToGZ
(06/20 23:06:23) It was you
(06/20 23:06:23) Trying book M-NegilahnBook with page(s) ['M-NegilahnBook']
(06/20 23:06:23) No match
(06/20 23:06:23) Trying book M-DerenoBook with page(s) ['M-DerenoBook']
(06/20 23:06:23) No match
(06/20 23:06:23) Trying book M-PayiferenBook with page(s) ['M-PayiferenBook']
(06/20 23:06:23) No match
(06/20 23:06:23) Trying book M-TetsonotBook with page(s) ['M-TetsonotBook']
(06/20 23:06:23) No match
(06/20 23:06:23) Trying book jrnlNegilahn with page(s) ['NegilahnJournal']
(06/20 23:06:23) No match
(06/20 23:06:23) Trying book LIBMinkataBook with page(s) ['LIBMinkataBook']
(06/20 23:06:23) No match
(06/20 23:06:23) Trying book LIBJalakBook with page(s) ['LIBJalakBook']
(06/20 23:06:23) No match
(06/20 23:06:23) Trying book DniLinkingBookToGrsn with page(s) ['DniLinkingBookToGrsn']
(06/20 23:06:23) No match
(06/20 23:06:23) Trying book DniLinkingBookToGZ with page(s) ['DniLinkingBookToGZ']
(06/20 23:06:23) Match found! Start opening book...
(06/20 23:06:23) CityBookGUI: IOpenBook: Page(s) requested ['DniLinkingBookToGZ']
(06/20 23:06:23) Traceback (most recent call last):
(06/20 23:06:23)   File "C:\DOCUME~1\HP_Owner\LOCALS~1\Temp\tmp1133.tmp\CityBookGUI.py", line 44, in OnNotify
(06/20 23:06:23)   File "C:\DOCUME~1\HP_Owner\LOCALS~1\Temp\tmp1133.tmp\CityBookGUI.py", line 99, in IOpenBook
(06/20 23:06:23) ValueError: unpack tuple of wrong size


The Tsogal/Gahreesen/City books all open properly, but the book doesn't show a link panel, and there is no hotspot. While the GZ book doesn't even open.

This is the corresponding code for the link panels:

Code: Select all
BookPages = {'M-NegilahnBook': (PageStart + ImgStart + 'xlinkpanelnegilahndef' + ImgEnd + AlignCenter), 'M-DerenoBook': (PageStart + ImgStart + 'xlinkpanelderenodefau' + ImgEnd + AlignCenter), 'M-PayiferenBook': (PageStart + ImgStart + 'xlinkpanelpayiferende' + ImgEnd + AlignCenter), 'M-TetsonotBook': (PageStart + ImgStart + 'xlinkpaneltetsonotdef' + ImgEnd + AlignCenter), 'NegilahnJournal': (PageStart + xJournalContents), 'LIBMinkataBook': (PageStart + ImgStart + 'xlinkpanelminkatadefa' + ImgEnd + AlignCenter), 'LIBJalakBook': (PageStart + ImgStart + 'xlinkpaneljalakdefaul' + ImgEnd + AlignCenter), 'DniLinkingBookToGrsn': (PageStart + ImgStart + 'xlinkpanelgarrisondef' + ImgEnd + AlignCenter), 'BahroRockBook': (PageStart + ImgStart + 'xlinkpanelcitygreattr' + ImgEnd + AlignCenter), 'DniLinkingBookToGZ': (PageStart + ImgStart + 'xlinkpanelgrtzerolink' + ImgEnd + AlignCenter), 'EderTsogalLinkBook': (PageStart + ImgStart + 'xlinkpaneltsogarden-0' + ImgEnd + AlignCenter), 'EderDelinLinkBook': (PageStart + ImgStart + 'xlinkpanelederdelinde' + ImgEnd + AlignCenter)}


And this is the code for IopenBook =

Code: Select all
def IOpenBook(self, ageBook, bkPages = None):
        global ourBook
        global bkLinks
        print ('%s: IOpenBook: Page(s) requested %s' % (self.__class__.__name__,
         bkPages,))
        if (type(bkPages) == type(None)):
            print 'ERROR: no pages defined'
            return
        if (not (ageBook in modPageDefs.AgeBooks)):
            print ('ERROR: Definition %s does not exist in AgeBooks' % ageBook)
            return
        bkParams = modPageDefs.AgeBooks[ageBook]
        (bkCover, bkFont, startOpen, forceOwned, bookGUI, width, height,) = bkParams
        PageDef = (bkCover + bkFont)
        if (not startOpen):
            if (not self.IsThereACover(PageDef)):
                print 'Warning: Missing cover, forcing book open'
                startOpen = 1
        PageCount = xLinkingBookDefs.kFirstLinkPanelID
        bkLinks = []
        for bkPage in bkPages:
            if (not (bkPage in modPageDefs.LinkDestinations)):
                print ('Warning: %s skipped, definition does not exist in LinkDestinations' % bkPage)
                continue
            pgParams = modPageDefs.LinkDestinations[bkPage]
            (bkAge, spawnPoint, spTitle, linkRule,) = pgParams
            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 %s, link destination %s' % (bkPage,
                 bkAge,))
                if (type(bkAge) != type(None)):
                    t = (PageCount,
                     bkPage,
                     bkAge,
                     spawnPoint,
                     spTitle,
                     linkRule,)
                    bkLinks.append(t)
                    PageDef = ((PageDef + (modPageDefs.BookPages[bkPage] % PageCount)) + '<pb>')
                else:
                    PageDef = ((PageDef + modPageDefs.BookPages[bkPage]) + '<pb>')
                PageCount = (PageCount + 1)
            else:
                print ('No owner of age %s so we are not showing %s' % (bkAge,
                 bkPage,))

        if (PageCount == xLinkingBookDefs.kFirstLinkPanelID):
            print 'No pages created...'
            return
        else:
            TotalCount = (PageCount - xLinkingBookDefs.kFirstLinkPanelID)
        print ('%d item(s) created, linking page(s): %d' % (TotalCount,
         len(bkLinks),))
        PageDef = PageDef[:-4]
        ourBook = ptBook(PageDef, self.key)
        ourBook.setSize(width, height)
        ourBook.setGUI(bookGUI)
        ourBook.show(startOpen)
You can't stop the truth. IC Blog
User avatar
GPNMilano
 
Posts: 1155
Joined: Mon Apr 21, 2008 5:50 am

Re: Pythons Driving me nuts!

Postby D'Lanor » Sat Jun 21, 2008 2:02 am

You probably know this already but the linking panel texture must be either in the age you link from or in a global page. And of course the texture name should be exactly as it is in that prp file. Which may be different than what it was in Blender due to truncation or whatever. You really don't want to take a guess at it. Not if you know how to look into prp files.

Since you seem to be using MOUL ages your panel should probably be in your own age. Either that or you have to find a way to put it in GUI_District_BkBookImages.prp (which should be a nice challenge). Even if the age was both in MOUL and CC the actual texture name may be different. Cyan has a tendency to rename stuff between releases (which btw is how they broke the MOUL 1st month shirt).

About the tuple error, looking at the code in your PM I notice that you removed the nested listing from the bookPages variable. It should be like this:

Code: Select all
bookPages = [['book1'], ['book2a', 'book2b'], ['book3']]
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron