Skip to main content

Minecraft Script Programming language

Project description

Minecraft Script

Minecraft script is primarily a tool to make Minecraft Datapack creation easier.

Minecraft Script is an interpreted programming language which goes through the Python interpreter for output.

However, interpretation is not its main feature, and is rather more of a debugging tool, as its sole

purpose is to allow you to validate your code before building it into a full datapack.

Commands

python -m minecraft_script help

python -m minecraft_script run [files: optional, multiple allowed]

python -m minecraft_script build [file]

Data Types

Minecraft-script can only work with integers. This is due to the fact that strings aren't a thing in minecraft, and floating point numbers don't work in most cases, specifically scoreboards.

This also means that the only division available is euclidean division.

var number = 423  // number, has to be an integer

var array = [1, 2, 3, 4, 5]  // array of numbers

Objects

Variables

The var keyword can be used to initialize new variables.

Use it by following it by the variable's name, then an equals sign and a value.

var hello2 = 500  // initialized variable "hello2" with value 500



var hello2 = 300  // assigned new value 300 to variable hello2

var hello2 = hello2 + 500  // adds 500 to hello2

Functions

Functions are defined with the "function" keyword. They can be anonymous,

or be attributed a name. Parentheses around the arguments are required (currently, subject to change).

function = (a) => a * 3  // anonymous function



function add = (a, b) => a + b  // define a simple add function

add(2, 7)  // call the function; returns 9

Builtin Functions

log

The log functions allows you to keep track of values in the console.

It is equivalent to JavaScript's console.log() or Python's print() function.

var hello1 = 500



log(400)  // logs "400" in console

log(hello1, 300)  // logs "500, 300" in console

append

Append a value to a list. The first argument has to be a list.

var test = [3, 5, 4]



append(test, 2)  // append 2 to the list

append(test, [3, 4])  // append [3, 4] to the list



log(test)  // logs "[3, 5, 4, 2, [3, 4]]"

extend

Extend a list by another list. Both arguments need to be lists.

var list_1 = [5, 2]

var list_2 = [2, 3]



extend(list_1, list_2)



log(list_1)  // logs "[5, 2, 2, 3]"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minecraft_script-0.1.406.tar.gz (12.2 kB view hashes)

Uploaded Source

Built Distribution

minecraft_script-0.1.406-py3-none-any.whl (15.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page