CoffeeScript integration in ScriptCraft https://github.com/walterhiggins/ScriptCraft
This repository has been archived on 2021-07-14. You can view files and clone it, but cannot push or open issues or pull requests.
Find a file
2013-03-23 14:14:53 +00:00
docs first draft of guide 2013-03-23 14:14:53 +00:00
mcp-deprecated reorog 2013-01-07 23:48:43 +00:00
screenshots Example of the use of block type 2013-01-20 21:20:15 +00:00
src further changes for issue #72 2013-03-23 12:54:15 +00:00
.gitignore added .js~ and .js# (emacs temp files) to ignore list 2013-02-05 20:48:26 +00:00
build.properties Switched to craftbukkit 147 (No changes to code - just tested with 147 server) 2013-01-21 22:19:34 +00:00
build.xml updated readme to include new download link and website - builds go to distinct timestamp dir 2013-02-22 16:51:01 +00:00
README.md updated readme to include new download link and website - builds go to distinct timestamp dir 2013-02-22 16:51:01 +00:00

ScriptCraft

A Minecraft mod that lets you create mods using Javascript.

Description

ScriptCraft is a plugin for Minecraft Servers which lets operators, administrators and plug-in authors customize the game using Javascript. ScriptCraft makes it easier to create your own mods. Mods can be written in Javscript and can use the full Bukkit API. The ScriptCraft mod also lets you enter javascript commands at the in-game prompt. To bring up the in-game prompt press the / key then type js followed by any javascript statement. E.g. /js 1+1 will print 2.

ScriptCraft also includes many objects and functions to make building and modding easier using Javascript.

  • echo( message ) - displays a message on the player's screen. e.g. /js echo( 1 + 3 ) or /js echo ("Hello World")
  • getMousePos() - A function which returns the current position of the cross-hairs (if a block is targeted)
  • getPlayerPos() - A function which returns the current position of the player.
  • putBlock( x, y, z, blockId, metaData ) - A function which lets you place a block anywhere (if no coordinates are given the block the player is currently looking at is replaced).
  • getBlock( x, y, z ) - returns the blockId and metadata at the given location (if no coordinates are given the cross-hair location is used)
  • putSign( String[] texts, x, y, z, blockId, metaData ) - A function which lets you place a sign.

The above primitives can be used to create buildings which would otherwise be time-consuming to create manually. It is highly recommended using the attached drone javascript plugin which provides a fluent API for building. The Javascript Drone class provides a much richer API which can be used to construct buildings. See the attached cottage.js file for an example of you can use the sample Drone plugin to create new buildings in Minecraft.

Prerequisites

You will need to have Java version 6 or 7 installed on your machine. Check the version by typing java -version at a command prompt. You will need to install Bukkit on your machine. Bukkit is a version of Minecraft (server) that makes it easy to install plugins and customize Minecraft. You can download the CraftBukkit server here.

Installation

If you don't want to compile from source, you can download the compiled plugin here and copy it the craftbukkit's plugins directory.

Post Install

Once installed, a new js-plugins directory is automatically created in the same directory as the plugins folder. All files in the js-plugins directory will be automatically loaded when CraftBukkit starts. Only players who are ops can use this plugin. You can grant a player op privileges by typing 'op ' at the server console prompt or by adding the player's username to the ops.txt file in your craftbukkit directory.

Launch CraftBukkit, then launch the Minecraft client and create a new server connection. The IP address will be localhost . Once you've connected to your bukkit server and have entered the game, look at a ground-level block and type ...

/js up().box('35:15', 4, 9, 1)

... This will create a black monolith structure 4 blocks wide by 9 blocks high by 1 block long. Take a look at the src/main/javascript/drone/drone.js file to see what ScriptCraft's drone can do. If you're interested in customizing minecraft beyond just creating new buildings, take a look at [./homes/homes.js][homes] and [./chat/color.js][chatcolor] for examples of how to create a javascript plugin for Minecraft.

A Javascript mod for minecraft is just a javascript source file (.js) located in the craftbukkit/js-plugins directory. All .js files in this directory will be automatically loaded when the craftbukkit server starts. To get started writing your own mod, first take a look at some of the existing mods in the homes, chat, arrows and signs directories. The chat/color.js mod is probably the simplest mod to get started with.

Additional information

Because the Bukkit API is open, all of the Bukkit API is accessible via javascript once the ScriptCraft plugin is loaded. For example, in addition to the functions provided in the MCP version of ScriptCraft, there are a couple of useful Java objects exposed via javascript in the Bukkit ScriptCraft plugin...

  • __plugin - the ScriptCraft Plugin itself. This is a useful starting point for accessing other Bukkit objects. The __plugin object is of type org.bukkit.plugin.java.JavaPlugin and all of its properties and methods are accessible. For example... js __plugin.server.motd returns the server's message of the day (javascript is more concise than the equivalent java code: __plugin.getServer().getMotd() ).
  • self - The player/command-block or server console operator who invoked the js command. Again, this is a good jumping off point for diving into the Bukkit API.
  • server - The top-level org.bukkit.Server object. See the Bukkit API docs for reference.

Further Reading

ScriptCraft has its own website with further information.

You can find more information about ScriptCraft on my blog.