The Video

explodeo.js

/*global require, server, Packages*/

var items = require("items"),
    recipes = require("recipes"),
    events = require("events");

var bow = items.bow(1),
    tnt = items.tnt(1),
    explodeBow = items.bow(1),
    nuclearBow = items.bow(1),
    cmArrow = Packages.net.canarymod.api.entity.Arrow,
    EXPLOSIVE_YIELD = 2.5,
    NUCLEAR_YIELD = 10;

explodeBow.setDisplayName("Bow of Exploding");
explodeBow.setLore("Excite. Very boom.");

var explodeBowRecipe = recipes.create({
    result: explodeBow,
    ingredients: {
        B: bow,
        T: tnt
    },
    shape: [
        "   ",
        "BT ",
        "   "
    ]
});

server.addRecipe(explodeBowRecipe);

nuclearBow.setDisplayName("Nuclear Bow");
nuclearBow.setLore("The only way to win is to not play the game.");

var nuclearBowRecipe = recipes.create({
    result: nuclearBow,
    ingredients: {
        B: bow,
        T: tnt
    },
    shape: [
        "   ",
        "TBT",
        "   "
    ]
});

server.addRecipe(nuclearBowRecipe);

function onArrowHit(event) {
    var projectile = event.projectile,
        world = projectile.world,
        loc = projectile.location,
        shooter = projectile.owner;

    if (projectile instanceof cmArrow) {
        if (shooter.inventory.itemInHand.getDisplayName() === "Bow of Exploding") {
            projectile.destroy();
            world.makeExplosion(shooter, loc, EXPLOSIVE_YIELD, true);
        } else if (shooter.inventory.itemInHand.getDisplayName() === "Nuclear Bow") {
            projectile.destroy();
            world.makeExplosion(shooter, loc, NUCLEAR_YIELD, true);
        }
    }
}

events.projectileHit(onArrowHit);

The Documentation

In the video, I spoke about (and used!) some web pages in order to find out how to make my customized items. An “API”, as used below, is an “application programming interface” (wikipedia link) which is the set of modules and functions that computer programs give to programmers.

Docs, Copy/Paste and just playing around will get you far

I didn’t magically know how to make arrows explode. The scriptcraft/plugins/arrows.js file gave me the key points and I used the ScriptCraft API documentation to learn about the recipes modules so that I could create the Bow of Exploding. Don’t be afraid of copying code from one place and changing it around somewhere else. Also don’t be afraid of breaking stuff. Because computer software is so changeable experimentation is quick and the quickest way to learn!

Where To Go From Here

Try making custom recipes (how about a way to turn iron into gold?) or learning how to use other events to make the world react to things that happen within it.