@open-mapmaking/mcjs
v0.1.3
Published
Minecraft commands generated with JavaScript
Downloads
4
Readme
MCJS
Minecraft commands generated with JavaScript.
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
- Install Node.js, open a terminal and type:
npm install -g @open-mapmaking/mcjs
- 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}!
`
}
- 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!!