Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 27eb343

Browse files
committed
math mod
1 parent 8c7c3b5 commit 27eb343

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/lib/Toolbox/Toolbox.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<block type="math_mul" />
4646
<block type="math_div" />
4747
<block type="math_pow" />
48+
<block type="math_mod" />
4849
<block type="math_log" />
4950
<sep gap="48"></sep>
5051
<block type="math_random" />

src/resources/blocks/math.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,33 @@ function register() {
177177
const code = `(${X} ** ${Y})`;
178178
return [`${code}`, 0];
179179
})
180+
registerBlock(`${categoryPrefix}mod`, {
181+
message0: '%1 % %2',
182+
args0: [
183+
{
184+
"type": "field_number",
185+
"name": "X",
186+
"check": "Number",
187+
"value": 1,
188+
"acceptsBlocks": true
189+
},
190+
{
191+
"type": "field_number",
192+
"name": "Y",
193+
"check": "Number",
194+
"value": 1,
195+
"acceptsBlocks": true
196+
}
197+
],
198+
output: "Number",
199+
inputsInline: true,
200+
colour: categoryColor
201+
}, (block) => {
202+
const X = javascriptGenerator.valueToCode(block, 'X');
203+
const Y = javascriptGenerator.valueToCode(block, 'Y');
204+
const code = `(${X} % ${Y})`;
205+
return [`${code}`, 0];
206+
})
180207
registerBlock(`${categoryPrefix}log`, {
181208
message0: 'log %1 %2',
182209
args0: [

0 commit comments

Comments
 (0)