Change my python type from Module to Script? In Blender #game engine

enter image description here


Add these two lines at the end of the script:

cont = logic.getCurrentController()

The module mode calls specifically the function main through the entry point on the controller, while in the script mode you have to explicitly call the main function on the script. As the main function needs the controller reference, you get the controller and pass to it.

That's how you use a module as a script, however I would seriously recommend you to stick with the module mode: the script mode is A LOT slower than the module mode (as it is parsed at runtime) and the module mode provides much better options on code editing and organization.

  • $\begingroup$ Thank you very much! $\endgroup$ – Koto Dec 16 '19 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.