Pictures in Journals

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

Postby Aloys » Mon Oct 23, 2006 2:24 pm

Bump. I'm afraid I cannot find a way to get out of the book GUI. The uam.showBook API call works well to bring up the book but how to get out of it?
User avatar
Aloys
 
Posts: 1968
Joined: Sun Oct 21, 2007 7:57 pm
Location: France (GMT +1)

Postby Robert The Rebuilder » Tue Oct 24, 2006 6:17 am

Aloys:

Download Dustin's second age from Zib's new UAM server. Here's the direct link:

http://tomatoshard.servegame.org:8081/fanages/111v1/

Decompyle the PAK file and look at how Dustin dismisses the book.
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

Postby Aloys » Tue Oct 24, 2006 7:35 am

I've looked at that code (and other Ages code) and I still don't see what I am doing wrong. The main difference is that I try to make a 'true' clickable using a click region and clickfile object property associated with this code:

"def OnNotify(self, state, id, events):
if (ObjectMsg.value == 'BookObject'):
uam.output('AAAAA: showing journal')
uam.showBook('PBML Journal', self.key)

(taken from FuncChk01Clickables.py and adjusted)

While previous Ages all use the 'controlKey and uam.isObjectInRange' method which isn't a 'true' clickable, as it is based on object proximity and doesn't result in having the cursor change when going over the object.
User avatar
Aloys
 
Posts: 1968
Joined: Sun Oct 21, 2007 7:57 pm
Location: France (GMT +1)

Postby Robert The Rebuilder » Tue Oct 24, 2006 10:53 am

Aloys:

The trick is to hand the notify back to uam, so that it can detect the click on the outside of the book. So, all you need to do (I believe) is to add the following line right at the top of your OnNotify() function:

Code: Select all
uam.handleNotify(state, id, events)


Let me know how this goes.
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

Postby Aloys » Tue Oct 24, 2006 11:27 am

Unfortunately that doesn't work.

I don't know if that's any help but the python log says this:

Code: Select all
(10/24 20:20:05) AAAAA on first update
(10/24 20:20:05) AAAAA on first update
(10/24 20:20:05) AAAAA on serverinitcomplete
(10/24 20:20:05) AAAAA on serverinitcomplete
(10/24 20:20:08) AAAAA on OnNotify 1
(10/24 20:20:08) AAAAA on OnNotify -1
(10/24 20:20:08) AAAAA on OnNotify 1
(10/24 20:20:08) AAAAA on OnNotify -1
(10/24 20:20:08) AAAAA on OnNotify -1
(10/24 20:20:08) AAAAA on OnNotify -1
(10/24 20:20:08) AAAAA on OnNotify -1
(repeat OnNotify -1 several times a second until I quit Uru)


And right now the full python code looks like this.
User avatar
Aloys
 
Posts: 1968
Joined: Sun Oct 21, 2007 7:57 pm
Location: France (GMT +1)

Postby Robert The Rebuilder » Tue Oct 24, 2006 12:12 pm

Thanks for providing the code, Aloys. I noticed that there needed to be a check for whether the id that was passed in matched the actClickableObject argument passed in for the python hook. So, I modified the code to look like this:

Code: Select all
from Plasma import *
from PlasmaTypes import *
from UruAgeManager import *
from xPsnlVaultSDL import *
actClickableObject = ptAttribActivator(1, 'Act: Clickable Object')
ObjectMsg = ptAttribString(2, 'Object String')

# Note: Change all "ptResponder" to "ptModifier" for a Modifier class

class aaaaa(ptResponder):
    __module__ = __name__

    def __init__(self):
        ptResponder.__init__(self)
        self.id = 106001  # Must be a unique ID of the form: AAASSS Where AAA is the Age Sequence prefix and SSSS is any ID number that's unique among the Age's scripts
        self.version = 1 # ???

    def OnFirstUpdate(self):
        print 'AAAAA on first update'

    def OnServerInitComplete(self):
        print 'AAAAA on serverinitcomplete'

    def OnNotify(self, state, id, events):
        uam.handleNotify(state, id, events)
        #print 'AAAAA on OnNotify',
        #print id
        if (id == actClickableObject.id):
            if (ObjectMsg.value == 'BookObject'):
                uam.output('AAAAA: showing journal')
                uam.showBook('PBML Journal', self.key)

                
    def OnSDLNotify(self, VARname, SDLname, playerID, tag):
        print 'AAAAA SDL notify.'

    def OnTimer(self, id):
        print 'AAAAA Timer update',
        print id
 


I commented out the OnNotify print statements because those will just fill up your logs, as you've already noticed. I also replaced the tabs with whitespaces; sometimes Python gets persnickety about that.

So, let me know how this goes; if not, we'll try something else.
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

Postby Aloys » Tue Oct 24, 2006 2:59 pm

That did the trick! :D
Thanks a lot for your help, I wouldn't have been able to do that alone. (I guess I should eventually get some python documentation)

Now I'm able to complete this tutorial I mentionned earlier so that other python illiterates like me can easily implement clickable journals..


[edit]
I also replaced the tabs with whitespaces; sometimes Python gets persnickety about that.

Yah I noticed that lately :rolleyes:
User avatar
Aloys
 
Posts: 1968
Joined: Sun Oct 21, 2007 7:57 pm
Location: France (GMT +1)

Previous

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests