Python, calling other object's properties

I have a character who has a double jump python script so that he can jump twice, but no more. To do that I made a property called jump that decreases by 1 every time you jump and if it is 0, you cannot jump.

I want an animation to be associated with the second jump only, so I wrote a script for the character armature that calls the jump property from the bounding box object (the one doing the jumping) and is set to play if the Jump property reaches a certain value.

My script isn’t working however and I wonder if it has something to do with my sytax? I just guessed that

GameLogic.getController("name of object that has Jump value").getOwner()['Jump']

would call the Jump value from the other object. Is there a different way to do that?

No. Where did you find that code?

You call object properties like this:


cont = GameLogic.getCurrentController()
own = cont.owner

jump = own["Jump"]

I think you mean that:


GameLogic.getCurrentScene().objects["OB+name of object that has Jump value"]['Jump']

@social
I wrote the code. That’s what I meant by “I guessed”. I had no idea if the syntax was correct. The code you suggested gets the object property ‘Jump’ from the object that the script controller is attached to. I am trying to call an attribute from a different object. Thanks for the reply though!

@Monster
Thanks! That looks like what I am looking for. However when I plugged it in, the console comes back with "AttributeError: ‘bulitin_function_or_method’ object has no attribute ‘objects’
Any ideas?

EDIT: Nevermind. I guess it didn’t like having

GameLogic.getCurrentScene().objects["OBname"]['Jump']

all on the same line.
I just seperated it into 2 lines and it worked just fine o_O