Skip to main content

Madagascar Asset Tools

Python >= 3.12

Loads .stream .dff .txd .bsp .txl .rws .lpa

madkit is a collection of tools for modding the game "Madagascar" (released in 2005): a CLI to unpack, repack and build mods for the game's level files, plus viewers for streams and textures.

Contents

Requirements

Getting started

1. Create a modding folder

Make a folder for your mods with its own virtual environment, and install madkit and madlysimple into it:

mkdir my-madagascar-mods
cd my-madagascar-mods
python -m venv .venv

# WINDOWS:
.venv\Scripts\activate
# LINUX/MACOS:
source .venv/bin/activate

pip install madkit madlysimple

madkit is the CLI and tools, madlysimple the helpers you use in your mod scripts.

The environment stays active until you close the terminal. In every new terminal, cd into your modding folder and run the activate line again before using madkit.

To update later: pip install --upgrade madkit madlysimple.

2. Copy the stock levels

Mods are built from the original .stream level files. Copy the game's Levels/ folder into your modding folder:

my-madagascar-mods/
  .venv/
  Levels/          # copy of <game folder>/Levels, never modified

3. Configure madkit

Tell madkit where the game is installed (once):

madkit config --game-dir "C:/Games/Madagascar"

This writes a settings.toml in the current folder, so run madkit from your modding folder. Use --levels-dir if your stock levels are somewhere other than Levels/.

Mods

Create a mod:

madkit mod init my_mod --level kingofny

This creates:

mods/my_mod/
  mod.toml      # name, description
  build.py      # @level(...) functions
  assets/       # files the mod imports (.AI scripts, textures, ...)

Each @level function receives the named levels, loaded from Levels/<level>.stream. After all functions ran, every level they received is saved to mods/my_mod/build/<level>.stream.

from pathlib import Path

from madformats.mod import level
from madformats.stream import RW_StreamFile

ASSETS = Path(__file__).parent / "assets"

@level("kingofny")
def gold_coins(kingofny: RW_StreamFile) -> None:
    kingofny.assetByName("DG_Coin_Collectable.AI").importFrom(ASSETS / "scripts/DG_Coin_Collectable.AI")

@level("kingofny")          # stacked: runs once per level
@level("kingofny_regen")
def bigger_coins(lvl): ...

@level("street", "kingofny")  # several names: one call with all levels
def alex_to_marty(street, kingofny): ...

Build it, or build it and copy the levels into the game:

madkit mod build my_mod     # -> mods/my_mod/build/
madkit mod install my_mod   # build + copy into <game folder>/Levels

Back up the game's Levels/ folder before installing mods, so you can restore the originals.

CLI

madkit unpack LEVEL.stream output/directory/

madkit repack input/directory/ LEVEL.stream

For more information run

madkit --help
madkit COMMAND --help

Tools

GUI tools are run as modules:

python -m madkit.tools.stream LEVEL.stream   # stream viewer
python -m madkit.tools.txd FILE.txd          # texture viewer
python -m madkit.tools.analyze FILE          # RenderWare file viewer
tfbeditor                                    # TfbPseudo AI script editor

Development

To work on madkit itself you need uv. Clone the repository and install the whole workspace:

git clone https://github.com/MaxStache/madagascar-game-asset-tools.git
cd madagascar-game-asset-tools
uv sync

The repository is a uv workspace with these packages, all installed in editable mode:

Package Path Import
madkit (CLI + tools) src/madkit/ madkit.cli, madkit.tools.*
madformats (file formats) packages/madformats/ madformats
madlysimple (modding helpers) packages/madlysimple/ madlysimple
tfbpseudo (AI script compiler + editor) packages/tfbpseudo/ tfbpseudo
tfbscript (.ai parser/decompiler, tfbtool) packages/tfbscript/ tfbscript

Each package under packages/ has its own pyproject.toml and is published to PyPI on its own.

License

Apache-2.0. See LICENSE.

Disclaimer

Unofficial fan project, not affiliated with or endorsed by DreamWorks, Activision or Toys for Bob. No game assets are included, you need your own copy of the game.

Metadata

Release files for madkit 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for madkit 0.1.5
File Size Uploaded Provenance
madkit-0.1.5.tar.gz 47.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for madkit 0.1.5
File Interpreter ABI Platform
madkit-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 107.6 kB

Release files / madkit-0.1.5.tar.gz

Download URL madkit-0.1.5.tar.gz
Size 47.8 kB
Tags Source
SHA-256 checksum
How to use checksums
60945d0c6d87a9690c265702121c82956a52ad6c899858590a009e66e7c5214e
BLAKE2b-256 checksum
How to use checksums
d2d19fafb14bc8c61fc29fc3ce255bbb8c89f6f8818d6d544a4fa0cf18f7293a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / madkit-0.1.5-py3-none-any.whl

Download URL madkit-0.1.5-py3-none-any.whl
Size 59.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c50817e815659e3dced09299e26d7a4d2b3c220e32eba5522067034cd565450d
BLAKE2b-256 checksum
How to use checksums
3ac4031700d5b524e6edf65b2e9298069b0779fa7089fb06106075223f2e4ee4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for madkit 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page