Chapter 5

Python Modding

All the game logic in Fleshcult is written in Python, the .py files inside fleshcult.nut. While you could edit Python code in Notepad or something, I strongly recommend setting up a specialised tool like PyCharm or VS Code.

Teaching Python programming is outside the scope of this guide, but I’ve tried to stick to basics, so beginners can poke and prod at the example code and learn by doing.

What it looks like

def on_revolution(self):
    for romanov in self.romanovs:
        if romanov.tsarist:
            romanov.revolve(180.0)
        else:
            pass  # yeah right

Language Reference


Fleshcult-Specific Stuff

Entry Point

When your mod is loaded, the game checks for a __init__.py file (note: double underscores, not single) in the root of the mod folder. When it’s enabled or disabled it’ll try to run these functions:

def init():
    pass

def deinit():
    pass

Importing from inside a mod

To refer to things in the Fleshcult source code from your mod, you’ll need to import them first.

# Import functions from Constant.py in fleshcult code
from faust.Constant import get_constant, del_constant

# Import from another file inside the same mod
from . import ArmpitDefinition

Next Steps