Importing scripts in GameEngine (Blend and Runtime)

Hello.

I have problem importing my own scripts in GameEngine in Blender 2.44 on Ubuntu 7.10.

I want to initialize some objects in the “GameSetup” script launched ones in the beginning. Classes are defined in other py files ( I have created them in blender text editor), but non of them (scripts or modules?) imports. For example:

PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File “GameSetup”, line 5, in <module>
ImportError: No module named ActionSay

I have tried “import ActionSay”, "from ActionSay import * " , “… ActionSay.py” and so on.

It has worked somehow some time ago thought, so I am quite frustrated now :spin:.

Thanks in advance.

Talkless, to get external scripts to work on Linux, you must start Blender from the directory that the .blend is in.

If you are using Blender that you got from the Ubuntu repositories, then you can launch it from the terminal with the command “blender-bin” or “blender”. Open a terminal window and navigate to the directory the .blend is in, then launch blender using one of those commands. Your game should now be able to find the external scripts.

If you are using a newer version of Blender than what is available from the repositories, and you have not installed it to your /usr/bin directory, then follow these instructions:

Open a Terminal window and navigate to the folder where the new version of Blender is resident. Enter the following commands (change the numbers 245 to whatever version you are using):

cp ./blender blender245
cp ./blenderplayer blenderplayer245
sudo mv ./blender245 /usr/bin
sudo mv ./blenderplayer245 /usr/bin

Now you should be able to launch the new version from the terminal. Here’s an example from work I was doing today on a .blend that uses external files:

tony@HomePC:~/Projects/MyBlends/Sokoban$ blender245 sokoBase1114.blend

Thank you blendenzo very much for the great replay!

It definitely worked (I used changing working directory trick).

I have a new problem with Runtime version now (running from blend works fine).

Here’s some console output:

vincas@vinco-linux:~/blender/sea_game$ ./sea_game
guessing ‘./sea_game’ == ‘/home/vincas/blender/sea_game/./sea_game’

GameInit.py
PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File “GameInit.py”, line 5, in <module>

ImportError: No module named GLSL_Water

So no GLSL_Water.py is found, though it is in the same directory as Runtime file. You can see no-water-like water as GLSL shader is not loaded.

http://www.4shared.com/file/33794967/b605533f/sea_game_2008-01-03.html - it’s full project with blend, scripts, textures and LINUX x86 runtime.

Have any suggestions?

Thanks.

same here

thanks brothers …

Dude, thats a pretty good water shader. Thanks for sharing!

Edit: Nevermind… I spoke too soon. Still looking into it.

Have a fun.

Though it’s not good with z waving - it flickers a bit as you move camera. Sin’s for height calculation used improperly. I should use heighmap texture color instead of coordinates, but sampler2D doesn’t work for me in vertex shader. But that’s question for another thread…

Hi! I’m having the same ImportError problem. Though it’s for PyGame. I was wondering if anyone found a solution to this thing already as I might try it to fix my issue.

Here’s the thing:
If I open Blender and have “import pygame.mixer” in my script, it works.
Outside of Blender, in the Python console, “import pygame.mixer” works as well.
But when I do “./theBlendRuntime” or “blenderplayer myblend.blend”, I get the ImportError.

Help please? :smiley: