Skip to content

Examples and your mod development

Lukasz Taczuk edited this page Sep 30, 2022 · 3 revisions

Running

Run Arma 3 with -mod=@Pythia.

In SQF (debug console), execute:

["pythia.test"] call py3_fnc_callExtension

This should reply with a OK hint message, if Pythia is working correctly. If it doesn't, ensure you've disabled BattlEye.

["pythia.ping", ["first", "second", 3]] call py3_fnc_callExtension

This should echo back all the arguments you're passing to the function.

In general, to call a custom (non-internal function), do the following:

["python.samplemodule.sample_function", ["first", "second", 3]] call py3_fnc_callExtension)

This will open the directory Arma 3\python, load the file samplemodule.py, call the python function sample_function("first", "second", 3) and return the value returned by that function to SQF.

Of course, you first need to create such a file.

Examples:

In samplemodule.py:

def print_args(*args):
    return_string = 'Received args: {}'.format(args)
    return return_string

In SQF:

["python.samplemodule.print_args", ["First", "Second", 3]] call py3_fnc_callExtension

Result: "Received args: ('First', 'Second', 3)"


In samplemodule.py:

def get_multiples(multiplier, count):
    return [i * multiplier for i in range(count)]

In SQF:

["python.samplemodule.get_multiples", [3, 6]] call py3_fnc_callExtension

Result: [0, 3, 6, 9, 12, 15]

Additional examples

You can access additional and more up to date examples here: https://github.com/overfl0/Pythia/tree/next/examples

Clone this wiki locally