Change my python type from Module to Script? In Blender #game engine
-
$\begingroup$ See blender.stackexchange.com/questions/21403/… and blender.stackexchange.com/questions/10769/… IMO would use module. Can you elaborate on why you wish to change? It will involve editing the script, in which case post the script $\endgroup$ – batFINGER Dec 16 '19 at 9:06
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.