Giter VIP home page Giter VIP logo

mcb's Introduction

MCB-Language

A lightweight scripting language that compiles in to mcfunction.

Description

MCB stand for Mincraft Boon. MCB is a lightweight scripting language that compiles in to mcfunction. It support functional programming, giving power to make your coding process faster.

Why build MCB?

Cuz mcfunction suck so i build MCB but trust me.... there is no cure.

Get Started

Requirements:

node js >=v16.0.0

Installation

# install with npm
npm install -g mcb-lang
# install with yarn
yarn global add mcb-lang

Creating project

mcb init

Powerful CLI

# want help?
mcb help
   
# initialize project.
mcb init

# build project.
mcb build or mcb .

# tools for project configs and more.
mcb mk or mcb make

Basic syntax

Variables

MCB is a statically typed language. This means that variables do have types in declaration.

Basic declaration

Restrict area no floating variables allowed.

// Format
let <objective>:score <criteria> <displayname>

// Usage
let foo:score dummy
let bar:score air Boon

Compiled code

scoreboard objectives add foo dummy

Set value in variable

// Format
<scoreboard_objective>[<target>] = value

// Usage
foo[x] = 10
bar[@s] = 5

Compiled code

scoreboard players set x foo 10
scoreboard players set @s bar 5

Print out the output

print("hi ${x[0]}")

Conditional expressions

fun hello(){
   x[a] = 0
   if(x[a]=0){
      print("hello")
   }else{
      print("hi")
   }
}

for loop

for(x[i] in 1..5;1){
   say hi
}

while loop

x[a] = 5
while(x[a]>0){
   print("while 1 ${x[a]}")
   x[a]-=1
}

Functions

Input parameters is not support in this version. return output too. 😎

A Function with no Input

fun hello(){
  say hello
}

// this is how you can call function.
hello()

Function Modifiers

load means that the function is run after the datapack has loaded, triggered by minecraft:tags\functions\load.json

// you will got a message in your minecraft chat after the datapack was loaded.
load fun hi_at_start(){
   print("HI")
}

tick means that the function is run every tick by minecraft:tags\functions\tick.json trigger.

// you will got a hi message in your minecraft chat every tick
tick fun hi_every_tick(){
   say hi
}

load and tick combo

// you will got a hi message in your minecraft chat every tick and on loaded.
tick load fun hey(){
   say hi
}

// you will got a hello message in your minecraft chat every tick and on loaded.
load tick fun hello(){
   say hello
}

@mix

mix another language to generate code

@mix(js)
{
   console.log("HI")
   return ["say hi","say hello"]
}

Mix result

say hi
say hello

Folder structure

All of Project-Files in here. MCB used folder structure following by this 3 words.

<namespace> β†’ mcbpack.json + Your Project-Files

<namespace>
   β”œβ”€ +static\ //coming soon
   β”‚        └─ +<Your Static File>
   β”œβ”€ +<Your Folder>\
   β”‚        └─ +<Your File>.mcb
   β”œβ”€ +<Your File>.mcb
   └─ mcbpack.json

What’s mcbpack.json?

The presence of a mcbpack.json file in directory indicates that directory is root of MCB Project.

mcbpack.json file is a configuration file specifies The root files and compiler options to let The MCB compiler compile projects.

Example of mcbpack.json

{
   "name": "Hello",
   "mcVersion": 1.17,
   "compiler":{
      "<any-name1>":{
         "root":["/src/**"],
         "output":"/dist",
         "obfusticate": true // comming soon
      },
      "<any-name2>":{
         "root":["/test/**"],
         "output": "/dist-test"
      },
      "<any-name3>":{
         "root":["/src/**","/test/**"],
         "output": "/dist"
      }
   },
   // comming soon
   "dependencies":{
      "warppp": "1.0"
   }
}

mcb's People

Contributors

boon4681 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.