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

mlogx

v2.6.0

Published

MLOGX transpiler targeting Mindustry Logic.

Downloads

232

Readme

A transpiler for Mindustry Logic.

logo

Installation

  • Install the dependencies if you don't have them yet: NodeJS, NPM, Git
  • Run npm i -g mlogx

Usage: mlogx

Design goals

  1. Validation
  • Debugging MLOG code is painful. The only way to notice that you typed ucontrol itemtake instead of ucontrol itemTake is to scroll through your entire program to see why units aren't taking items, and finally see the purple "invalid" box. There is also no warning for using a variable that doesn't exist. The MLOGX compiler will check your code before it compiles to make sure all commands are valid and all variables are of the correct type.
  1. Readability and Conciseness
  • Text MLOG statements can be a bit weird. For example, the ulocate building instruction requires a meaningless ore as an argument, and several other instructions have repeated or strangely ordered arguments and/or meaningless zeros. MLOGX has more concise statements with better ordering of arguments, while still accepting the old ones.
  • It also supports shorthand instructions, such as infix op(set x 5 + 5 => op add x 5 5) and infix jump(jump label x >= 5 => jump label greaterThanEq x 5)
  • The preferred variable naming convention is to use a thing.property syntax, for example, sensor core.x. This is a shorthand for sensor core.x core @x as you would otherwise be typing things twice. This makes it very clear what each variable is meant to be.
  • Sometimes there are bits of data that you might want to change, but never while your code is running. Storing these as a variable in your MLOG code is a waste of instructions, so they often end up getting inlined, making them difficult to change and understand. MLOGX has compiler consts, which allow you to inline data without compromising readability.
  • Advanced unit control logic often requires highly repetitive code, for example, the same block of code repeated an arbitrary number of times but with one number incrementing. &for loops clean this up easily, and allow you to change the target number of units by changing a single compiler const in a config.json file instead of copy pasting your code n times, forgetting to change a number in one place, and then wasting 15 minutes wondering why the 3rd flare doesn't get rebound.
  • Logic that prints information is both difficult to read and hard to change. The printf statement allows you to write printf "Power: {powerIn}/{powerOut} ({powerPerc}%)".
  • MLOGX also allows you to split your code into multiple files, which is useful if you use a particular bit of code lots of times.
  1. Optimization
  • Because MLOGX is a strict superset of MLOG, your code can be optimized just as much as if you were writing regular MLOG. The compiler does not inject extra executed instructions unless you ask for it.
  • MLOGX is not currently an optimizing compiler, the instructions you put in are what you will get out.

Other features

MLOGX is more than just a compiler, it also has the mlogx info command, which gives you information on a command or generic arg type(eg operandDouble will show all operators that accept two operands). There is also mlogx port, which ports mlog code to mlogx by removing trailing zeros, and mlogx genLabels, which adds autogenerated jump labels to code from a processor.

Example images

Image of error messages

Image of concise statements

Image of compiler consts

Image of &for loops

Features:

  • [x] Stops you from writing silly code like ubind "poly"
  • [x] Improved syntax for certain commands(ulocate, radar)
  • [x] mlogx info for information about a command
  • [x] Compiler constants
  • [x] No more pasting weird unicode characters for the sand icon
  • [x] /**/ comments
  • [x] Static type checking
  • [x] NPM package
  • [x] --watch option
  • [?] Namespaces
  • [x] Loop unrolling syntax
  • [x] Functions
  • [x] Console output highlighting
  • [x] Porting tool
  • [x] Infix op and jump syntax
  • [ ] More functions
  • [ ] Inline functions
  • [ ] Custom commands