Page 1 of 1

problem import GameLogic

Posted: Mon Jun 25, 2007 10:42 am
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?


:( :( :(

Posted: Wed Jun 27, 2007 7:04 pm
by Littlebob
GameLogic only works in the game engine not in the blender editor.

Re: problem import GameLogic

Posted: Thu Jul 17, 2008 6:12 pm
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.