[Solved] Python error: can't import Plasma

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

[Solved] Python error: can't import Plasma

Postby Sirius » Fri Dec 16, 2011 5:46 am

Hi everyone, I'm having an error in a Python script.
Code: Select all
(12/11 14:26:34) Traceback (most recent call last):
(12/11 14:26:34)   File "C:/Documents and Settings/User/Desktop/Python/tmp/xTestCam.py", line 5, in ?
(12/11 14:26:34)     from Plasma import *
(12/11 14:26:34) SystemError: NULL result without error in PyObject_Call
(12/11 14:26:34) Python file xTestCam.py was not found.
As you can see, it seems the file fails importing the Plasma API. However, this file is used 4 times in the whole Age, and the three other files work correctly (sometimes two files fail and the two others run correctly). The PythonFileMod are almost the same, the only possible problem might be that out of the 4 sceneobjects with a PythonFileMod, 3 have the same name but in separate PRPs.

I don't think it is a scripting error, as the error occurs before the class inheriting the ptResponder.
Here is a part of the script:
Code: Select all
global glue_cl
global glue_inst
global glue_params
global glue_paramKeys
from Plasma import *
from PlasmaTypes import *
from PlasmaKITypes import *
## attributes

class xTestCam(ptResponder):
    # stuff

# Python glue (the one you have when creating a new Python file in PlasmaShop).
Any thoughts ? Thanks.
Last edited by Sirius on Wed Feb 08, 2012 7:25 am, edited 1 time in total.
User avatar
Sirius
 
Posts: 1113
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Python error: can't import Plasma

Postby tachzusamm » Fri Dec 16, 2011 12:11 pm

Mhh, that's not really a script that does anything.

Why do you declare glue_cl and the other glue vars as global, in a scope (your script's global scope) that already IS global ?
Declaring them as global should be necessary only in a function's body.
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Python error: can't import Plasma

Postby Jojon » Sat Dec 17, 2011 4:54 am

Other than the reapeated object name, which sounds well worth checking out, I believe any periods in a name may throw the parsing. (I.e: myObject_001 will work, but not myObject.001)

Do we want to know, yet (i.e: spoilers?), what you are doing? :)
Alternative versions of objects perhaps? Something like the relativity age? :7
Jojon
 
Posts: 1116
Joined: Sun Sep 30, 2007 5:49 am

Re: Python error: can't import Plasma

Postby diafero » Sat Dec 17, 2011 5:38 am

I would indeed avoid using the same object name in different prps of the same age... at least, functions like PtFindSceneobject will go crazy, and maybe others, too.
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
diafero
Deep Island Admin
 
Posts: 2803
Joined: Mon May 05, 2008 5:50 am
Location: Germany

Re: Python error: can't import Plasma

Postby Sirius » Sat Dec 17, 2011 6:27 am

Ok, I'll try that. I would definitely not put two objects with the same name in the same Age, but I'm still editing one of Cyan's PRP (nope, nothing like Relativity). I don't really understand why they didn't rename it in sceneobject01, sceneobject02 etc.

PtFindSceneObject should simply return the first object it finds. And Plasma seems to supports "#", "@" or even "~" (at least on objects without regions, responders, etc), which is not the case of the objects I'm working on.

tachzusamm wrote:Why do you declare glue_cl and the other glue vars as global, in a scope (your script's global scope) that already IS global ?
Declaring them as global should be necessary only in a function's body.
Well, Cyan's Python files decompiled with Drizzle often does, and I didn't remove it in this script (I often copy one of these files to start my new script from it, even though using the default file from PlasmaShop would be the same).

Well, I guess I better change the names. It's just a bit long to change it in the SceneNode, and then delete the old object if I'm not even sure it will fix it.


EDIT:
I figured out what was wrong: Plasma CAN handle ANY object names, but it WON'T let you link a Python File Mod to it if the name has any special character or is already used.
It won't even accept "thingy.something" because of the dot !
User avatar
Sirius
 
Posts: 1113
Joined: Mon Jul 26, 2010 4:46 am
Location: France


Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests