problem import GameLogic

Physics APIs, Physics file formats, Maya, Max, XSI, Cinema 4D, Lightwave, Blender, thinkingParticles™ and other simulation tools, exporters and importers
doramonman
Posts: 2
Joined: Mon Jun 25, 2007 9:12 am

problem import GameLogic

Post by doramonman »

I havd to installed Blender 2.44 and Python 2.5.1 On WinXP sp2.
When Run python Script (Alt+P) Blender cannot import gamelogic in all file.


Image
http://images.forstudent.com/show.php?i ... 6c7d962037

1.py

Code: Select all

# first gamePython script
# gets the position of the owning object
# and prints it on the console

import GameLogic

controller = GameLogic.getCurrentController()
owner = controller.getOwner()

print owner.getPosition()
If I try to "print 'Helloworld' " without line "import" it has no problem

How to Fix this problem?
I must have to install other program?
or how to set path?


:( :( :(
Littlebob
Posts: 9
Joined: Wed Dec 27, 2006 10:17 pm

Post by Littlebob »

GameLogic only works in the game engine not in the blender editor.
YB_Info
Posts: 3
Joined: Thu Jul 17, 2008 5:58 pm

Re: problem import GameLogic

Post by YB_Info »

To answer to your question, I believe that you have a Python version too new.
I would suggest that you switch to Blender 2.46, newest Python.

When testing your script, you should use the Text Editor. Then Run is as a Python script.

Try this and you shouldn't get any errors.
# Some line of Test

import GameLogic #Import what ever, only takes ressources :p

print "I Am GOD!"
With 2.46, while I looked at your script, 1 error was found. You will get an error for getCurrentController()
because it need to be associated in the Logic Bricks (Where the basic Game Engine sensors all begins) since
it needs to return something to associate to the variable. If it doesn't exist, the returned value is not NULL
but an error :D

Sensor - Controller - Attribute
Obj - Python - Movement

Hope this basic info helps.