

ScriptCraft: Building cool things using Javascript in Minecraft - dpearson
http://walterhiggins.net/blog/ScriptCraft

======
neumann_alfred
Considering how much of Minecraft can be about grinding for resources or MCMMO
levels... imagine being able to script the player, or even being allowed "bot
teammates" you can script! Since that part of it could run on _just_ the
client (minus small interface stuff on the server for clients to request basic
info and send player input), you could go all out with as much advanced AI as
you can muster, without draining the server of any resources... while having a
bunch of minions that gather resources, fight, explore and/or build (if you
have the spare processing power/memory and the scripts.. so I guess it would
be dominated by people who have many crazy fast machines and mad coding
skills.. but I'd still love derping around in it, too. There's always robbing
those bots manually haha..).

Apart from these bots acting on their own, players could send commands to bots
via private message or towny/faction chat. Oh, and speaking of towny and
factions, or any sort of teams reallly: what if this sort of "Minecraft Robot
Wars" competition was set up so there'd be a few human players, with each
having their bots who know their owners, but otherwise nobody knowing who is a
player or a bot, and who is on what side... ?!

So you could e.g. either all join up in one town/faction and give your
alliance away for more efficiency/power, or split up and try to play all sorts
of diplomatic games via chat and actions, and try to deceive bots/people long
and short term. Minecraft online is so much about trust, I never played
another game that came close; and while that can be very frustrating and petty
with humans, it seems _hilarious_ to try to code bots that act real or
otherwise deceive ^^ Especially if everybody knows that it's the goal of the
game.

Please, nobody make this happen, this would destroy my life. Even just
thinking about the possibilities is addicting haha.

~~~
chrislloyd
We wrote a library to do just that (sorry): <https://github.com/minefold/node-
minecraft>

It needs a small fixes to work with the current version of Minecraft but it's
pretty feature complete. We were using it internally for load testing (until
we made our architecture support multiple games).

------
Cogito
This is cool, but for the server it is already possible to use a number of
scripting languages.

By using the Bukkit server mod, which provides a stable plugin API, it is
relatively easy to add a wrapper around a scripting engine [0].

For example, a plugin providing Rhino support [2] and one providing python
support [2].

I would recommend either porting your work to the Bukkit framework, or working
with one of the existing plugins to include some of the cool stuff you have
made.

I don't currently know what the most popular scripting plugin currently
available is, but I'm sure you can find it with a bit more digging than I have
done.

[0]
[http://dev.bukkit.org/search/?scope=projects&search=scri...](http://dev.bukkit.org/search/?scope=projects&search=script)

[1] <http://dev.bukkit.org/server-mods/redstonetorch/>

[2] <http://dev.bukkit.org/server-mods/pydevtools/>

~~~
walterh
Thanks for the bukkit recommendation - it really is a great minecraft
framework to code against. I've since added a ScriptCraft bukkit plug-in...
[https://github.com/walterhiggins/ScriptCraft/blob/master/buk...](https://github.com/walterhiggins/ScriptCraft/blob/master/bukkit.md)

~~~
Cogito
No worries :)

I used to be very active on the team there, but haven't contributed any code
for a while now. I get the urge almost every week, so maybe I should jump back
in for a bit.

It has its problems, but is miles ahead from where we started and really does
enable plugin authors in a way straight modding never can.

------
jbert
This is a _great_ gateway drug for getting kids into coding.

The JS language also allows a transition to html5/web stuff (cool web pages
they and their friends can see with some simple-to-setup hosting) and perhaps
ultimately server side (nodejs).

And a child walking that path would then be exposed to enough ideas/different
environments that learning a different language would be a natural next step.

This is a pretty exciting idea. I wonder how easy it can be made. i.e. I
wonder how much of the distracting tool-based detail can be swept to one side.

~~~
bradleyland
I'm currently introducing my 10 year old niece to programming using
ComputerCraft, a single player mod that introduces several programmable
objects in to the Minecraft world. Installing is a bit of an exercise, because
it requires Forge, but it is otherwise worth it. I recommend using MCPatcher
to load Forge, then just drop the ComputerCraft zip in to the /mods folder
inside your Minecraft data folder.

<http://www.computercraft.info>

~~~
driverdan
Using MagicLauncher[1] makes it much easier.

1: [http://www.minecraftforum.net/topic/939149-launcher-magic-
la...](http://www.minecraftforum.net/topic/939149-launcher-magic-
launcher-100-mods-options-news/)

~~~
bradleyland
Wow! Thanks so much for that link.

One of the downsides of the diversity in the Minecraft modding community is
that it can be difficult to identify the "best" way to do something. New tools
come and go, and compatibility wanes when new releases hit.

------
exemd
We experimented with this kind of scripting in Manic Digger:
[http://manicdigger.sourceforge.net/forum/viewtopic.php?f=7&#...</a><p>It
would be better if it had exposed all the commands from the server modding
api: <a href="http://manicdigger.sourceforge.net/news/wp-
content/uploads/2012/08/Modding.png"
rel="nofollow">http://manicdigger.sourceforge.net/news/wp-
content/uploads/2...</a> . (note: old version)<p>I think JS would be useful
for making Adventure game mode where blocks (script-boxes) contain javascript
code that spawns NPCs, defines dialog trees, quests, items.<p>Another example:
Spleef arena control room <a
href="http://mdgallery.strangebutfunny.net/View?id=103"
rel="nofollow">http://mdgallery.strangebutfunny.net/View?id=103</a>

------
Macuyiko
Cool. As a matter of fact, about a week ago I tried to do something similar by
trying to integrate Python with Minecraft. I actually did expose the full
Bukkit API to Python (easy enough to do), so all its commands are available.

I didn't really like the "type your code in Minecraft chat"-approach many
similar projects were/are taking (i.e. "/js myCodeHere()" in chat) and wanted
a proper interpreter window. To integrate the Java-based Bukkit API with
Python, I used Jython. The result is something similar as shown here:
<http://www.minecraftwiki.net/wiki/Pi_Edition>

I've yet to put up a blog post or something, but I've thrown together a quick
video of me playing with it (it's a bit slow so feel free to forward) here:
<http://www.youtube.com/watch?v=rI3PfgCSI7Y>

I think something like this could really help in getting kids excited about
programming. Back in the day, I started learning programming with LOGO
<http://en.wikipedia.org/wiki/Logo_(programming_language)> , a quirky
adaptation of LISP, but where you could immediately see your results drawn on
screen. It's cool to see Minecraft as some sort of modern "canvas" for
programming.

~~~
whatshisface
<http://dev.bukkit.org/server-mods/python-plugin-loader/>

I have been using a python-bukkit plugin layer for quite some time for a lot
of small administrative plugin tasks on my private server. You should check
out his project, it's on github.

------
alttab
I am a Minecraft server owner (<http://craftworksfactionrpg.net>) and I've
used a scripting plugin extensively to add server-side functionality to my
server. The plugin is called 'Skript', <http://dev.bukkit.org/server-
mods/skript>, and has a fairly large exposure of Bukkit APIs.

With this, I've created an entirely custom RPG class plugin, and a complete
dungeon editor.

Problem was, with the 1.4.6 update, Skript stopped working in some areas so
I've been forced to go into Eclipse and write Java with the bukkit APIs
directly. For someone with experience, jumping into Bukkit plugin development
was a piece of cake, but I was able to build out very very very sophisticated
plugins with Skript before the update broke it.

------
DanBC
This is, potentially, amazing.

Minecraft is aiming for some extensive modding re-write, which will make
installing and using mods easier. I 'm not sure how much work the author will
have to do to get scriptcraft running under the new system.

I'm also interested in how it compares to existing world building tools. Most
of those are out-of-minecraft software. But things like world edit, etc.

~~~
walterh
I would love if the Minecraft guys provided Javascript scriptability without
the need for a mod.

~~~
ricardobeat
That would ruin the game for most players. It _has_ to be a server mod.

~~~
walterh
Agreed. It makes sense for admins to be able to build using javascript but
would lead to accidental/deliberate griefing if all players on a server had
it.

------
walterh
It looks like Bukkit might be a perfect fit for ScriptCraft. Bukkit seems to
have wrappers around a lot proprietary minecraft code. The ability to use
those wrappers in Javascript would mean that once ScriptCraft was installed,
futher Bukkit plugins could be written entirely in Javascript (no need for
java).

------
thehodge
Isn't this sort of what the Raspberry Pi version of minecraft does?

~~~
kaidenshi
Sort of, yes. Except that version will support many languages instead of just
JS. In the demo videos you see them using Python commands. The concept is
almost exactly the same, though the guys at Mojang are building the
interpreter into the game itself instead of it being a mod.

More info here: <http://www.minecraftwiki.net/wiki/Pi_Edition>

