Package: scriptmaker
ScriptmakerA PDF writer for Blood on the Clocktower scripts.Scriptmaker includes some special features:support for modern and legacy base3+experimental custom scriptshomebrew character supportvia the official app's character schemaas a result, supports translations too!nightorder styles: single-sided rotated, or double-sided full-texti18n support with fallback rendering modesSignificant credit goes tochizmwfor inspiration and assets!StackPythonpoetryjinja2ExamplesTrouble BrewingHere's scriptmaker's default output for the official Trouble Brewing script.You can also choose to generate simple nightorders.Custom script & homebrewHomebrewed content and custom logos are also supported.UsageInstallationScriptmaker requires the following non-Python dependencies:ghostscript
poppler-utils
pangoInstall the package with your package manager of choice.pipinstallscriptmaker
poetryaddscriptmaker
...Using the CLIscriptmaker (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 pagesscriptmaker 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 pagesUsing the packageImport everything you need.fromscriptmakerimportCharacter,Datastore,Script,PDFTools,Renderer,ScriptmakerErrorCreate 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 wantmy_datastore.add_official_characters()Load a script.json file.withopen("my/script.json","r")asjson_file:my_script_json=json.load(json_file)# Perhaps you have a custom nightorder.withopen("my/nightorder.json","r")asnightorder_file:my_nightorder=json.load(nightorder_file)# Loads the characters into the datastore, then builds a script object toomy_script:Script=my_datastore.load_script(my_script_json,nightorder_json=my_nightorder)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.jsonmy_script.meta.author="rsarvar1a"my_script.meta.add_logo("https://my/logo/url.png")# Options have defaults; see ScriptOptions()my_script.options.i18n_fallback=TrueRender it!outputs=set()# Renders to the datastore path, if no output_folder is givenoutputs.add(Renderer().render_script(my_script),output_folder=None)outputs.add(Renderer().render_nightorder(my_script))Postprocess your PDFs.forpathinoutputs:PDFTools.compress(path)PDFTools.pngify(path)