Python and Responders: Please Read!

From OpenUru
Jump to: navigation, search

If you are using Python files to make things happen in your Age (and you more than likely will if you want puzzles, and neat actions to happen), then it is very IMPORTANT that you remember to have your responders that you have Python run to notify Python that they are done.

Basically what is happening is your python file will have something in it that has a responder run, say like this clip here:

    def OnNotify(self, state, id, events):
        global avatarEntering
        if (id ==
            if (PtFindAvatar(events) != PtGetLocalAvatar()):
            print ' must have ki'
            kiLevel = PtGetLocalKILevel()
            if (kiLevel < 2):
            for event in events:
                if ((event[0] == 1) and (event[1] == 1)):
                    avatarEntering = PtFindAvatar(events)
                    print "entered the region, disable this one and the other door's triggers"
                    if (avatarEntering == PtGetLocalAvatar()):
                        print 'stop this avatar'
                        print 'take away first person'
                        cam = ptCamera()
                        PtSendKIMessage(kDisableEntireYeeshaBook, 0)
                    print 'open the door'
          , avatar=avatarEntering)

        if (id ==
            if (avatarEntering != PtGetLocalAvatar()):
            print ' door is open, walk in'
            avatarEntering.avatar.runBehaviorSetNotify(behaviorWalkIn.value, self.key, behaviorWalkIn.netForce)

In this clip, the Avatar is going to be stopped, and commands to it disabled. My door responder is going to be told by python to run.

This python file is the "trigger" for that door responder. If it does NOT tell the Python file that it's done, you will end up with nothing else happening (I know, I went down this road, wondering why after the door opened nothing else was happening!).

All you need to do is add this to the end of your responders that are being controlled by Python:


You may want to make sure you tell it to wait until the previous command is finished too.

This is the responder saying "Hey Python File! I'm done! You can go do your next thing!"

Return To: 3DS Max Plugin Tutorials

Copyright (C) 2011 Andy Legate.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU Free Documentation License".