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.6

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.6
File Size Uploaded Provenance Actions
madkit-0.1.6.tar.gz 51.3 kB Without provenance Details for madkit-0.1.6.tar.gz

Built distribution (wheel)

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

Total release size: 115.1 kB

Release files / madkit-0.1.6.tar.gz

Download URL madkit-0.1.6.tar.gz
Size 51.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e2e586e04bf4607d4770a5f9343d35ee8d4f253b7c57e8935390665540820fc2
BLAKE2b-256 checksum
How to use checksums
8b4ea7756bf906ba2e24d6bb58a9d7c113c6811ecb1e93b42b17f736b73f88f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.6-py3-none-any.whl

Download URL madkit-0.1.6-py3-none-any.whl
Size 63.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
611b68f625920d469ba1bdd9cab71e3b5f54f1db6dce838e75ade7189866fbaa
BLAKE2b-256 checksum
How to use checksums
a217602bedd2d8ce76d4a3798008f672aff5f1b2766c7d1db56704ce1e18564f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.6

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