Python to Funky Trees Mini Compiler by Whills
PYtoFT converts variables in a Python script into condensed, single-line functions compatible with the SimplePlanes / SimplePlanes2 Funky Trees system.
The tool can:

[!CAUTION]
- It is not recommended to use this tool unless you are familiar with the basics of Python and how Funky Trees work in SimplePlanes.
- Incorrectly written Python code may result in conversion errors or unexpected in-game behavior. Use this tool at your own risk.
Install Python 3 and download or clone this project
Run:
python _PY_to_FT.py
Full working demo script: demo script
Demo airplane XML: Pyphoon demo plane
from lib.FT_functions import * # import built-in Funky Trees functions and variables.
main_loop_name = "_process" # the name of the main function
exclude = ["exported_var"] # list of variable names to be excluded from the conversion,
# you may need to add some aircraft-part-exported variables here.
# ========== program start ==========
# optional: declare your global variables
my_global_var = 1.0
exported_var = False
# main loop function: the control logic in this function will be executed once every frame in game.
# all variables declared inside this function + all global variables will be converted to in-game variables.
# you can also do not write this function, then only global variables will be converted.
def _process() -> None:
global my_global_var
global exported_var
simple_var = 2000.0
if my_global_var:
if IAS > exported_var:
another_simple_var = foo(simple_var)
else:
another_simple_var = 0
else:
another_simple_var = -1
# below are helper functions, make sure all functions have return values in all cases.
# it's not recommended to call other helper functions inside helper functions.
# default argument values are *NOT* supported and do *NOT* use recursion!
def foo(some_value) -> float:
input_val = some_value
if Altitude > 200:
input_val += 2
else:
input_val -=2
result = input_val + bar()
return result
def bar() -> float:
if IAS > 10:
return 5
else:
return 0
The script above can be converted to the following XML code:
<Setter variable="my_global_var" function="1.0" priority="0" />
<Setter variable="simple_var" function="2000.0" priority="0" />
<Setter variable="another_simple_var" function="(my_global_var ? ((IAS > exported_var) ? (((Altitude > 200) ? (simple_var + 2) : (simple_var - 2)) + ((IAS > 10) ? 5 : 0)) : 0) : -1)" priority="0" />
[!NOTE] This tool can only convert simple functions. The following Python features are not currently supported:
- Classes
- Recursion
- Default arguments
If you want to reconfigure the directory of your target output folder, you can delete _PY_to_FT_config.json and run the application again.
[!CAUTION] Always backup your
.xmlcraft file before running the conversion. The conversion will overwrite ALL Funky Trees codes you have already written in game in Variable Setters.
I hope you find this tool useful. In the future, it would be interesting to support the conversion of other popular languages (such as C#, Java, or JavaScript) into Funky Trees; however, this is currently beyond the scope of my skills.
I may also pursue future updates to expand support for additional Python features.
If you find this work useful, any amount of support would be appreciated: Patreon
This project is licensed under the GNU General Public License v3.0 (GPL-3.0-or-later).