User:Sulai7200/Ideas/Scripting

This webpage is about how to implement scripting in minecraft. Scripting should allow scripting blocks, items and monsters (NPC). The server admins may execute any script command 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. Scripts of such game content are 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. When the server starts up, the server admin may choose the user extensions packs he wants to allow on his world:

[x] default package (Mojang) [ ] cool user extension from sulai [x] action pack from CompanionCube [x] my global admin scripts

On startup, the scripted definition of chaos gun and ammo are loaded into the game additionally to the default definitions of Mojang. If clients connect to that server, both the world map, and the scriped definitions are downloaded. If CompanionCube's ammo is defined to be produced by some recipe, any user connected to that server may now produce ammo.

Aditionally, global admin scripts are selected. Those may define various stuff, in this example it reacts on users chat messages like "/playerlist" and "/kit armour". See server side script examples.

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's why scripting does not affect game performance.

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.