Skip to main content

A Python library to generate RetroAchievements scripts programmatically.

Project description

PyCheevos

PyCheevos is a set of tools to generate RetroAchievements achievement sets programmatically using Python.

Inspired by RATools and Cruncheevos, it allows you to leverage the full power of the Python ecosystem (loops, functions, classes) to build complex achievement logic with clean, readable code.

  • Core: Handles condition parsing, memory addresses, arithmetic (byte, word, delta) and logic helpers (reset_if, measured). Now supports logical operators (&, |, ~) for clean condition chaining.
  • Models: Provides the structure for Sets, Achievements, Leaderboards, and Rich Presence.
  • Utils: Contains hybrid importers (import_notes, import_achievements) that can fetch data from local files or directly from the RetroAchievements server.

Installation

You can install PyCheevos directly from PyPI:

pip install pycheevos

[!NOTE] Since the library is under active development, it is recommended to pin the version in your project to avoid breaking changes: pip install pycheevos==0.0.4

Usage

Using this library assumes familiarity with the RetroAchievements workflow and memory inspection.

Get Started

Create a new .py file and import the library modules (models and core).

Run your script to generate an output folder containing your RA logic files ([ID]-User.txt).
You can change this output location by defining a path in the .save() function of AchievementSet.

Using the Importers

To run the importer tools installed via pip, use the -m flag:

  • To import achievements:
python -m pycheevos.utils.import_achievements

(Supports local files and server download)

  • To import notes:
python -m pycheevos.utils.import_notes

(Automatically detects pointer hierarchies and fetches notes from the server if needed)

Small Demo

from pycheevos.models.set import AchievementSet
from pycheevos.models.achievement import Achievement
from pycheevos.core.helpers import byte, prior, value, reset_if
from pycheevos.core.constants import AchievementType

# Initialize the set
game_set = AchievementSet(game_id=1, title="Sonic the Hedgehog")

# Define Memory Addresses
mem_rings = byte(0xFE20)
mem_zone  = byte(0xFE10)

# Reusable Logic Function
def got_rings(amount):
    """Triggers when ring count increases to or past 'amount'."""
    # Use '&' for AND, '|' for OR, '~' for NOT
    # Use value() to wrap constant numbers safely
    return (mem_rings >= value(amount)) & (prior(mem_rings) < value(amount))

# Create Achievement
ach = Achievement(
    title="Super Ring Collector", 
    description="Collect 1000 rings", 
    points=50, 
    id=111001,
    type=AchievementType.PROGRESSION # Use Enum for safety
)

# Apply Logic
# New Syntax: You can chain logic directly using operators
ach.add_core(
    got_rings(1000) & (mem_zone == value(0)) # Must be in Green Hill
)

# Add reset logic using the new helper function
ach.add_core(
    reset_if(mem_rings == 0)
)

game_set.add_achievement(ach)

# Generate the user file (1-User.txt)
game_set.save()

User Repositories

[!IMPORTANT] Your repo here? Make a PR and add it!

Contributing

You are welcome to report issues. If you run into errors generating the script, please include your Python version and the traceback.

You are welcome to request features. When doing so, please show how you would use the feature (pseudo-code) and what logic problem it solves.

The core library aims to be minimal. Complex logic specific to a single game should ideally be implemented in your own script using Python's flexibility, rather than hardcoded into the library core.

Pull Requests are welcome, especially for documentation improvements or type hinting fixes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycheevos-0.0.4.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycheevos-0.0.4-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file pycheevos-0.0.4.tar.gz.

File metadata

  • Download URL: pycheevos-0.0.4.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for pycheevos-0.0.4.tar.gz
Algorithm Hash digest
SHA256 efa6644f70aad569bd1c33a65ccd4d73c6cc87f6c940a3578f91fb2a2aef74b6
MD5 cc464da08ae047155ac2543c4a720eb2
BLAKE2b-256 833afce480c384c77e2020351730e4e671b2dccf92ef0f16730521d44731aa56

See more details on using hashes here.

File details

Details for the file pycheevos-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pycheevos-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for pycheevos-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d03d3371fb0f80f20b65b880eb0bdd7b546555ea8f93a541dd77b2dd0f973be4
MD5 e04c415f5be216cdb371da79aa605336
BLAKE2b-256 965731102bf627edc62d75bb28fd28b6c94a08f6c2029e648811a2bd18119836

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page