SpellScript

SpellScript is a Bukkit plugin which allows the user to manipulate the game environment to a degree using JavaScript.

The basic unit of the plugin is the Node. In Javscript the node is represented by the variable “node”. The node is the object through which the user will code. To create a node, the user first needs to encode the node’s command onto an ItemStack. This is done by writing the javascript command into a book or book-and-quill and then, while holding the book in your hand, running the command /SpellScript. Running this command will print the script onto the item stacks of any items that are within 5 meters of you. These item stacks now store the command and are ready to be activated.

You will want to use an anvil to name the item stacks. Once you name the item anything you want (it has to be without spaces), you can then say that word and as long as you are within 10 meters of the item on the ground, in an item frame, or in a player’s inventory, the item will run the script inside of it. You can also give the script arguments by adding them after the activation word. These arguments will be accessible through “node.getArgs()”.

The node will appear in the world as a mobspawner flame effect. The node has an attribute called “power” which it uses to execute some tasks. Looking through the javadocs for the node class will show you how much each task costs in power. Once the node runs out of power, it will die, even if it’s command hasn’t finished executing.

Keep in mind: All methods causing a change to anything in Minecraft (placing a block, setting an entity on fire, etc.) take at least 1 tick to occur. Methods that only retrieve data or affect Nodes occur immediately. For example, if node1 is taking health away from a player and node2 is taking power away from node1, then node2 will probably deplete node1 of power much sooner than node1 will deplete the player of health.

When you activate a node, you will get a piece of paper with a long lore. Right clicking this piece of paper in your hand will kill the node immediately.

The source for this plugin can be found here: https://github.com/cakenggt/SpellScript

The JavaDocs for the plugin can be found here (make sure to look at the docs for Node): http://aleclownes.com/jd/SpellScript/

To view the methods made available to JS, look at the javadocs or the source at github. Only public methods in Node and all of the Wrappers are usable in scripts.

Take a look at the forums for spell development and examples: http://dev.bukkit.org/bukkit-plugins/spellscript/forum/

Here are some example scripts:

//This teleports the caster to the node’s location
node.teleport(node.getCaster(), node.getLocation());

//This gets the latest chat that was said and repeats it to the caster
var chat = node.getChatWrapper();
while (true){
	if (!chat.equals(node.getChatWrapper())){
		chat = node.getChatWrapper();
		node.announce(node.getCaster(), chat.getMessage())
	}
}

Comments

Posts Quoted:
Reply
Clear All Quotes

About This Project

Categories

Members

Recent Files