User:Sulai7200/Ideas/Scripting

This wiki page is about how to implement scripting in minecraft. This would allow the community to define new blocks, items and monsters (NPC). Additionally, the server admins may execute any script command in the server console to change the served world and may define scripts that react on client chat messages.

If you like the idea, vote for it.

Basics
Game content is defined through blocks, items and monsters. Those three types of content should be scriptable. A extension developer may bundle his scripted contents in extension packs. Before starting a world, the server admin may choose what extension packs to play with. By default, only the standard minecraft pack is selected.

When the server starts up, it could look like this: play with: [x] default package (Mojang) [ ] cool user extension from sulai [x] action pack from CompanionCube [x] my global admin scripts

On startup, the scripted definition in CompanionCube's action pack are loaded into the game additionally to the default definitions of Mojang (earth, pick axe, shovel...). If clients connect to that server, both the world map, and the scriped definitions are downloaded. Those are now available game content for this world.

Scripts of such game content could be text files stored in a file system hierarchy like that:

default package creeper creeper.3d creeper.png script.js   redstone block redstone.png script.js   redstone dust item redstone dust.png script.js cool user extension from sulai brimstone block brimstone block.png script.js   brimstone item brimstone item.png script.js action pack from CompanionCube chaos gun script.js   ammo script.js my global admin scripts playerlist script.js   kit script.js

Each level-2 subfolder contains a script.js. This script defines the behavior of blocks, items, monsters and server scripts. Have a look at the script examples to get an idea. More content may be downloaded from community websites in such packages.

There is is fourth type of scripts: global server admin scripts. Those may define various stuff, in this example it reacts on users chat messages like "/playerlist" and "/kit armour". See server side script examples. Because of the package system, even such command sets may be distributed easily over community websites.

Security, Cheating, Performance
Because user scripted components are downloaded from the server, security is most important. We don't want a server that would crash the game because of some bad code. I propose to use Mozzilla's Rhino JavaScript, which lets the java programmer restrict script access to a blacklist of java classes.

Cheating: Because the scripted components are provided by the server, no more client-side-cheating is possible than it is right now. The server admin has full rights to do anything, of course.

Performance: Most blocks are inactive. They are only activated by some event, like hitting or breaking (see the scripting examples). That means, script execution takes a very tiny amount of total execution time. That's why scripting does not affect game performance. Additionally, scripting engines like Rhino JavaScript allow to be compiled into bytecode.

Impact on the community and Majong
Scripting support of that style adds long term playability to the game, since new game content is provided by the large minecraft community rather than by a team of a few developers. It would make it rather easy to provide object packages that fulfill good ideas about new blocks, items and monsters that flood http://getsatisfaction.com daily.

A lot of interesting game content in turn makes the game more interesting to a broader audience. It will raise sells of minecraft in a long term manner. It's a win-win situation:


 * The community may create and enjoy own game content.
 * That game content is only playable with minecraft, of course. The vast variability of available game content will raise sells.

Script Examples
See the scripting examples.

I added a "scriptable" tag to some of the ideas on getSatisfaction. Most likely, they can be implemented using scripts.