Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.
Andy C edited this page Sep 16, 2015 · 3 revisions

walk in direction <left/right> for this many seconds <number>

The walk block makes your character walk in the specified direction for the specified number of seconds.

If no duration is specified, your character will walk for 1 second.


Block Definition:

Blockly.Blocks['walk'] = {
    init: function() {
        this.appendDummyInput()
            .appendField("walk in direction")
            .appendField(new Blockly.FieldDropdown([["left", "left"], ["right", "right"]]), "direction");
        this.appendValueInput("length")
            .setCheck("Number")
            .appendField("for this many seconds");
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setColour(160);
        this.setTooltip('Moves your character in the specified direction for the specified number of seconds');
        this.setHelpUrl('https://github.com/ChildrenOfUr/Ilmenscript/wiki/walk');
    }
};

Code Generator:

Blockly.JavaScript['walk'] = function(block) {
    var dropdown_direction = block.getFieldValue('direction');
    var value_length = Blockly.JavaScript.valueToCode(block, 'length', Blockly.JavaScript.ORDER_ATOMIC);
    if (value_length == '') {
        return 'transmit("ilmenscript_walk' + dropdown_direction + '", 1);\n';
    }
    return 'transmit("ilmenscript_walk' + dropdown_direction + '", ' + value_length + ');\n';
};

Block Factory

Ilmenscript is based on Google Blockly. Check the official Blockly wiki for help on the Blockly core blocks (everything outside of the Game category).

Clone this wiki locally