Where Can I Edit The JS of a Primitive in the Source Code? (Part 1)

It's my personal chromebook. And to my surprise, this chromebook can run really "hard on the cpu games" with only a bit of lag.

Like MCJE? (One of my computers was terrible at it; 1 frame/~10 seconds. Fortunately, my current computer runs it fine.)

It's a chromebook.

Why did you tell me that? I saw it from

Sorry, I misunderstood. Yes, It can run Minecraft Java Edition (but I don't know for sure because I can't run it. I CAN however run HUGE games that are on Roblox.)


confetti is a cool effect

objects.js, line 2371 is the start of

    if (category === 'motion') {

    } else if (category === 'looks') {

And it ends on line 2754 with


Some are actually in threads.js.

Don't confuse the palette generation tables in objects.js with the code that implements the primitives, which can be all over the place. (E.g., the red List blocks are mostly in lists.js.)

if they are all js thing why don't we have to turn js on to use them?

You do if you want to call them directly using the JS reporter.

If your writing a mod (like this one) then you can just bypass that restriction

SpriteMorph.prototype.doSwitchToCostume = function (id, noShadow) {
    var w = 0,
        h = 0,
    if (id instanceof List) { // try to turn a list of pixels into a costume
        if (this.costume) {
            // recycle dimensions of current costume
            w = this.costume.width();
            h = this.costume.height();
        if (w * h !== id.length()) {
            // assume stage's dimensions
            stage = this.parentThatIsA(StageMorph);
            w = stage.dimensions.x;
            h = stage.dimensions.y;
        id = Process.prototype.reportNewCostume(
    if (id instanceof Costume) { // allow first-class costumes
        this.wearCostume(id, noShadow);
    if (id instanceof Array && (id[0] === 'current')) {

    var num,
        arr = this.costumes.asArray(),
    if (
            [localize('Turtle'), localize('Empty')],
            (id instanceof Array ? id[0] : null)
    ) {
        costume = null;
    } else {
        if (id === -1) {
        costume = detect(arr, cst => cst.name === id);
        if (costume === null) {
            num = parseFloat(id);
            if (num === 0) {
                costume = null;
            } else {
                costume = arr[num - 1] || null;
    this.wearCostume(costume, noShadow);

This, in objects.js, lines 3765 to 3822, looks like the code that implements [scratchblocks]switch to costume [ v] :: looks[/scratchblocks].

Really? I tried it without the clone part and it worked.

testing script pic (1)
Doesn't make the sprite move 10 steps. If I broadcast __clone__init__, the sprite does move 10 steps.

Let me try again then. Nope you're right. I don't know what I was saying. Sorry.

No. See How to dual boot ChromeOS and Linux— a step by step guide | by Adrian Carroll | Medium. By default, crosh doesn’t support all the Linux commands, not even cd or ls. If you can't do that, How to Install Linux on Chromebook [Step-by-Step Guide] gives a similar result entirely through chromeos itself.

On the actual topic, all blocks are in threads.js or objects.js. I don't know how to determine for any individual block though. If you know the blockspec but not the internal name, look for it in blocks.js

List.prototype.asJSON = function (guessObjects) {
    // Caution, no error catching!
    // this method assumes that the list.canBeJSON()

    function objectify(list, guessObjects) {
        var items = list.itemsArray(),
            obj = {};
        if (canBeObject(items)) {
            items.forEach(pair => {
                var value = pair.length() === 2 ? pair.at(2) : undefined;
                obj[pair.at(1)] = (value instanceof List ?
                    objectify(value, guessObjects) : value);
            return obj;
        return items.map(element => {
            return element instanceof List ?
                objectify(element, guessObjects) : element;

    function canBeObject(array) {
        // try to determine whether the contents of a list
        // might be better represented as dictionary/object
        // than as array
        var keys;
        if (array.every(
            element => element instanceof List && (element.length() < 3)
        )) {
            keys = array.map(each => each.at(1));
            return keys.every(each => isString(each) && isUniqueIn(each, keys));

    function isUniqueIn(element, array) {
        return array.indexOf(element) === array.lastIndexOf(element);

    return JSON.stringify(objectify(this, guessObjects));

is in lists.js, and looks like it implements testing script pic (2).

Edit: Oh, and part 2 is coming up, if I'm not mistaken.

That does exist, but there is a wrapper function in threads.js. The actual block function takes two input, the first being json in this case.

This topic was automatically closed after reaching the maximum limit of 100 replies. Continue discussion at Where Can I Edit The JS of a Primitive in the Source Code? (Part 2).