0
$\begingroup$

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

enter image description here

$\endgroup$
1

1 Answer 1

1
$\begingroup$

Add these two lines at the end of the script:

cont = logic.getCurrentController()
main(cont)

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.

$\endgroup$
1
  • $\begingroup$ Thank you very much! $\endgroup$
    – Koto
    Dec 16, 2019 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .