Skip to main content

A Python library for producing custom scripts in Blood On The Clocktower.

Project description

Scriptmaker

A PDF writer for Blood on the Clocktower scripts.

Scriptmaker includes some special features:

  • support for modern and legacy base3+experimental custom scripts
  • homebrew character support via the official app's character schema
    • as a result, supports translations too!
  • nightorder styles: single-sided rotated, or double-sided full-text
  • i18n support with fallback rendering modes

Significant credit goes to chizmw for inspiration and assets!

Stack

  • Python
  • poetry
  • jinja2

Examples

Trouble Brewing

Here's scriptmaker's default output for the official Trouble Brewing script.

You can also choose to generate simple nightorders.

Custom script & homebrew

Homebrewed content and custom logos are also supported.

Usage

Installation

Scriptmaker requires the following non-Python dependencies:

ghostscript
poppler-utils
pango

Install the package with your package manager of choice.

pip install scriptmaker
poetry add scriptmaker
...

Using the CLI

scriptmaker (make-pdf | tokenize)
scriptmaker make-pdf <inputs> [output] [options]

  inputs:
    (--script path/to/script.json | --url https://script.json | --recurse path/to/folder/) # Sources a script.
    [--nights path/to/nights.json] # Supplies a custom night order.
  
  output:
    [--output-folder path/to/folder/] # Creates build/ and pdf/ folders under this directory.
  
  options:
    [--full] # Creates a full-text two-sided nightorder
    [--simple] # Creates a simple, rotatable nightorder for physical printing
    [--i18n-fallback] # Tries to resolve issues with non-Latin character rendering
    [--postprocess] # Compresses PDFs and generates PNGs for pages
scriptmaker tokenize <inputs> [output] [options]

  inputs:
    directory # Recurses over it, adds all scripts to a datastore, and prints the result.
  
  output:
    [--output-folder path/to/folder/] # Creates build/ and pdf/ folders under this directory.
  
  options:
    [--character-size size-in-mm] # Determines the size in millimetres of character tokens; default 45.
    [--reminder-size size-in-mm] # Determines the size in millimetres of reminder tokens; default 19.
    [--extra-copies path/to/copies.json] # A key-value dict of character IDs and token counts, if you wish to generate extra copies.
    [--official-only | --exclude-official] # Either only print base3 + experimental tokens, or don't add them at all (good for homebrews).
    [--postprocess] # Compresses PDFs and generates PNGs for pages

Using the package

  1. Import everything you need.
from scriptmaker import Character, Datastore, Script, PDFTools, Renderer, ScriptmakerError
  1. Create a data store for your new script.
# Create a datastore (leaving it blank uses a temporary directory)
my_datastore : Datastore = Datastore("my/output/directory/")

# Load the official characters into it, if you want
my_datastore.add_official_characters()
  1. Load a script.json file.
with open("my/script.json", "r") as json_file:
    my_script_json = json.load(json_file)

# Perhaps you have a custom nightorder.
with open("my/nightorder.json", "r") as nightorder_file:
    my_nightorder = json.load(nightorder_file)

# Loads the characters into the datastore, then builds a script object too
my_script : Script = my_datastore.load_script(my_script_json, nightorder_json = my_nightorder)
  1. Set your desired options on the script if not already in the script.json.
# Metas are automatically set if there was a _meta block in the script.json
my_script.meta.author = "rsarvar1a"
my_script.meta.add_logo("https://my/logo/url.png")

# Options have defaults; see ScriptOptions()
my_script.options.i18n_fallback = True
  1. Render it!
outputs = set()

# Renders to the datastore path, if no output_folder is given
outputs.add(Renderer().render_script(my_script), output_folder = None)
outputs.add(Renderer().render_nightorder(my_script))
  1. Postprocess your PDFs.
for path in outputs:
  PDFTools.compress(path)
  PDFTools.pngify(path)

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

scriptmaker-2.0.1.tar.gz (33.7 MB view details)

Uploaded Source

Built Distribution

scriptmaker-2.0.1-py3-none-any.whl (33.7 MB view details)

Uploaded Python 3

File details

Details for the file scriptmaker-2.0.1.tar.gz.

File metadata

  • Download URL: scriptmaker-2.0.1.tar.gz
  • Upload date:
  • Size: 33.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for scriptmaker-2.0.1.tar.gz
Algorithm Hash digest
SHA256 82e58844408ef364b237fd19d1c9eed9f7f4aedc988c3b669df7bb372372e7ce
MD5 0b442382cc539ed442d84f13cc3a219e
BLAKE2b-256 1f8738351f7c56cf956cf17f61fe9b8db303f67c4e5e3efe775a73cf52f66255

See more details on using hashes here.

File details

Details for the file scriptmaker-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: scriptmaker-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 33.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for scriptmaker-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1f9cf4fb77c28387c7770380d3cb5444503c02b67fce5674b52efa2ba23a0ba0
MD5 9158d41c073cb03b2d6d41c5e730f41c
BLAKE2b-256 c867835d0961cff0acdf61713f688ac79cba9b00ae1fc2e3ba6a1e048c89bedc

See more details on using hashes here.

Supported by

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