MLOGX

raw JSON →
2.7.2 verified Fri May 01 auth: no javascript

MLOGX is a transpiler and toolchain for Mindustry Logic (MLOG), the scripting language of the game Mindustry. Version 2.7.2 provides validation, readability improvements (e.g., infix operators, printf), compiler constants, loops, and multi-file support. It is actively maintained with frequent releases. Unlike raw MLOG, MLOGX catches invalid commands and type mismatches at compile time. It ships TypeScript types and supports both CLI and API usage.

error ReferenceError: mlogx is not defined
cause Using `require('mlogx')` in an ESM context.
fix
Use import mlogx from 'mlogx' or const { compile } = await import('mlogx').
error Module 'mlogx' has no exported member 'transpile'
cause The main function is named `compile`, not `transpile`.
fix
Replace import { transpile } from 'mlogx' with import { compile } from 'mlogx'.
error mlogx: command not found
cause Global installation missing or PATH not set.
fix
Run npm install -g mlogx or use npx mlogx.
breaking The CLI changed from `mlogx <file>` to `mlogx compile <file>` in v2.0, and the API changed from synchronous to asynchronous.
fix Update CLI usage: `mlogx compile input.mlogx -o output.mlog`. If using the API, switch to async `compile(source, options)`.
breaking Default export removed in v2. Use named import `{ compile }` instead.
fix Change `import mlogx from 'mlogx'` to `import { compile } from 'mlogx'`.
gotcha The `writeOutput` function expects an object with `code` and optionally `warnings` – not a raw string.
fix Always pass the full result object from `compile()` to `writeOutput()`.
deprecated `mlogx port` command is deprecated in favor of `mlogx convert`.
fix Use `mlogx convert input.mlog -o output.mlogx` instead of `mlogx port`.
npm install mlogx
yarn add mlogx
pnpm add mlogx

Compiles an MLOGX file to MLOG, showing the basic API usage.

import { compile, writeOutput } from 'mlogx';
import { readFileSync } from 'fs';

const source = readFileSync('example.mlogx', 'utf8');
const result = compile(source, {
  filename: 'example.mlogx',
  targetVersion: 7,
  format: 'mlog'
});
console.log(result.code);
writeOutput(result, './out/output.txt');
// Output: compiled MLOG with error checks