horiyouta's picture
2410232053
c3de7ac
const adj = text => text.slice(2, text.length);
const con = text => text == `` || Number(text) < 2 ? ` #` : ` ${text}`.slice(text.length - 1, text.length + 2);
const stc = (block, generator, name) => adj(generator.statementToCode(block, name));
javascript.javascriptGenerator.forBlock[`set_player`] = (block, generator) => {
const type = block.getFieldValue(`type`);
const value = stc(block, generator, `value`);
return `sp[${type}][${value}]`;
};
javascript.javascriptGenerator.forBlock[`change_player`] = (block, generator) => {
const type = block.getFieldValue(`type`);
const value = stc(block, generator, `value`);
return `cp[${type}][${value}]`;
};
javascript.javascriptGenerator.forBlock[`set_inventory`] = (block, generator) => {
const place = stc(block, generator, `place`);
const type = block.getFieldValue(`type`);
const value = stc(block, generator, `value`);
return `si[${place}][${type}][${value}]`;
};
javascript.javascriptGenerator.forBlock[`set_block`] = (block, generator) => {
const place = stc(block, generator, `place`);
const value = stc(block, generator, `value`);
return `sl[${place}][${value}]`;
};
javascript.javascriptGenerator.forBlock[`set_flymode`] = (block, generator) => {
const value = stc(block, generator, `value`);
return `sf[${value}]`;
};
javascript.javascriptGenerator.forBlock[`drop`] = (block, generator) => {
const place = stc(block, generator, `place`);
const value = stc(block, generator, `value`);
const quant = stc(block, generator, `quant`);
return `di[${place}][${value}][${quant}]`;
};
javascript.javascriptGenerator.forBlock[`explosion`] = (block, generator) => {
const place = stc(block, generator, `place`);
const radius = stc(block, generator, `radius`);
return `ex[${place}][${radius}]`;
};
javascript.javascriptGenerator.forBlock[`craft_recipe`] = (block, generator) => {
const v1 = stc(block, generator, `1`);
const v2 = stc(block, generator, `2`);
const v3 = stc(block, generator, `3`);
const v4 = stc(block, generator, `4`);
const v5 = stc(block, generator, `5`);
const v6 = stc(block, generator, `6`);
const value = stc(block, generator, `value`);
const quant = stc(block, generator, `quant`);
const v7 = stc(block, generator, `7`);
const v8 = stc(block, generator, `8`);
const v9 = stc(block, generator, `9`);
const npo = stc(block, generator, `npo`);
let recipe = ``;
if (con(v1) == ` #` && con(v2) == ` #` && con(v3) == ` #`) {
if (con(v4) == ` #` && con(v5) == ` #` && con(v6) == ` #`) recipe = `${con(v7)}${con(v8)}${con(v9)} # # # # # #`;
else recipe = `${con(v4)}${con(v5)}${con(v6)}${con(v7)}${con(v8)}${con(v9)} # # #`;
} else recipe = `${con(v1)}${con(v2)}${con(v3)}${con(v4)}${con(v5)}${con(v6)}${con(v7)}${con(v8)}${con(v9)}`;
return `ar[${value}][${quant}][${recipe}][${npo ? `L` : `S`}]`;
};
javascript.javascriptGenerator.forBlock[`smelt_recipe`] = (block, generator) => {
const original = stc(block, generator, `original`);
const processed = stc(block, generator, `processed`);
return `as[${original}][${processed}]`;
};
javascript.javascriptGenerator.forBlock[`add_data`] = (block, generator) => {
const v1 = stc(block, generator, `1`);
const v2 = stc(block, generator, `2`);
const v3 = stc(block, generator, `3`);
const v4 = stc(block, generator, `4`);
const v5 = stc(block, generator, `5`);
const v6 = stc(block, generator, `6`);
const v7 = stc(block, generator, `7`);
const v8 = stc(block, generator, `8`);
const v9 = stc(block, generator, `9`);
const v10 = stc(block, generator, `10`);
return `ad[${v1}][${v2}][${v3}][${v4}][${v5}][${v6}][${v7}][${v8}][${v9}][${v10}]`;
};
javascript.javascriptGenerator.forBlock[`add_food`] = (block, generator) => {
const v1 = stc(block, generator, `1`);
const v2 = stc(block, generator, `2`);
const v3 = stc(block, generator, `3`);
const v4 = stc(block, generator, `4`);
const v5 = stc(block, generator, `5`);
const v6 = stc(block, generator, `6`);
return `af[${v1}][${v2}][${v3}][${v4}][${v5}][${v6 ? `Y` : `N`}]`;
};
javascript.javascriptGenerator.forBlock[`set_texture`] = (block, generator) => {
const bl = stc(block, generator, `block`);
const value = stc(block, generator, `value`);
return `st[${bl}][${value}]`;
};
javascript.javascriptGenerator.forBlock[`set_skin`] = (block, generator) => {
const value = stc(block, generator, `value`);
return `ss[${value}]`;
};
javascript.javascriptGenerator.forBlock[`player_skin`] = (block, generator) => {
return `gs`;
};
javascript.javascriptGenerator.forBlock[`skin`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`play_sound`] = (block, generator) => {
const value = stc(block, generator, `value`);
return `ps[${value}]`;
};
javascript.javascriptGenerator.forBlock[`world_loads`] = (block, generator) => {
return `$`;
};
javascript.javascriptGenerator.forBlock[`forever`] = (block, generator) => {
const value = stc(block, generator, `value`);
return `fo[${value}]`;
};
javascript.javascriptGenerator.forBlock[`if`] = (block, generator) => {
const bool = stc(block, generator, `bool`);
const value = stc(block, generator, `value`);
return `if[${bool}][${value}]`;
};
javascript.javascriptGenerator.forBlock[`else`] = (block, generator) => {
const bool = stc(block, generator, `bool`);
const value = stc(block, generator, `value`);
const value2 = stc(block, generator, `value2`);
return `el[${bool}][${value}][${value2}]`;
};
javascript.javascriptGenerator.forBlock[`search`] = (block, generator) => {
const value = stc(block, generator, `value`);
return `pc[${value}]`;
};
javascript.javascriptGenerator.forBlock[`search_place`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return `pp[${type}]`;
};
javascript.javascriptGenerator.forBlock[`press_key`] = (block, generator) => {
const value = stc(block, generator, `value`);
return `pk[${value}]`;
};
javascript.javascriptGenerator.forBlock[`player`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return `gp[${type}]`;
};
javascript.javascriptGenerator.forBlock[`inventory`] = (block, generator) => {
const value = stc(block, generator, `value`);
const type = block.getFieldValue(`type`);
return `gi[${value}][${type}]`;
};
javascript.javascriptGenerator.forBlock[`get_block`] = (block, generator) => {
const value = stc(block, generator, `value`);
return `gl[${value}]`;
};
javascript.javascriptGenerator.forBlock[`flymode`] = (block, generator) => {
return `gf`;
};
javascript.javascriptGenerator.forBlock[`get_data`] = (block, generator) => {
const value = stc(block, generator, `value`);
const type = stc(block, generator, `type`);
return `gd[${value}][${type}]`;
};
javascript.javascriptGenerator.forBlock[`seed`] = (block, generator) => {
return `se`;
};
javascript.javascriptGenerator.forBlock[`input`] = (block, generator) => {
const text_value = block.getFieldValue(`value`);
return text_value;
};
javascript.javascriptGenerator.forBlock[`bool`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`calc`] = (block, generator) => {
const value = stc(block, generator, `value`);
const type = block.getFieldValue(`type`);
const value2 = stc(block, generator, `value2`);
return `${`+-*/`[type - 1]}[${value}][${value2}]`;
};
javascript.javascriptGenerator.forBlock[`random`] = (block, generator) => {
const value = stc(block, generator, `value`);
const value2 = stc(block, generator, `value2`);
return `rd[${value}][${value2}]`;
};
javascript.javascriptGenerator.forBlock[`comparison`] = (block, generator) => {
const value = stc(block, generator, `value`);
const type = block.getFieldValue(`type`);
const value2 = stc(block, generator, `value2`);
return `${`><=`[type - 1]}[${value}][${value2}]`;
};
javascript.javascriptGenerator.forBlock[`logic`] = (block, generator) => {
const value = stc(block, generator, `value`);
const type = block.getFieldValue(`type`);
const value2 = stc(block, generator, `value2`);
return `${[`an`, `or`][type - 1]}[${value}][${value2}]`;
};
javascript.javascriptGenerator.forBlock[`not`] = (block, generator) => {
const value = stc(block, generator, `value`);
return `no[${value}]`;
};
javascript.javascriptGenerator.forBlock[`place`] = (block, generator) => {
const x = stc(block, generator, `x`);
const y = stc(block, generator, `y`);
return `gc[${x}][${y}]`;
};
javascript.javascriptGenerator.forBlock[`split_place`] = (block, generator) => {
const value = stc(block, generator, `value`);
const type = block.getFieldValue(`type`);
return `sc[${value}][${type}]`;
};
javascript.javascriptGenerator.forBlock[`variable`] = (block, generator) => {
const value = generator.nameDB_.getName(block.getFieldValue(`value`), Blockly.Variables.NAME_TYPE);
return `va[${value}]`;
};
javascript.javascriptGenerator.forBlock[`set_var`] = (block, generator) => {
const variable = generator.nameDB_.getName(block.getFieldValue(`var`), Blockly.Variables.NAME_TYPE);
const value = stc(block, generator, `value`);
return `sv[${variable}][${value}]`;
};
javascript.javascriptGenerator.forBlock[`change_var`] = (block, generator) => {
const variable = generator.nameDB_.getName(block.getFieldValue(`var`), Blockly.Variables.NAME_TYPE);
const value = stc(block, generator, `value`);
return `cv[${variable}][${value}]`;
};
javascript.javascriptGenerator.forBlock[`building_blocks`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`wooden_blocks`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`ore_blocks`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`oreblocks`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`deco_blocks`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`wool_blocks`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`stairs_blocks`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`terracotta_blocks`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`plant_deco`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`flower_deco`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`decoration`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`redstone`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`miscellanceous`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`spawnegg`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`food`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`tool`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`weapon`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`armor`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`ore_mate`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`material`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`dye`] = (block, generator) => {
const type = block.getFieldValue(`type`);
return type;
};
javascript.javascriptGenerator.forBlock[`add_tool`] = (block, generator) => {
const v1 = stc(block, generator, `1`);
const v7 = stc(block, generator, `7`);
const v2 = stc(block, generator, `2`);
const v4 = block.getFieldValue(`4`);
const v3 = block.getFieldValue(`3`);
const v5 = stc(block, generator, `5`);
const v6 = stc(block, generator, `6`);
return `at[${v1}][${v7}][${v2}][${v3}${v4}][${v5}][${v6}]`;
};
javascript.javascriptGenerator.forBlock[`join`] = (block, generator) => {
const value = stc(block, generator, `value`);
const value2 = stc(block, generator, `value2`);
return `jo[${value}][${value2}]`;
};