Skip to content

OpenMapmaking/mcjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCJS

Minecraft commands generated with JavaScript.

Documentation

Features

  • Compiles .mcjs files to .mcfunction.
  • Generate Minecraft commands using all the power of JavaScript.

In terminal, use the --help option to see all the commands available:

mcjs --help

Getting started

  1. Install Node.js, open a terminal and type:
npm install -g @open-mapmaking/mcjs
  1. Create a test.mcjs file containing:
// Regular javascript
let entities = ['creeper', 'zombie', 'bat']

for (let entity of entities) {
  // cmd function is used to output Minecraft commands
  cmd`
  summon ${entity} ~ ~ ~
  say Summoned ${entity}!
  `
}
  1. Compile test.mcjs from terminal:
mcjs test.mcjs

test.mcjs is interpreted like regular javascript. A test.mcfunction file is generated from its execution, in the same folder. It contains all commands passed to the cmd function:

summon creeper ~ ~ ~
say Summoned creeper!
summon zombie ~ ~ ~
say Summoned zombie!
summon bat ~ ~ ~
say Summoned bat!

The cmd function

When the cmd function is called from a .mcjs file, it outputs the string it gets to the final .mcfunction file:

  • test.mcjs
cmd('say hello')
cmd('summon creeper ~ ~ ~')
  • test.mcfunction
say hello
summon creeper ~ ~ ~

cmd is also a template tag, which means that multiline strings are available:

  • test.mcjs
let name = 'Steve'

cmd`
say ${name}!
say ${name.toUpperCase()}!!
`
  • test.mcfunction
say Steve!
say STEVE!!

About

Minecraft commands generated with JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published