Git Product home page Git Product logo

craftscript's Introduction

CraftScript

Opus #26

A tiny scripting language for writing user-centered scripts in Minecraft.

Documentation

Comprehensive language documentation (and some introductory tutorials) are available here.

Maven Information

<repository>
    <id>kenzie</id>
    <name>Kenzie's Repository</name>
    <url>https://repo.kenzie.mx/releases</url>
</repository>
<dependency>
    <groupId>mx.kenzie</groupId>
    <artifactId>craftscript</artifactId>
    <version>1.0.0</version>
</dependency>

Introduction

CraftScript is a contextualised, functional script engine. It can function either as an interpreted scripting language or a compiled programming language.

It is designed for the game 'Minecraft' to run small, non-invasive scripts from the context of a player. However, the parser and script engine are easy to modify or extend so that domains may create their own additional functionality.

Its principle feature is the 'context' -- the situation and environment that code is running in, including the variables, functions and keywords that are available during runtime. This allows for an unusual form of ad hoc polymorphism: the same interpreted code can be used to do an entirely different thing depending on its context. Rather than overloading two separate functions (e.g. fn(int) and fn(string)) CraftScript can feed different parameters, variables, known types and even language keywords to an executable statement.

Motivations

CraftScript was designed for players in the game 'Minecraft' to write scripts to be run from their in-game avatar.

With this in mind, the actions available in a script are limited to what the executor is capable of doing. This adds a layer of safety to the language, since a player's permissions can be limited in order to prevent destructive actions.

I made CraftScript for a public server in which users can write, upload and run their own scripts in order to create macros or special behaviour.

The language is designed to be fairly simple but also unambiguous, and imitates the style of Minecraft's native commands, selectors and keys.
There is some deviation from this, since CraftScript has several features that do not exist in the .mcfunction format.

Language Type

Scripts are designed to be interpreted into an executable structure. However, in some situations it may be preferable to compile the script into a JVM class.

Currently, there is one built-in simple script compiler. This turns a script into bytecode that can be saved in the Java class format or loaded directly into the machine. While this does allow a script to be stored and loaded significantly more quickly, it still requires CraftScript as a dependency to run.

The simple script compiler assembles the executable statements in situ -- when they are required -- rather than storing them ahead of time.

This has the advantages of not keeping all the statement objects in memory and potentially benefiting from some JVM optimisation, however, if the JVM is unable to optimise it properly, it will require more CPU resources and could be slower to execute than an interpreted script. This is because the memory block has to be allocated for a statement before it can be run.

craftscript's People

Contributors

moderocky avatar

Stargazers

Pesek avatar Ayham Al Ali avatar Assim Zemouchi avatar

Watchers

 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.