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.
scriptcraft/mcp-deprecated/CommandScript.java

44 lines
1.5 KiB
Java
Raw Normal View History

2012-12-27 13:55:05 +01:00
package net.minecraft.src;
/**
2013-01-05 13:25:14 +01:00
* This mod lets you load and run javascript to build structures which
* would otherwise be tedious. Build road networks, rows of houses,
* factories and sky-scrapers. ScriptCraft takes building to a whole
* new level by making it easy to create javascript scripts that do
* the building for you. The following code creates a simple cottage
* at the crosshair location or the player's current location...
*
2012-12-27 13:55:05 +01:00
* load("./drone.js");
2013-01-05 13:25:14 +01:00
* var drone = new Drone().chkpt('cornerstone');
* drone.box0(48,7,2,6) // 4 walls
2012-12-27 13:55:05 +01:00
* .right(3).door() // a door front-center
* .left(2).box(102) // windows left and right of door
* .right(4).box(102) //
2013-01-05 13:25:14 +01:00
* .move('cornerstone').up(2).prism0(53,7,6); // a gable roof
2012-12-27 13:55:05 +01:00
*
*/
2013-01-05 13:25:14 +01:00
public class CommandScript extends CommandBase
{
ScriptCraftEvaluator evaluator = null;
2012-12-27 13:55:05 +01:00
2013-01-05 13:25:14 +01:00
public String getCommandName() { return "js"; }
public int getRequiredPermissionLevel() { return 0; }
2012-12-27 13:55:05 +01:00
public void processCommand(ICommandSender par1ICommandSender, String[] args)
{
2013-01-05 13:25:14 +01:00
if (this.evaluator == null)
this.evaluator = new ScriptCraftEvaluator(new ScriptCraftMCP(this));
2012-12-27 13:55:05 +01:00
// Collect the arguments into a single string.
String s = "";
for (int i=0; i < args.length; i++) {
s += args[i] + " ";
}
// Now evaluate the string we've colected.
2013-01-05 13:25:14 +01:00
this.evaluator.eval(s,par1ICommandSender);
2013-01-05 13:25:14 +01:00
return;
2012-12-27 13:55:05 +01:00
}
}