How do you make a mod?

How do you make a Snap mod?

Chances are you don't really need to. Unless you intend to make really deep changes to the system, building your own blocks should be more than enough.

What is your use case, though? What kind of mod where you hoping to make?

I was just interested in how people make Snap mods.
I've figured out some stuff already, like adding new categories and blocks, but I don't know how to add code to the blocks.

Ah, I see. If the goal is educational then that's enough of an important use case!

Code to blocks is added in two places.

In objects.js you'll define the specification of your block. Look for line 406, for example:

        goToLayer: {
            only: SpriteMorph,
            type: 'command',
            category: 'looks',
            spec: 'go to %layer layer',
            defaults: [['front']]` 
        },

Then, in threads.js, you'll define the function that responds to the (in this example) goToLayer selector (line 3730):

Process.prototype.goToLayer = function (name) {
    var option = this.inputOption(name),
        thisObj = this.blockReceiver();
    if (thisObj instanceof SpriteMorph) {
        if (option === 'front') {
            thisObj.comeToFront();
        } else if (option === 'back') {
            thisObj.goToBack();
        }
    }
};

If you're just playing around, that should be enough, but if you were writing an actual mod best practice would be to not touch the sources. But that's for some other time! :slight_smile:

Thanks!