Coder Social home page Coder Social logo

scriptcraft's Introduction

ScriptCraft - Modding Minecraft with Javascript

Gitter code style: prettier

ScriptCraft lets you write Minecraft Mods using Javascript - a programming language that's relatively easy to learn and use. ScriptCraft is a Minecraft Server plugin which means it must be used with a Minecraft server. Once you've downloaded and installed the Minecraft Server, then installed the ScriptCraft Plugin you can write your own Minecraft mods using Javascript.

I created ScriptCraft to make it easier for younger programmers to create their own Minecraft Mods. Mods are written using the JavaScript programming language. Once the ScriptCraft mod is installed, you can add your own new Mods by adding JavaScript (.js) files in a directory.

  • If you're new to programming and want to start modding Minecraft, then Start Here.
  • If you've already used Scratch, have attended a few CoderDojo sessions, or have already dabbled with JavaScript, then Start Here.
  • Watch some demos of what you can do with ScriptCraft.

This is a simple mod in a file called greet.js in the scriptcraft/plugins directory:

function greet( player ) {
  echo( player, 'Hello ' + player.name );
}
exports.greet = greet;

At the in-game prompt, type:

/js greet(self)

Anything you can do using the Spigot or CanaryMod APIs in Java, you can do using ScriptCraft in 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 SpigotMC API or CanaryMod API. ScriptCraft works with all of the following Minecraft Server software:

I recommend using SpigotMC because both CanaryMod and CraftBukkit are no longer being actively developed. 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. For example: /js 1 + 1 will print 2.

ScriptCraft also includes many objects and functions to make building and modding easier using JavaScript. The JavaScript Drone object bundled with ScriptCraft provides an easy way to build at-scale in Minecraft. See the attached temple.js file for an example of how you can use the sample Drone plugin to create new buildings in Minecraft.

Prerequisites

ScriptCraft is a Minecraft Server Mod which only works with Minecraft for Personal computers (Windows, Mac and Linux). It does not work with X-BOX, Playstation or WiiU versions of the game. You will need to have Java version 7 or later installed. Check the version by typing java -version at a command prompt.

Installation

Before installing ScriptCraft you must first install SpigotMC which is a special version of Minecraft Server that makes it easy to customize the game.

Installing and Running SpigotMC

Follow these steps to download and install SpigotMC.

  1. Download Spigot's BuildTools.jar
  2. Save the BuildTools.jar file to a new directory called spigotmc.
  3. Open a terminal (Mac and Linux) or command prompt (windows) window and type java -jar BuildTools.jar. This will kick off a long series of commands to "build" SpigotMC.
  4. When the build is done, there will be a new file beginning with spigot and ending in .jar in the spigotmc directory. Run this file by typing java -jar spigot-1.10.2.jar (it might not be that exact name - you can list files in the directory by typing dir (Windows) or ls (Mac and Linux).
  5. The server will start up then shut down very shortly afterwards. You'll need to edit a file called eula.txt - change eula=false to eula=true and save the file.
  6. Run the java -jar spigot-1.10.2.jar command again - this time the server will start up. Shut it down by typing stop at the server prompt.

Installing ScriptCraft

Follow these steps to download and install ScriptCraft.

  1. Download the scriptcraft.jar plugin and save it to the plugins directory and restart the server by typing java -jar spigot-1.10.2.jar.
  2. At the server prompt type js 1 + 1 and hit enter. The result 2 should be displayed.

Congratulations - you've just installed your Custom Minecraft Server and are ready to begin writing your first mod!

Post Install

Once installed, a new scriptcraft/plugins directory is automatically created. All files in the scriptcraft/plugins directory will be automatically loaded when the server starts. Only players who are ops can use this plugin. You can grant a player op privileges by typing 'op ' (replacing with your own Minecraft user name) at the server console prompt or by adding the player's username to the ops.txt file in your server directory.

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

/js up().box( blocks.wool.black, 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 the homes mod for an example of how to create a more fully-featured JavaScript plugin for Minecraft.

Your first mod - Howling blocks

Listed below is a simple mod that will make blocks 'Howl' when they're broken.

// copy and paste this code to a new file named 'scriptcraft/plugins/howling-blocks.js'
var sounds = require('sounds');
function howl(event){
  sounds.entityWolfHowl( event.block );
}
events.blockBreak( howl );

If you're using CanaryMod instead of SpigotMC you can download the equivalent code.

A JavaScript mod for minecraft is just a JavaScript source file (.js) located in the scriptcraft/plugins directory. All .js files in this directory will be automatically loaded when the server starts.

To get started writing your own mod, take a look at some of the examples.

Additional information

Because the SpigotMC API is open, all of the SpigotMC API is accessible via javascript once the ScriptCraft plugin is loaded. There are a couple of useful Java objects exposed via javascript in the ScriptCraft plugin:

  • __plugin – the ScriptCraft Plugin itself. This is a useful starting point for accessing other SpigotMC objects. The __plugin object is of type org.bukkit.plugin.Plugin and all of its properties and methods are accessible. For example: js __plugin.name returns the plugin's name (JavaScript is more concise than the equivalent Java code: __plugin.getName() ).

  • server – The top-level org.bukkit.Server object. See the SpigotMC API docs for reference.

  • 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 SpigotMC API.

Contributing

If you would like to contribute source code and/or documentation changes please read contributing.md

Status

Travis Build Status

Bukkit Configuration

(You can ignore this if using CanaryMod)

ScriptCraft works with Bukkit Plugin and uses the Bukkit Configuration API. On first loading, ScriptCraft will create a config.yml file in the plugins/scriptcraft/ directory. This file looks like this:

extract-js:
  plugins: true
  modules: true
  lib: true

This file allows scriptcraft admins to turn on or off re-unzipping of the modules, plugins and lib folders when deploying a new version of ScriptCraft. It's strongly recommended that the lib directory always be set to true to get the latest core ScriptCraft code . The modules and plugins directories are optional and not part of ScriptCraft core.

Further Reading

You can find more information about ScriptCraft on my blog.

Additional Resources

CoderDojo Athenry have some excellent tutorials for younger programmers who have used Scratch and are interested in Modding Minecraft using JavaScript. In particular, they have an excellent Scratch - to - JavaScript tutorial which explains Scratch programs and how to do the same thing in JavaScript.

I highly recommend the series of tutorials provided by CoderDojo Athenry.

Developer Chris Cacciatore has created some interesting tools using ScriptCraft:

Docker

To launch a container with SpigotMC and ScriptCraft you can just do

  docker run -p 25565:25565 -it tclavier/scriptcraft

You can find all files used to build this container in github project: docker-scriptcraft

scriptcraft's People

Contributors

aplhk avatar carlrobert avatar cgmartin avatar cobbzilla avatar edonaldson avatar gitter-badger avatar jasonk avatar jonathanperret avatar jwulf avatar kabiroberai avatar kmlawson avatar kylehowells avatar m4chinations avatar marcogerosa avatar marcvangend avatar monowii avatar mrvoltz avatar nixnax avatar pvginkel avatar rupl avatar schramp avatar shaneriley avatar stlee987 avatar tclavier avatar tiagofassoni avatar tonygravagno avatar triyuga avatar trmfreitas avatar vorburger avatar walterhiggins avatar

Stargazers

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

Watchers

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

scriptcraft's Issues

JS not loading js-plugins

Here is the log

2013-01-04 23:12:39 [INFO] Starting minecraft server version 1.4.5
2013-01-04 23:12:39 [INFO] Loading properties
2013-01-04 23:12:39 [INFO] Default game type: SURVIVAL
2013-01-04 23:12:39 [INFO] Generating keypair
2013-01-04 23:12:39 [INFO] Starting Minecraft server on *:25565
2013-01-04 23:12:40 [INFO] This server is running CraftBukkit version git-Bukkit-1.4.5-R1.0-b2543jnks (MC: 1.4.5) (Implementing API version 1.4.5-R1.0)
2013-01-04 23:12:40 [INFO] [ScriptCraftPlugin] Loading ScriptCraftPlugin v0.01
2013-01-04 23:12:40 [INFO] Preparing level "world"
2013-01-04 23:12:40 [INFO] Preparing start region for level 0 (Seed: 3408191539297853076)
2013-01-04 23:12:41 [INFO] Preparing start region for level 1 (Seed: 3408191539297853076)
2013-01-04 23:12:41 [INFO] Preparing spawn area: 28%
2013-01-04 23:12:41 [INFO] Preparing start region for level 2 (Seed: 3408191539297853076)
2013-01-04 23:12:41 [INFO] [ScriptCraftPlugin] Enabling ScriptCraftPlugin v0.01
2013-01-04 23:12:41 [INFO] [ScriptCraftPlugin] ScriptCraft enabled.
2013-01-04 23:12:42 [INFO] [ScriptCraftPlugin] js> load("C:\CraftBukkit\js-plugins\drone.js")
2013-01-04 23:12:42 [SEVERE] java.io.FileNotFoundException: C:CraftBukkitjs-pluginsdrone.js (The system cannot find the file specified)
2013-01-04 23:12:42 [SEVERE] at java.io.FileInputStream.open(Native Method)
2013-01-04 23:12:42 [SEVERE] at java.io.FileInputStream.(Unknown Source)
2013-01-04 23:12:42 [SEVERE] at java.io.FileReader.(Unknown Source)
2013-01-04 23:12:42 [SEVERE] at net.walterhiggins.scriptcraft.ScriptCraftEvaluator.load(ScriptCraftEvaluator.java:104)
2013-01-04 23:12:42 [SEVERE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-01-04 23:12:42 [SEVERE] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-01-04 23:12:42 [SEVERE] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-01-04 23:12:42 [SEVERE] at java.lang.reflect.Method.invoke(Unknown Source)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:386)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.gen._cmd__1._c_script_0(:1)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.gen._cmd__1.call()
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.gen._cmd__1.call()
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.gen._cmd__1.exec()
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.Context.evaluateString(Context.java:1079)
2013-01-04 23:12:42 [SEVERE] at net.walterhiggins.scriptcraft.ScriptCraftEvaluator.eval(ScriptCraftEvaluator.java:65)
2013-01-04 23:12:42 [SEVERE] at net.walterhiggins.scriptcraft.ScriptCraftPlugin.onEnable(ScriptCraftPlugin.java:30)
2013-01-04 23:12:42 [SEVERE] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
2013-01-04 23:12:42 [SEVERE] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
2013-01-04 23:12:42 [SEVERE] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
2013-01-04 23:12:42 [SEVERE] at org.bukkit.craftbukkit.v1_4_5.CraftServer.loadPlugin(CraftServer.java:272)
2013-01-04 23:12:42 [SEVERE] at org.bukkit.craftbukkit.v1_4_5.CraftServer.enablePlugins(CraftServer.java:254)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.MinecraftServer.j(MinecraftServer.java:320)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.MinecraftServer.e(MinecraftServer.java:299)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.MinecraftServer.a(MinecraftServer.java:258)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.DedicatedServer.init(DedicatedServer.java:147)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.MinecraftServer.run(MinecraftServer.java:398)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.ThreadServerApplication.run(SourceFile:856)
2013-01-04 23:12:42 [INFO] [ScriptCraftPlugin] Error - File not found C:CraftBukkitjs-pluginsdrone.js
2013-01-04 23:12:42 [SEVERE] org.mozilla.javascript.EvaluatorException: Couldn't open file "C:CraftBukkitjs-pluginsdrone.js". (#1)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:64)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.Context.reportError(Context.java:872)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.Context.reportError(Context.java:890)
2013-01-04 23:12:42 [SEVERE] at net.walterhiggins.scriptcraft.ScriptCraftEvaluator.load(ScriptCraftEvaluator.java:110)
2013-01-04 23:12:42 [SEVERE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-01-04 23:12:42 [SEVERE] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-01-04 23:12:42 [SEVERE] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-01-04 23:12:42 [SEVERE] at java.lang.reflect.Method.invoke(Unknown Source)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:386)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.gen._cmd__1._c_script_0(:1)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.gen._cmd__1.call()
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.gen._cmd__1.call()
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.gen._cmd__1.exec()
2013-01-04 23:12:42 [SEVERE] at org.mozilla.javascript.Context.evaluateString(Context.java:1079)
2013-01-04 23:12:42 [SEVERE] at net.walterhiggins.scriptcraft.ScriptCraftEvaluator.eval(ScriptCraftEvaluator.java:65)
2013-01-04 23:12:42 [SEVERE] at net.walterhiggins.scriptcraft.ScriptCraftPlugin.onEnable(ScriptCraftPlugin.java:30)
2013-01-04 23:12:42 [SEVERE] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
2013-01-04 23:12:42 [SEVERE] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
2013-01-04 23:12:42 [SEVERE] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
2013-01-04 23:12:42 [SEVERE] at org.bukkit.craftbukkit.v1_4_5.CraftServer.loadPlugin(CraftServer.java:272)
2013-01-04 23:12:42 [SEVERE] at org.bukkit.craftbukkit.v1_4_5.CraftServer.enablePlugins(CraftServer.java:254)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.MinecraftServer.j(MinecraftServer.java:320)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.MinecraftServer.e(MinecraftServer.java:299)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.MinecraftServer.a(MinecraftServer.java:258)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.DedicatedServer.init(DedicatedServer.java:147)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.MinecraftServer.run(MinecraftServer.java:398)
2013-01-04 23:12:42 [SEVERE] at net.minecraft.server.v1_4_5.ThreadServerApplication.run(SourceFile:856)
2013-01-04 23:12:42 [INFO] [ScriptCraftPlugin] Exception: Couldn't open file "C:CraftBukkitjs-pluginsdrone.js". (#1)
2013-01-04 23:12:42 [INFO] Server permissions file permissions.yml is empty, ignoring it
2013-01-04 23:12:42 [INFO] Done (1.974s)! For help, type "help" or "?"

Example Scripts Expect drone.js To Be One Level Higher

The example scripts expect the drone.js file to be up one level in the dir structure. However, the install instructions say to play all JS files into one flat dir.

Obviously not a big deal!

BTW: Thanks for this--it's a lot of fun.

Add a new command which is executable by all (non-ops too)

The goal is to be able to add new console commands via javascript - however, only operators should have access to the js command so for an op to create a new javascript function and have that function executable by all, it needs to be exposed via another command.

That command will be jsp - (short for js plugin , or js proxy or js protected - take your pick). jsp won't in fact evaluate any javascript code - that would leave the server wide open for all players - instead it looks up a lookup table of javascript functions which have been exposed for use by players.
For example...

/jsp home set

will make the plugin lookup a table to see if there is a 'home' javascript function defined and if there is it calls that function passing in each argument. The distinction between js and jsp is this - js evaluates javascript. jsp looks up a table for a specific javascript function (the 1st parameter supplied to jsp) and invokes that function passing in all subsequent parameters.
The plan is to use the common (among bukkit plugins/servers) home plugin commands as a test-bed.

basic commands:
/jsp home - takes the player home.
/jsp home set - sets the player's current location as home.
/jsp home delete - delete the home reference
/jsp home help - prints help about the command

social commands:
/jsp home - go to 's home.
/jsp home list - display whose homes you can visit
/jsp home ilist - display who can visit your home
/jsp home invite - invite player to your home
/jsp home uninvite - uninvite
/jsp home public - make your home public (anyone can visit)
/jsp home private - make your home private

admin commands:
/jsp home listall - list all of the homes on the server.
/jsp home clear - clears player's home from server.

See http://dev.bukkit.org/server-mods/myhome/ for reference.

Negative height for boxes etc. to build down instead of up

It would be nice if one could specify negative values for height when calling box() etc. to build downwards instead of upwards.

Of course the more or less same result can be achieved by down(20).box(4,1,20,1) instead of (box,4,1,-20,1) but that feels like a lot of typing.

"You don't have ScriptCraftPlugin..js"

Strange problem... on one of my machines I get this error when trying to run any ScriptCraft function. For example, I type '/js echo("hi")' and I see the error above. The CraftBukkit console shows that the command was received (it says " issued server command: ..."). ScriptCraft has worked on this machine before, but I don't know what changed or where to troubleshoot it now. I haven't yet set up a development environment to debug it. It's an Ubuntu 64-bit machine using Oracle Java 7.10, I've cleared out ~/.minecraft and re-downloaded everything. Note the double periods in the error message, maybe that's a clue?

Need to define cuboid area

Is there a way for you to define a cuboid area?
I'm trying to develop a pvp script. But I need to define a cuboid area with a tool.
(As in world edit with a wooden axe)
So anyone can set a cuboid area to play pvp in teams.
Can anyone help me?

Thanks, Fearful.

Extensions to Drone

Can these be added to the Drone object? I haven't pulled the latest, so they may already be there:

Drone.extend('getLocation', function() {
return org.bukkit.Location(this._getWorld(), this.x, this.y, this.z);
});
Drone.extend('setPos', function(x, y, z, dir) {
if (x) this.x = x;
if (y) this.y = y;
if (z) this.z = z;
if (dir) this.dir = dir;

return this;

});

Perform js excecution in background

When running a particularly lengthy script, the server gets bogged down and disconnects users. It would be nice if console commands and loaded scripts were launched in a separate thread with limited computational resources on the server (execute a limited number of js statements per second or similar) to prevent it from disconnecting users.

Additionally, each command could be given its own id so we can kill the thread if needed (infinite loop for example). Current executing commands could be listed with a function appropriately named (/js jobs, /js kill :id)

Alternatively, provide a data structure that lets the user opt into a separate managed thread of execution easily in javascript without having to dive into usage of java.lang.Thread directly.

Thanks,
Alex

"You don't have scriptcraft.evaluate permission"

Log:

30.01 18:05:29 [Server] INFO Wh1teT1ger died
30.01 18:05:18 [Server] INFO Wh1teT1ger[/82.46.99.205:51649] logged in with entity id 28 at ([Test] -964.5, 4.0, -382.5)
30.01 18:05:10 [Server] Startup Done (1.996s)! For help, type "help" or "?"
30.01 18:05:10 [Server] INFO Server permissions file permissions.yml is empty, ignoring it
30.01 18:05:10 [Server] INFO [ScriptCraftPlugin] Enabling ScriptCraftPlugin v1.4.7-20130126
30.01 18:05:10 [Server] INFO Preparing spawn area: 28%
30.01 18:05:10 [Server] INFO Preparing start region for level 1 (Seed: -8069096820369105479)
30.01 18:05:09 [Server] INFO Preparing start region for level 0 (Seed: -8069096820369105479)
30.01 18:05:08 [Server] INFO ----- ------------------- -----

The log shows no error and actually shows that scriptcraft is running. However when I try and execute the command: "/js up().box('35:15', 4, 9, 1)" I get the message "You don't have scriptcraft.evaluate permission". I can kill ('/kill') myself on the server so surely it can't be the permissions granted to the player by multicraft.

What's wrong? My js-plugins folder is in the '/' folder rather than in the 'plugins' folder. Could this be the issue?

MCP installation mechanism doesn't work

I installed MCP as directed. Is this now deprecated? Anyway, I followed the instructions and when recompiling I get errors stating that ScriptCraftEvaluator, ScriptCraftMCP, etc classes are missing. So I copied those over to my mcp726a/src/minecraft/net/minecraft/src directory too. Then recompiling and reobfuscating works fine. I copy the reobfed classes to the minecraft.jar file and the game runs.

Now I try to load the cottage.js file as in the getting started instructions. But I get an error that __folder is undefined. That seems to be the mechanism to load dependent javascript files. So I try a /js var __folder = '' so I can load at least 1 of the javascripts... no luck. I can't seem to load any javascripts even with absolute directory paths. What's with __folder?

I'm on a Mac with Mountain Lion.

I want students to be able to program JavaScript without connecting to a server. That's why I went this route. I guess I can just try out the Bukkit thing and have a server installed locally on their machines?

reorganise source directory

rename bukkit-plugin to src
move js-plugins to src/javascript
add readme.md for the src/javsacript directory and subdirectories.

/js load() not finding the plugins for bukkit

When I try: /js load('./castle')

I get an error about the file not being found. I have placed drone.js, fort.js, and castle.js in js-plugins which is found in the craftbukkit directory.

What is the correct path for the load() call?

Cannot read property "x" from null

When trying to load drone.js in the bukkit version, I get the following error:

 org.mozilla.javascript.EcmaError: TypeError: Cannot read property "x" from null (/Users/abrams/craftbukkit/js-plugins/drone.js#265)

Time out while browsing for .js to load.

Trying to load the script manually (still not loading on it's own with out issue while in js-plugins) and it gives a timeout if you take to long to find what your looking for. (Under a minute).

2013-01-05 00:40:31 [INFO] undefined�[m
2013-01-05 00:40:31 [INFO] [ScriptCraftPlugin] undefined
2013-01-05 00:40:31 [INFO] p4r4d0x42 lost connection: disconnect.endOfStream

Need to improve bukkit event handling

No way to unregister a listener.
Suspect the current bukkit.on() implementation is broken, Listener and RegisteredListener should be the same object?

Pyramid Generator

load(__folder + "drone.js")
//
// constructs a pyramid
//
Drone.extend('pyramid', function(block, height) {
this.chkpt('pyramid');

for (var i = height; i > 0; i -= 2) {
    this.box(block, i, 1, i).up().right().fwd();
}

return this.move('pyramid');

});

Drone.extend('pyramid0', function(block, height) {
this.chkpt('pyramid0');

for (var i = height; i > 0; i -= 2) {
    this.box0(block, i, 1, i).up().right().fwd();
}

return this.move('pyramid0');

});

Object Variable Names Squashed

Defining objects in the /js console or loaded from script files with /js load() are getting "squashed".

Example:
/js var myObj = {test:"hello"};

The engine now sees the following variables as defined:
myObj
myObjtest

Notice no '.' separator on myObjtest
myObjtest should never be defined in this manner; the test property should only be accessible via myObj.test

Thanks,
Alex

Coffeescript?

Have you considered Coffeescript? It seems much easier to teach than Javascript.

I've had success with teaching my oldest a bit, but that just may be my familiarity with Coffeescript compared to Javascript.

How to reload

I don't see that the reload command is exposed anymore. how do you reload JS files that you create and modify in the js_plugins directories?

For instance, I'd like to create a folder js-plugins/mine to put my own js files in as I develop and test, but I can't figure out how to get modified files to reload unless I shut down and restart the bukkit server.

In addition, if we create our own useful plugins (like a pyramid, similar to your temple, or an entire dungeon creator), do you want to know about them to include in your repository?

Question on generating entities

I don't know if this is the best/right place to leave these kind of questions. If not, please direct me to the correct place, and I will glad ask them there.

I'm trying to generate entities to populate some structures that I am creating. I would like to do something like the following, but I cannot get it to work:

/js self.world.spawnEntity(self.location.clone().add(10,0,0),org.bukkit.EntityType.PIG)

As a simple example, I was hoping this would spawn a pig 10 blocks from me. But I get an error.

getBlock() method undefined

On the github homepage for ScriptCraft it lists the following method:

getBlock( x, y, z ) - returns the blockId and metadata at the given location (if no coordinates are given the cross-hair location is used)

But if I do a /js getBlock() I get the following error:

15:37:45 [SEVERE] Caused by: sun.org.mozilla.javascript.internal.EvaluatorException: Can't find method org.bukkit.craftbukkit.v1_4_R1.CraftWo
rld.getBlockAt(sun.org.mozilla.javascript.internal.Undefined,sun.org.mozilla.javascript.internal.Undefined,sun.org.mozilla.javascript.interna
l.Undefined). (<Unknown source>#94)
15:37:45 [SEVERE]       at sun.org.mozilla.javascript.internal.DefaultErrorReporter.runtimeError(Unknown Source)
15:37:45 [SEVERE]       at sun.org.mozilla.javascript.internal.Context.reportRuntimeError(Unknown Source)

<Unknown Source> in Errors

When a script file throws an error, the error message gives an ugly Error. For example:
at line number 1 (#33) in at line number 33

EDIT:
Inserting something like
this.engine.put(this.engine.FILENAME,boot.getCanonicalPath().replaceAll("\","/"));
after line 100 of ScriptCraftPlugin.java
could give better messages.

Can't call putBlock or putSign

I can call the other methods listed on the ScriptCraft github homepage. And I can call things like cottage(). But /js putBlock(246,64,80,5,0); gives me the following error when trying to put a wood block near me:

15:28:54 [SEVERE] javax.script.ScriptException: sun.org.mozilla.javascript.internal.WrappedException: Wrapped java.lang.NullPointerException
(<Unknown source>#70) in <Unknown source> at line number 70
15:28:54 [SEVERE]       at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
15:28:54 [SEVERE]       at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)

/js putBlock(246, 64, 80, 5, null); gives me the following error which is a little different:

15:29:34 [SEVERE] javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Can't find method org.bukkit.craftbuk
kit.v1_4_R1.block.CraftBlock.setTypeIdAndData(number,null,boolean). (<Unknown source>#70) in <Unknown source> at line number 70
15:29:34 [SEVERE]       at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
15:29:34 [SEVERE]       at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
15:29:34 [SEVERE]       at javax.script.AbstractScriptEngine.eval(Unknown Source)

What should I be specifying for metaData? Am I doing something wrong?

Forge API

Forge would be a good api to expose

Alignment of blocks changing

The script below recreate the problem if you call it with /js track(48, 15);

When facing one direction the track comes out correctly. In particular the detector, powered, detector grouping of tracks is fine.

However, if you turn and create a track perpendicular to this. Then the second detector rail, in each boost grouping is laid down at right angles to the rest of the track. I'd like the say the realignment of the track block is random, but there does appear to be a pattern to it.

Drone.extend('track', function(length, boostGap)
{
    if ( typeof length == "undefined" ) {
        length = 10;
    }
    if ( typeof boostGap == "undefined" ) {
        boostGap = 15;
    }

    this.chkpt('track');
    this.box(1,3,1,length) // Track base - type, width, height, depth
        .up().box(0,3,2,length) // clear above
        .right().box(66,1,1,length); // Lay the basic initial track

    var left = length;

    while ( left >= 3 ) {
        this.box(28,1,1,1).fwd() // Detector Rail
            .box(27,1,1,1).fwd() // powered rail
            .box(28,1,1,1).fwd(boostGap-2)
        left = left - boostGap;
    }

    return this
});

Announce when load() is successful by default

When I first got started I was luckily able to check the server console, but I never got any positive sign that drone.js et. al were loading.

I found a line claiming to do this in _scriptcraft.js -- where do we set that verbose flag? Either way since this is basically the first thing someone does it might eliminate some confusion when people get started.

.class File Distribution?

Forgive me if I'm misinterpreting something, but in step seven of your installation process, you mention taking the compiled files and repackaging them back into the minecraft.jar file.

Are these files .class files? Because the standard way of distributing Minecraft mods is distributing those .class files themselves for people to drop into their instance of Minecraft. I know we'll still (might) have to set up Rhino, and some directories, but if I'm right it would knock off a good chunk of the installation progress if each person who wanted to use the mod didn't need to create these files themselves.

Possible to have multiline JavaScript?

Is it possible to allow users to run longer JavaScript code than a single line? The line is limited in length as it is. Ideally files can be loaded. Seems like this used to be supported via the /js load() command for the MCP version. Is there a similar mechanism for the Bukkit version?

Levers only appear in 1 orientation

Is there a way to make levers appear in a particular orientation? No matter what I do, they always appear the same way, whether by drone or by the putBlock method. I have students create elaborate circuits or other contraptions and then they have to place levers to make them work. I previously had to get a server plugin to disable all destroying and placing of blocks, so they have to use ScriptCraft to do so (way too distracting otherwise).

Support for Bukkit/Craftbukkit

This is pretty amazing work - I'm currently diving deep to see the potential of it all. It would be awesome if there was a way to make this compatible with Bukkit/Craftbukkit.

castle

Where would one find the js code for castle()?

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.