Getting game logic data in file export script?

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
gennoveus
Posts: 0
Joined: Tue Dec 21, 2010 7:13 am

Getting game logic data in file export script?

Post by gennoveus »

Hi

So as far as I understand it, I can only access Blender Game Engine data (i.e. GameLogic) when the game is running.

So what if I need to make an script that exports properties that are available only from the GameLogic module?

specifically, I am after the 'visible' attribute of KX_GameObject. example

Code: Select all

cont = GameLogic.getCurrentController()
obj = cont.owner
 
obj.visible #I want this!
Does anyone know how I can access the GameLogic module from a normal python script (i.e not in game mode)

Alternatively, is there any other way to find out if an object is 'visible?' (where an object is set 'invisible' in the game logic panel)

If it is only possible to access this data while the game mode is running, is it possible to turn the game mode 'on' and 'off' using python script?

Any other ideas are also welcome!

stiv
Posts: 0
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Post by stiv »

So what if I need to make an script that exports properties that are available only from the GameLogic module?
Is there some reason not to simply write the data via python from the running game?

gennoveus
Posts: 0
Joined: Tue Dec 21, 2010 7:13 am

Post by gennoveus »

stiv wrote:
So what if I need to make an script that exports properties that are available only from the GameLogic module?
Is there some reason not to simply write the data via python from the running game?
Yes.

The 3D artists working with me will be creating and exporting hundreds of models. It seems like it will take a large number of steps to get a script running from the the game engine, especially for these guys who are not programmers and do not understand Python.

To the end user, doesn't it seem strange that you can't just click File->Export like everything else?

It seems a very awkward and unprofessional way to tackle the problem. Surely there is some other solution?

gennoveus
Posts: 0
Joined: Tue Dec 21, 2010 7:13 am

Post by gennoveus »

I now have a script running that is exporting what we need ... but here is what the artists have to do:

1) Open up a text file with my script in it.
2) Copy and paste that script into the python text editor.
3) Add a controller to an object in the scene with the python script linked (and a sensor to start it).
4) Start the game engine.
5) Stop the game engine.

It works but it's horribly messy. Also, I loose the ability to use a nice GUI (e.g. Blender.Window.FileSelector) :?

I'm using 2.49 now. Will version 2.5/6 provide any kind of workaround for this?

All this for one bool variable ... :roll:

cesarecf
Posts: 0
Joined: Mon May 16, 2011 5:15 am

succes?

Post by cesarecf »

gennovius, how did you go with that script?? i think i have the same trouble

Post Reply