# CraftScript

## Introduction

CraftScript is a contextualised, functional scripting 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.&#x20;

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.&#x20;

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://craftscript.kenzie.mx/craftscript.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
