-
Notifications
You must be signed in to change notification settings - Fork 6
Examples and your mod development
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.
-
Open the directory of your Arma mod (Pythia assumes you have a mod, because you need to have a place to call the SQF from, anyway).
-
Create a directory that will hold your python code; its name doesn't really matter, but let's name it
python_code
for this example. -
Create a
python_code\$PYTHIA$
file and put your module name inside. Again, let's assumesamplemodule
as the file contents, for this example. -
Create a
python_code\__init__.py
file and put your code there. This works as a regular python package so you can also add other files there, your can import them, etc... -
Run Arma with
-mod=@Pythia;@MyAwesomeModule
(or you can just enable them in the launcher, instead) -
Call your python code from the debug console, by typing:
["samplemodule.sample_function", ["first", "second", 3]] call py3_fnc_callExtension)
This will open the directory @MyAwesomeModule\python_code\
, load the package there, by loading __init__.py
, and internally name it samplemodule
, call the python function sample_function("first", "second", 3)
and return the
value returned by that function to SQF.
To sum up, this is how your directory structure should look like:
@MyAwesomeMod/
├── Addons/ # (...)
└── python_code/ # Can be named however you want; you can have more than one
├── $PYTHIA$ # Contains the name of your python package, for example: samplemodule
└── __init__.py # Contains the function called (or imports other files)
In __init__.py
:
def print_args(*args):
return_string = 'Received args: {}'.format(args)
return return_string
In SQF:
["samplemodule.print_args", ["First", "Second", 3]] call py3_fnc_callExtension
Result: "Received args: ('First', 'Second', 3)"
In __init__.py
:
def get_multiples(multiplier, count):
return [i * multiplier for i in range(count)]
In SQF:
["samplemodule.get_multiples", [3, 6]] call py3_fnc_callExtension
Result: [0, 3, 6, 9, 12, 15]
You can access additional and more up to date examples here: https://github.com/overfl0/Pythia/tree/next/examples