hy guys ! i made a class and put it in a module, and i’m trying to instance objects of that class inside a script in blender with no succes so far,
for example i have my module objects.py :
class Car :
tokenVariable = "i'm being used to make a point"
the script where i’m trying to use it :
import objects
BMW = objects.Car() # BMW is an instance of the Car class
print "what's your purpose in life ?"
print BMW.tokenVariable
the interpreter is telling me that the module objects has no atribute Car
can anyone tell me how to do this right ? (how to instance objects of a class from a module inside a script)
I found that when you import a custom script, and then make changes to that script and run the game again, the importet script is not updated. To do that, you can put “reload(objects)” under your import line to make it update, but only for development. I’d take it out again when your game is done.
Maybe it helps you, this is how it should look:
import objects
reload(objects)
Oh, and I wouldn’t put a space between the class name and the colon in the definition. I don’t know if it’s allowed or not, but just to be safe.