Skip to content

CommandBlocksJS allows you to translate Javascript code to Minecraft Commandblocks

License

Notifications You must be signed in to change notification settings

bradparks/CommandBlocksJS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#CommandBlocksJS CommandBlocksJS allows you to program commandblocks logic in typescript/javascript. The major benefit in using CommandBlocksJS instead of building the blocks yourself is that you can create complex logic a lot faster that than you could in minecraft. Furthermore you can 'build' stuff like countdown timers in 4 lines of code where you would need ~10 minutes to write all the commands ingame.

##Documentation cooming soon

###Legacy Documentation (<2.0) Here There also is a Quick Start page for those who cant wait to write their first script (with version 1.3)

##Examples

//
//https://github.com/M4GNV5/CommandBlocksJS/blob/master/Example/CircleCalculations.ts
//

/// <reference path="../Core/API.ts"/>

//start at radius
var startRadius = 1;
//stop at radius
var stopRadius = 20;

var radius = new Runtime.Integer(startRadius);
var timer = new Util.Timer(calculateNext, 1);
timer.start();

function calculateNext()
{
	var circumference = new Runtime.Decimal();
	var area = new Runtime.Decimal();

	var pi = Runtime.Decimal.Pi;

	// C = 2 * pi * r
	circumference.set(radius);
	circumference.multiplicate(pi);
	circumference.multiplicate(2);

	// A = r * r * pi
	area.set(radius);
	area.multiplicate(area);
	area.multiplicate(pi);

	// output current values
	Chat.Tellraw.create(
		"r = ",
		radius.toTellrawExtra(),
		", C = ",
		circumference.toExactTellrawExtra(),
		", A = ",
		area.toExactTellrawExtra()
	).tell(new Entities.Player("@a"));

	//add one to radius
	radius.add(1);

	radius.isBetween(stopRadius, undefined, function ()
	{
		timer.stop();
	});
}

###Output Cmd

##Used Libraries

##License CommandBlocksJS is published under the 4 clause BSD license what means you can use source and binary for everything but your project needs to include the following clause: "This product includes software developed by Jakob Löw (M4GNV5)."

About

CommandBlocksJS allows you to translate Javascript code to Minecraft Commandblocks

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 77.8%
  • C# 21.6%
  • Shell 0.6%