problem to access property

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

mbibim
Posts: 11
Joined: Thu Apr 10, 2003 11:57 pm

problem to access property

Postby mbibim » Fri Apr 11, 2003 12:01 am

hello

I'm using gameblender in blender 2.25 to create a game and I'm trying to access the property (created in the F8 menu) of an object in python script but I can find the associated method.
Actually I can find my object:

ob = Object.Get("obj")

and after I don't find his properties. So if someone knows how I can solve my problem...

thank

bi²

guzzloid
Posts: 2
Joined: Fri Apr 11, 2003 6:04 pm

Postby guzzloid » Fri Apr 11, 2003 6:14 pm

:? I'm also trying to do the same thing, but no luck so far. As far as I can tell, you either can't do it (surely not!) or those properties are hidden away somewhere less-than-obvious (surely not! ;-))

Although I'm not using any of the interactive game features, I thought these properties would be a good way of assigning arbitrary properties for object's propeties/physics for use by import/export filters for features not supported in blender (but used in my own opengl programs). However, if I can't find out how to access these in Python...

eeshlo
Posts: 132
Joined: Wed Nov 06, 2002 10:02 pm

Postby eeshlo » Mon Apr 14, 2003 10:20 pm

You can't access the game objects with the Blender module, you have to use the GameLogic module instead:

Code: Select all

import GameLogic

ow = GameLogic.getCurrentController().getOwner()
print dir(ow)


add an always sensor to your object and connect a Python controller, set it to the script containing this code, when you run the game engine it will print out all properties for that object, see the game engine documentation for further info.

mbibim
Posts: 11
Joined: Thu Apr 10, 2003 11:57 pm

moteur physique

Postby mbibim » Wed Apr 16, 2003 10:52 am

ok! but the GameLogic module doesn't exist under Blender 2.25. So where can I get ?

thanx bi²

eeshlo
Posts: 132
Joined: Wed Nov 06, 2002 10:02 pm

Postby eeshlo » Wed Apr 16, 2003 10:01 pm

The GameLogic module IS available in 2.25, only 2.26 has a disabled game engine. Did you try to run it by using the alt-p key? This won't work, the GameLogic module is only available while running the game engine.
The elysiun forums are a much better place to ask these kinds of questions btw.

mbibim
Posts: 11
Joined: Thu Apr 10, 2003 11:57 pm

Postby mbibim » Thu Apr 17, 2003 1:15 pm

yes!! GameLogic works under 2.25 but not with ALT+p.
But that:

import GameLogic

ow = GameLogic.getCurrentController().getOwner()
print dir(ow)

don't give me an access to my object property.
If someone knows the exact code to access the properties, please send it to me because I'm don't know what to do now.
I've tried to use to documentation but nothing seems to show me how I can do.

thanks for you support.

bi²

eeshlo
Posts: 132
Joined: Wed Nov 06, 2002 10:02 pm

Postby eeshlo » Thu Apr 17, 2003 6:12 pm

That code only prints the functions you can access to change physics properties, mesh data, etc. To print the value of a property you added yourself with logic bricks, you can just use the same code and replace the print statement with something like this:

Code: Select all

print ow.propertyname


where 'propertyname' is of course whatever name you assigned to the property.

Here is a link to other documentation with examples:

http://oldsite.blender3d.org/gameBlenderDoc/book1.html

While old, lots (if not all) is still applicable to the current GameLogic module.

Once again, I point you to the elysiun forums for these kinds of questions, there are lots of example scripts available, and a very active helpful community.


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests