In Memoriam: Tai'lahr

OpenUru.org, along with the rest of the Mystonline community, is mourning the loss of Tai'lahr on October 16th, 2019.

Rest in Peace, friend.

Python and Responders: Please Read!

From OpenUru
Jump to navigation Jump to 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 == triggerRgn1.id):
            if (PtFindAvatar(events) != PtGetLocalAvatar()):
                return 
            print ' must have ki'
            kiLevel = PtGetLocalKILevel()
            if (kiLevel < 2):
                return 
            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"
                    triggerRgn1.disable()
                    triggerRgn2.disable()
                    if (avatarEntering == PtGetLocalAvatar()):
                        print 'stop this avatar'
                        PtDisableMovementKeys()
                        print 'take away first person'
                        cam = ptCamera()
                        cam.disableFirstPersonOverride()
                        cam.undoFirstPerson()
                        PtSendKIMessage(kDisableEntireYeeshaBook, 0)
                    print 'open the door'
                    door1OpenResponder.run(self.key, avatar=avatarEntering)
                    return 

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

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:

http://assets.openuru.org/wiki/andy/MaxTutPics1/notifytrig.jpg

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".