Basic Python Object Help

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Quote from Mathias

    Using the extension should be straight forward, and shouldn't really require documentation

    Well, apparently I'm not smart enough to pick it up myself. Luckily then, I'm fine with looking stupid and asking questions!

    Running Python files works wonderfully, I'm very much enjoying that control. What I don't know how to do yet is run a function (with arguments) and get the return value in MMF2.

    So what events/actions do I need to run this function from the python file:

    Code
    # echo.py
    def echo(string):
        return string

    Cheers.

    Making games at Please login to see this link..
    Please login to see this link. on Twitter.

  • Well, have a look at the example file "python_functions.mfa". Basically, you can either register the function, or call it by name:

    Code
    import interface
    
    
    @interface.register('echo')
    def my_echo_function(string):
        return string
    
    
    def echo(string):
        return string

    and in your MFA, first run the script, then add a string argument (Add parameter String$("Python object", "Hi!")), then call either the registered function (Call registered function "echo") or the global function (Call global "echo"). To get the return value, you simply do StringValue$("Python object", Return( "Python object", 0)), and that's about it ;)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!