Results 1 to 2 of 2

Thread: Python Trouble

  1. #1

    Python Trouble

    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 i was following this video '' (to give you and idea of what i am trying to do)i really need help

  2. #2
    Moderator Monster's Avatar
    Join Date
    Jan 2006
    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 "".

    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 (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"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts