npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mindustry-schematic-parser

v4.3.2

Published

A simple api to parse mindustry schematics

Downloads

108

Readme

Mindustry Schematic Parser

A simple way to parse mindustry schematics.

Most of this package's functionality is documented with JSDoc, so most IDEs will give you autocompletion and function and class details.

Install

npm install mindustry-schematic-parser

Usage

import * as fs from 'fs'
import { Schematic } from 'mindustry-schematic-parser'

const base64 =
'bXNjaAF4nE2N227CMAyGf9KjhrRpSNznBXqFtBfhCUJjUBEklUkH7NG5oDhppWHH+Rwf/iBDqZA7cyZ8b24/emuc1cHrbcumx9LSpeWuD513WL899MFrvWOxGh/9cPol7v6IJfdX4sZ5S/jqnJQD2ebiBYzPwVni/clfm4MJhPo4uDZJl/NEyX6IrHYmCO8AVvi3RTpQdQWMT6hxlBBKVYlLZ3zMo9mEHKleFDHN0vYiQjxPW6koUQjyNFVKVsSOmiSiOqr5A7myCUlZzcovD0488Q=='

const schematic = Schematic.decode(base64)
console.log('name: ', schematic.name)
console.log('description: ', schematic.description)
console.log('power balance: ', schematic.powerBalance)
console.log('item cost:', schematic.requirements)

// save a preview of the schematic
schematic
  .render({
    background: false // disable background
  })
  .then(nodeCanvas => nodeCanvas.toBuffer())
  .then(buffer => fs.writeFileSync('my_file.png', buffer))

Rendering options

Bellow are the type definitions for schematic rendering options

export interface SchematicRenderingOptions {
  /** Options for rendering coveyors */
  conveyors?: {
    render: boolean
  }
  /** Options for rendering conduits */
  conduits?: {
    render: boolean
  }
  /** Options for rendering normal bridges */
  bridges?: {
    render?: boolean
    opacity: number
  }
  /** Options for rendering phase bridges */
  phaseBridges?: {
    render?: boolean
    opacity: number
  }
  /** The max size in pixels for this image */
  maxSize?: number
  /**
   * The size the preview must have.
   * Using this option overshadows `maxSize`
   */
  size?: number
  /** Whether the image should have a background */
  background?: boolean
  /** Browser only,  */
  assetsBaseUrl: string
}

Exports

  • arc: namespace for the emulated functionality from Anuken/Arc
  • mindustry: namespace for mindustry emulated functionality
  • Blocks: object containing all blocks available under categories
  • Items: object with all items available
  • Liquids: object with all liquids available
  • Schematic: class used to represent schematics, comes with static methods for encoding/decoding
  • SchematicTile: class used to represent single schematic tiles

Exported types

  • ItemName: an union of all the names of the available items
  • ItemCost: record of item names and numbers, used to represent schematic build requirements
  • LiquidName: an union of all the names of the available liquids