when working with the Global Dictionary i ran in to a problem where when i have " print(bge.logic.globalDict[‘call’])" it does not show up but instead gives me " Python module can’t be imported - object ‘Cube’, controller ‘Python’:ImportError: No module named ‘Call’" untitled.blend (455 KB) i was following this video ‘https://www.youtube.com/watch?v=-zXenoSa4V4’ (to give you and idea of what i am trying to do)i really need help
First of all you do not need “main()”. This is bad style (yes the templates are bad style). It adds complexity without providing any benefit. It makes not even sense.
Better use a descriptive name that expresses what you want to do. As I do not know you intention I call it “demonstrateStoring”. i’m sure you know what you want to achieve - so you can come up with a better name ;).
The same applies to the module name. A good name let the reader guess what it contains (or what it is good for). Again, I do not know you intentions. I simply guess you want to store things. So storage would be a good name.
Du to naming conventions the file needs the .py extension. So we come up with “storage.py”.
Here is where you error is coming from: You told the BGE to call “main(controller)” of module “Call”. But there is no module “Call” due to there is no file Call.py (you forgot the .py).
I suggest to use it that way:
import bge def demonstrateStoring(): bge.logic.globalDict["call"] = "hero" print( bge.logic.globalDict["call"] )
You configure your Python controller with “storage.demonstrateStoring”