Skip to content

Commit

Permalink
Make custom join block
Browse files Browse the repository at this point in the history
  • Loading branch information
bruh-9000 committed Mar 15, 2024
1 parent d7fb366 commit 54d221f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/blocks/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,26 @@ const getPlayerSelectedUnit = {
"helpUrl": ""
};

const join = {
"type": "join",
"message0": "join %1 %2",
"args0": [
{
"type": "input_value",
"name": "text1"
},
{
"type": "input_value",
"name": "text2"
}
],
"inputsInline": true,
"output": null,
"colour": 160,
"tooltip": "",
"helpUrl": ""
};

// Colors per category
// 65 for unit
// 120 for trigger
Expand All @@ -940,4 +960,4 @@ export const blocks = Blockly.common.createBlockDefinitionsFromJsonArray(
unitStartsUsingAnItem, unitAttributeBecomesZero, unitUsesItem, unitTouchesWall, playerSendsChatMessage, destroyEntity, lastCreatedUnit, playerCameraTrackUnit, createUnitAtPosition,
playerJoinsGame, playerLeavesGame, getPlayerName, str2num, num2str, sendChatMessageToPlayer, break1, continue1, decreaseVariableByNumber, increaseVariableByNumber, setVariable, triggeringItem,
triggeringRegion, triggeringProjectile, repeat, while1, kickPlayer, comment, dropAllItems, centerOfRegion, getEntireMapRegion, getEntityPosition, itemTypeOfItem, projectileTypeOfProjectile,
setPlayerName, setUnitNameLabel, getPlayerSelectedUnit]);
setPlayerName, setUnitNameLabel, getPlayerSelectedUnit, join]);
9 changes: 9 additions & 0 deletions src/generators/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,4 +494,13 @@ forBlock['getplayerselectedunit'] = function (block, generator) {
// Generate the function call for this block.
const code = `getPlayerSelectedUnit(${player})`;
return [code, generator.ORDER_NONE];
};

forBlock['join'] = function (block, generator) {
const text1 = generator.valueToCode(block, 'text1', Order.NONE) || "''";
const text2 = generator.valueToCode(block, 'text2', Order.NONE) || "''";

// Generate the function call for this block.
const code = `${text1} + ${text2}`;
return [code, generator.ORDER_NONE];
};
2 changes: 1 addition & 1 deletion src/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export const toolbox = {
},
{
'kind': 'block',
'type': 'text_join',
'type': 'join',
},
{
'kind': 'block',
Expand Down

0 comments on commit 54d221f

Please sign in to comment.