How do I convert the module to script?
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.