Getting started

I am using blender 2.48a and I want to learn to script , focusing on the game engine
All the tutorials i see start with
import GameLogic or

however i when I Alt-P to run the script ,even those simple lines , i get
ImportError: No module named GameLogic or
NameError: name ‘GameLogic’ is not defined

Can someone explain what I need to do to get the GameLogic functionality.

you dont execute the scripts with alt+p, but via a python controller logic brick

cyborg is right.

The process is this: Select the object that you want to run the script. Can be the player object, or create an empty if you need someplace for it to go but it’s not specific to an object.

Go to the logic panel in the buttons. It’s the first icon, a little pacman thing.

In the first row, where it says “sensors”, press “add”. Do the same in the second, where it says “controllers”. You should now have an “always” sensor and an “AND” controller.

Change the “AND” controller to a “Python” in the dropdown. Then type the name of your script as it appears in the text editor. Finally, drag from the little yellow dot on the right of the “Always” to the dot on the left of the “Python”.

Hover over any 3D view, and simply press P. Your game, and your script, should run.

I have a bunch of good links to tutorials and resources for GE python if you click on the “resources” link in my sig and then scroll down to the GE and Python sections.