Important! Please read the announcement at http://myst.dustbird.net/uru-account.htm
Also! Please read the retirement announcement at http://myst.dustbird.net/uru-retirement.htm

Python and Responders: Please Read!

From UamWiki
Revision as of 12:40, 24 January 2011 by AndyLegate (talk | contribs) (Created page with '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 yo…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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:

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: Andy's Max Tutorials