hikkaku 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/{composer-bPcsVhIg.mjs → block-helper-DaOyXkRZ.mjs} +164 -90
- package/blocks/index.d.mts +163 -150
- package/blocks/index.mjs +144 -131
- package/{project-CpV5Dm-X.d.mts → index-kUDvI5sE.d.mts} +59 -16
- package/index.d.mts +2 -2
- package/index.mjs +17 -6
- package/package.json +5 -2
- package/types.d.mts +7 -0
- package/vite/index.mjs +22 -17
package/blocks/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as valueBlock, c as unwrapSoundSource, f as attachStack, g as substack, n as fromPrimitiveSource, o as menuInput, p as block, s as unwrapCostumeSource, t as fromBooleanSource } from "../block-helper-DaOyXkRZ.mjs";
|
|
2
|
+
import { InputType, Shadow } from "sb3-types/enum";
|
|
2
3
|
|
|
3
4
|
//#region src/blocks/control.ts
|
|
4
5
|
/**
|
|
@@ -7,7 +8,7 @@ import { a as valueBlock, d as menuInput, f as unwrapCostumeSource, h as Shadow,
|
|
|
7
8
|
* Input: `times`, `handler`.
|
|
8
9
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
9
10
|
*
|
|
10
|
-
* @param times PrimitiveSource<
|
|
11
|
+
* @param times PrimitiveSource<HikkakuNumber>. number of iterations
|
|
11
12
|
* @param handler () => void. body of the loop
|
|
12
13
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
13
14
|
* @example
|
|
@@ -20,7 +21,7 @@ import { a as valueBlock, d as menuInput, f as unwrapCostumeSource, h as Shadow,
|
|
|
20
21
|
const repeat = (times, handler) => {
|
|
21
22
|
const substackId = substack(handler);
|
|
22
23
|
return block("control_repeat", { inputs: {
|
|
23
|
-
TIMES: fromPrimitiveSource(times),
|
|
24
|
+
TIMES: fromPrimitiveSource(InputType.PositiveInteger, times, 10),
|
|
24
25
|
...substackId ? { SUBSTACK: [Shadow.NoShadow, substackId] } : {}
|
|
25
26
|
} });
|
|
26
27
|
};
|
|
@@ -30,7 +31,7 @@ const repeat = (times, handler) => {
|
|
|
30
31
|
* Input: `condition`, `handler`.
|
|
31
32
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
32
33
|
*
|
|
33
|
-
* @param condition PrimitiveSource<
|
|
34
|
+
* @param condition PrimitiveSource<HikkakuBool>
|
|
34
35
|
* @param handler () => void
|
|
35
36
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
36
37
|
* @example
|
|
@@ -43,7 +44,7 @@ const repeat = (times, handler) => {
|
|
|
43
44
|
const repeatUntil = (condition, handler) => {
|
|
44
45
|
const substackId = substack(handler);
|
|
45
46
|
return block("control_repeat_until", { inputs: {
|
|
46
|
-
CONDITION:
|
|
47
|
+
CONDITION: fromBooleanSource(condition),
|
|
47
48
|
...substackId ? { SUBSTACK: [Shadow.NoShadow, substackId] } : {}
|
|
48
49
|
} });
|
|
49
50
|
};
|
|
@@ -53,7 +54,7 @@ const repeatUntil = (condition, handler) => {
|
|
|
53
54
|
* Input: `condition`, `handler`.
|
|
54
55
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
55
56
|
*
|
|
56
|
-
* @param condition PrimitiveSource<
|
|
57
|
+
* @param condition PrimitiveSource<HikkakuBool>
|
|
57
58
|
* @param handler () => void
|
|
58
59
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
59
60
|
* @example
|
|
@@ -66,7 +67,7 @@ const repeatUntil = (condition, handler) => {
|
|
|
66
67
|
const repeatWhile = (condition, handler) => {
|
|
67
68
|
const substackId = substack(handler);
|
|
68
69
|
return block("control_while", { inputs: {
|
|
69
|
-
CONDITION:
|
|
70
|
+
CONDITION: fromBooleanSource(condition),
|
|
70
71
|
...substackId ? { SUBSTACK: [Shadow.NoShadow, substackId] } : {}
|
|
71
72
|
} });
|
|
72
73
|
};
|
|
@@ -77,7 +78,7 @@ const repeatWhile = (condition, handler) => {
|
|
|
77
78
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
78
79
|
*
|
|
79
80
|
* @param variable VariableReference
|
|
80
|
-
* @param value PrimitiveSource<
|
|
81
|
+
* @param value PrimitiveSource<HikkakuNumber>. upper bound
|
|
81
82
|
* @param handler () => void
|
|
82
83
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
83
84
|
* @example
|
|
@@ -91,7 +92,7 @@ const forEach = (variable, value, handler) => {
|
|
|
91
92
|
const substackId = substack(handler);
|
|
92
93
|
return block("control_for_each", {
|
|
93
94
|
inputs: {
|
|
94
|
-
VALUE: fromPrimitiveSource(value),
|
|
95
|
+
VALUE: fromPrimitiveSource(InputType.Number, value, 10),
|
|
95
96
|
...substackId ? { SUBSTACK: [Shadow.NoShadow, substackId] } : {}
|
|
96
97
|
},
|
|
97
98
|
fields: { VARIABLE: [variable.name, variable.id] }
|
|
@@ -122,7 +123,7 @@ const forever = (handler) => {
|
|
|
122
123
|
* Input: `seconds`.
|
|
123
124
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
124
125
|
*
|
|
125
|
-
* @param seconds PrimitiveSource<
|
|
126
|
+
* @param seconds PrimitiveSource<HikkakuNumber>
|
|
126
127
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
127
128
|
* @example
|
|
128
129
|
* ```ts
|
|
@@ -132,7 +133,7 @@ const forever = (handler) => {
|
|
|
132
133
|
* ```
|
|
133
134
|
*/
|
|
134
135
|
const wait = (seconds) => {
|
|
135
|
-
return block("control_wait", { inputs: { DURATION: fromPrimitiveSource(seconds) } });
|
|
136
|
+
return block("control_wait", { inputs: { DURATION: fromPrimitiveSource(InputType.Number, seconds, 1) } });
|
|
136
137
|
};
|
|
137
138
|
/**
|
|
138
139
|
* Waits until condition becomes true.
|
|
@@ -140,7 +141,7 @@ const wait = (seconds) => {
|
|
|
140
141
|
* Input: `condition`.
|
|
141
142
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
142
143
|
*
|
|
143
|
-
* @param condition PrimitiveSource<
|
|
144
|
+
* @param condition PrimitiveSource<HikkakuBool>
|
|
144
145
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
145
146
|
* @example
|
|
146
147
|
* ```ts
|
|
@@ -150,7 +151,7 @@ const wait = (seconds) => {
|
|
|
150
151
|
* ```
|
|
151
152
|
*/
|
|
152
153
|
const waitUntil = (condition) => {
|
|
153
|
-
return block("control_wait_until", { inputs: { CONDITION:
|
|
154
|
+
return block("control_wait_until", { inputs: { CONDITION: fromBooleanSource(condition) } });
|
|
154
155
|
};
|
|
155
156
|
/**
|
|
156
157
|
* Conditional execution.
|
|
@@ -158,7 +159,7 @@ const waitUntil = (condition) => {
|
|
|
158
159
|
* Input: `condition`, `handler`.
|
|
159
160
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
160
161
|
*
|
|
161
|
-
* @param condition PrimitiveSource<
|
|
162
|
+
* @param condition PrimitiveSource<HikkakuBool>
|
|
162
163
|
* @param handler () => void
|
|
163
164
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
164
165
|
* @example
|
|
@@ -171,7 +172,7 @@ const waitUntil = (condition) => {
|
|
|
171
172
|
const ifThen = (condition, handler) => {
|
|
172
173
|
const substackId = substack(handler);
|
|
173
174
|
return block("control_if", { inputs: {
|
|
174
|
-
CONDITION:
|
|
175
|
+
CONDITION: fromBooleanSource(condition),
|
|
175
176
|
...substackId ? { SUBSTACK: [Shadow.NoShadow, substackId] } : {}
|
|
176
177
|
} });
|
|
177
178
|
};
|
|
@@ -181,7 +182,7 @@ const ifThen = (condition, handler) => {
|
|
|
181
182
|
* Input: `condition`, `thenHandler`, `elseHandler`.
|
|
182
183
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
183
184
|
*
|
|
184
|
-
* @param condition PrimitiveSource<
|
|
185
|
+
* @param condition PrimitiveSource<HikkakuBool>
|
|
185
186
|
* @param thenHandler () => void
|
|
186
187
|
* @param elseHandler () => void
|
|
187
188
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
@@ -196,7 +197,7 @@ const ifElse = (condition, thenHandler, elseHandler) => {
|
|
|
196
197
|
const thenSubstackId = substack(thenHandler);
|
|
197
198
|
const elseSubstackId = substack(elseHandler);
|
|
198
199
|
return block("control_if_else", { inputs: {
|
|
199
|
-
CONDITION:
|
|
200
|
+
CONDITION: fromBooleanSource(condition),
|
|
200
201
|
...thenSubstackId ? { SUBSTACK: [Shadow.NoShadow, thenSubstackId] } : {},
|
|
201
202
|
...elseSubstackId ? { SUBSTACK2: [Shadow.NoShadow, elseSubstackId] } : {}
|
|
202
203
|
} });
|
|
@@ -213,7 +214,7 @@ const ifElse = (condition, thenHandler, elseHandler) => {
|
|
|
213
214
|
* ```ts
|
|
214
215
|
* import { match } from 'hikkaku/blocks'
|
|
215
216
|
*
|
|
216
|
-
* match(
|
|
217
|
+
* match([true, () => {}], () => {})
|
|
217
218
|
* ```
|
|
218
219
|
*/
|
|
219
220
|
const match = (...branches) => {
|
|
@@ -426,7 +427,7 @@ const getVariable = (variable) => {
|
|
|
426
427
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
427
428
|
*
|
|
428
429
|
* @param variable VariableReference
|
|
429
|
-
* @param value PrimitiveSource<
|
|
430
|
+
* @param value PrimitiveSource<HikkakuNumber | HikkakuString>
|
|
430
431
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
431
432
|
* @example
|
|
432
433
|
* ```ts
|
|
@@ -437,7 +438,7 @@ const getVariable = (variable) => {
|
|
|
437
438
|
*/
|
|
438
439
|
const setVariableTo = (variable, value) => {
|
|
439
440
|
return block("data_setvariableto", {
|
|
440
|
-
inputs: { VALUE: fromPrimitiveSource(value) },
|
|
441
|
+
inputs: { VALUE: fromPrimitiveSource(InputType.String, value, "0") },
|
|
441
442
|
fields: { VARIABLE: toField(variable) }
|
|
442
443
|
});
|
|
443
444
|
};
|
|
@@ -448,7 +449,7 @@ const setVariableTo = (variable, value) => {
|
|
|
448
449
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
449
450
|
*
|
|
450
451
|
* @param variable VariableReference
|
|
451
|
-
* @param value PrimitiveSource<
|
|
452
|
+
* @param value PrimitiveSource<HikkakuNumber>
|
|
452
453
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
453
454
|
* @example
|
|
454
455
|
* ```ts
|
|
@@ -459,7 +460,7 @@ const setVariableTo = (variable, value) => {
|
|
|
459
460
|
*/
|
|
460
461
|
const changeVariableBy = (variable, value) => {
|
|
461
462
|
return block("data_changevariableby", {
|
|
462
|
-
inputs: { VALUE: fromPrimitiveSource(value) },
|
|
463
|
+
inputs: { VALUE: fromPrimitiveSource(InputType.Number, value, 0) },
|
|
463
464
|
fields: { VARIABLE: toField(variable) }
|
|
464
465
|
});
|
|
465
466
|
};
|
|
@@ -524,7 +525,7 @@ const getListContents = (list) => {
|
|
|
524
525
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
525
526
|
*
|
|
526
527
|
* @param list ListReference
|
|
527
|
-
* @param item PrimitiveSource<
|
|
528
|
+
* @param item PrimitiveSource<HikkakuString | HikkakuNumber>
|
|
528
529
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
529
530
|
* @example
|
|
530
531
|
* ```ts
|
|
@@ -535,7 +536,7 @@ const getListContents = (list) => {
|
|
|
535
536
|
*/
|
|
536
537
|
const addToList = (list, item) => {
|
|
537
538
|
return block("data_addtolist", {
|
|
538
|
-
inputs: { ITEM: fromPrimitiveSource(item) },
|
|
539
|
+
inputs: { ITEM: fromPrimitiveSource(InputType.String, item, "thing") },
|
|
539
540
|
fields: { LIST: toField(list) }
|
|
540
541
|
});
|
|
541
542
|
};
|
|
@@ -546,7 +547,7 @@ const addToList = (list, item) => {
|
|
|
546
547
|
* Output: Scratch statement block definition that is appended to the current script stack.
|
|
547
548
|
*
|
|
548
549
|
* @param list Input value used by this block.
|
|
549
|
-
* @param index PrimitiveSource<
|
|
550
|
+
* @param index PrimitiveSource<HikkakuNumber | HikkakuString>
|
|
550
551
|
* @returns Scratch statement block definition that is appended to the current script stack.
|
|
551
552
|
* @example
|
|
552
553
|
* ```ts
|
|
@@ -557,7 +558,7 @@ const addToList = (list, item) => {
|
|
|
557
558
|
*/
|
|
558
559
|
const deleteOfList = (list, index) => {
|
|
559
560
|
return block("data_deleteoflist", {
|
|
560
|
-
inputs: { INDEX: fromPrimitiveSource(index) },
|
|
561
|
+
inputs: { INDEX: fromPrimitiveSource(InputType.String, index, 1) },
|
|
561
562
|
fields: { LIST: toField(list) }
|
|
562
563
|
});
|
|
563
564
|
};
|
|
@@ -599,8 +600,8 @@ const deleteAllOfList = (list) => {
|
|
|
599
600
|
const insertAtList = (list, index, item) => {
|
|
600
601
|
return block("data_insertatlist", {
|
|
601
602
|
inputs: {
|
|
602
|
-
INDEX: fromPrimitiveSource(index),
|
|
603
|
-
ITEM: fromPrimitiveSource(item)
|
|
603
|
+
INDEX: fromPrimitiveSource(InputType.String, index, 1),
|
|
604
|
+
ITEM: fromPrimitiveSource(InputType.String, item, "thing")
|
|
604
605
|
},
|
|
605
606
|
fields: { LIST: toField(list) }
|
|
606
607
|
});
|
|
@@ -625,8 +626,8 @@ const insertAtList = (list, index, item) => {
|
|
|
625
626
|
const replaceItemOfList = (list, index, item) => {
|
|
626
627
|
return block("data_replaceitemoflist", {
|
|
627
628
|
inputs: {
|
|
628
|
-
INDEX: fromPrimitiveSource(index),
|
|
629
|
-
ITEM: fromPrimitiveSource(item)
|
|
629
|
+
INDEX: fromPrimitiveSource(InputType.String, index, 1),
|
|
630
|
+
ITEM: fromPrimitiveSource(InputType.String, item, "thing")
|
|
630
631
|
},
|
|
631
632
|
fields: { LIST: toField(list) }
|
|
632
633
|
});
|
|
@@ -649,7 +650,7 @@ const replaceItemOfList = (list, index, item) => {
|
|
|
649
650
|
*/
|
|
650
651
|
const getItemOfList = (list, index) => {
|
|
651
652
|
return valueBlock("data_itemoflist", {
|
|
652
|
-
inputs: { INDEX: fromPrimitiveSource(index) },
|
|
653
|
+
inputs: { INDEX: fromPrimitiveSource(InputType.String, index, 1) },
|
|
653
654
|
fields: { LIST: toField(list) }
|
|
654
655
|
});
|
|
655
656
|
};
|
|
@@ -671,7 +672,7 @@ const getItemOfList = (list, index) => {
|
|
|
671
672
|
*/
|
|
672
673
|
const getItemNumOfList = (list, item) => {
|
|
673
674
|
return valueBlock("data_itemnumoflist", {
|
|
674
|
-
inputs: { ITEM: fromPrimitiveSource(item) },
|
|
675
|
+
inputs: { ITEM: fromPrimitiveSource(InputType.String, item, "thing") },
|
|
675
676
|
fields: { LIST: toField(list) }
|
|
676
677
|
});
|
|
677
678
|
};
|
|
@@ -711,7 +712,7 @@ const lengthOfList = (list) => {
|
|
|
711
712
|
*/
|
|
712
713
|
const listContainsItem = (list, item) => {
|
|
713
714
|
return valueBlock("data_listcontainsitem", {
|
|
714
|
-
inputs: { ITEM: fromPrimitiveSource(item) },
|
|
715
|
+
inputs: { ITEM: fromPrimitiveSource(InputType.String, item, "thing") },
|
|
715
716
|
fields: { LIST: toField(list) }
|
|
716
717
|
});
|
|
717
718
|
};
|
|
@@ -930,7 +931,7 @@ const whenTouchingObject = (target, stack) => {
|
|
|
930
931
|
const whenGreaterThan = (menu, value, stack) => {
|
|
931
932
|
const res = block("event_whengreaterthan", {
|
|
932
933
|
topLevel: true,
|
|
933
|
-
inputs: { VALUE: fromPrimitiveSource(value) },
|
|
934
|
+
inputs: { VALUE: fromPrimitiveSource(InputType.Number, value, 10) },
|
|
934
935
|
fields: { WHENGREATERTHANMENU: [menu, null] }
|
|
935
936
|
});
|
|
936
937
|
attachStack(res.id, stack);
|
|
@@ -952,11 +953,7 @@ const whenGreaterThan = (menu, value, stack) => {
|
|
|
952
953
|
* ```
|
|
953
954
|
*/
|
|
954
955
|
const broadcast = (message) => {
|
|
955
|
-
return block("event_broadcast", { inputs: { BROADCAST_INPUT:
|
|
956
|
-
InputType.Broadcast,
|
|
957
|
-
message,
|
|
958
|
-
message
|
|
959
|
-
]] : fromPrimitiveSource(message) } });
|
|
956
|
+
return block("event_broadcast", { inputs: { BROADCAST_INPUT: fromPrimitiveSource(InputType.Broadcast, message, "message1") } });
|
|
960
957
|
};
|
|
961
958
|
/**
|
|
962
959
|
* Broadcasts and waits.
|
|
@@ -974,7 +971,7 @@ const broadcast = (message) => {
|
|
|
974
971
|
* ```
|
|
975
972
|
*/
|
|
976
973
|
const broadcastAndWait = (message) => {
|
|
977
|
-
return block("event_broadcastandwait", { inputs: { BROADCAST_INPUT: fromPrimitiveSource(message) } });
|
|
974
|
+
return block("event_broadcastandwait", { inputs: { BROADCAST_INPUT: fromPrimitiveSource(InputType.Broadcast, message, "message1") } });
|
|
978
975
|
};
|
|
979
976
|
|
|
980
977
|
//#endregion
|
|
@@ -995,7 +992,7 @@ const broadcastAndWait = (message) => {
|
|
|
995
992
|
* ```
|
|
996
993
|
*/
|
|
997
994
|
const say = (message) => {
|
|
998
|
-
return block("looks_say", { inputs: { MESSAGE: fromPrimitiveSource(message) } });
|
|
995
|
+
return block("looks_say", { inputs: { MESSAGE: fromPrimitiveSource(InputType.String, message, "Hello!") } });
|
|
999
996
|
};
|
|
1000
997
|
/**
|
|
1001
998
|
* Speaks for duration.
|
|
@@ -1015,8 +1012,8 @@ const say = (message) => {
|
|
|
1015
1012
|
*/
|
|
1016
1013
|
const sayForSecs = (message, seconds) => {
|
|
1017
1014
|
return block("looks_sayforsecs", { inputs: {
|
|
1018
|
-
MESSAGE: fromPrimitiveSource(message),
|
|
1019
|
-
SECS: fromPrimitiveSource(seconds)
|
|
1015
|
+
MESSAGE: fromPrimitiveSource(InputType.String, message, "Hello!"),
|
|
1016
|
+
SECS: fromPrimitiveSource(InputType.Number, seconds, 2)
|
|
1020
1017
|
} });
|
|
1021
1018
|
};
|
|
1022
1019
|
/**
|
|
@@ -1035,7 +1032,7 @@ const sayForSecs = (message, seconds) => {
|
|
|
1035
1032
|
* ```
|
|
1036
1033
|
*/
|
|
1037
1034
|
const think = (message) => {
|
|
1038
|
-
return block("looks_think", { inputs: { MESSAGE: fromPrimitiveSource(message) } });
|
|
1035
|
+
return block("looks_think", { inputs: { MESSAGE: fromPrimitiveSource(InputType.String, message, "Hello!") } });
|
|
1039
1036
|
};
|
|
1040
1037
|
/**
|
|
1041
1038
|
* Thinks for duration.
|
|
@@ -1055,8 +1052,8 @@ const think = (message) => {
|
|
|
1055
1052
|
*/
|
|
1056
1053
|
const thinkForSecs = (message, seconds) => {
|
|
1057
1054
|
return block("looks_thinkforsecs", { inputs: {
|
|
1058
|
-
MESSAGE: fromPrimitiveSource(message),
|
|
1059
|
-
SECS: fromPrimitiveSource(seconds)
|
|
1055
|
+
MESSAGE: fromPrimitiveSource(InputType.String, message, "Hello!"),
|
|
1056
|
+
SECS: fromPrimitiveSource(InputType.Number, seconds, 2)
|
|
1060
1057
|
} });
|
|
1061
1058
|
};
|
|
1062
1059
|
/**
|
|
@@ -1211,7 +1208,7 @@ const nextBackdrop = () => {
|
|
|
1211
1208
|
*/
|
|
1212
1209
|
const changeLooksEffectBy = (effect, value) => {
|
|
1213
1210
|
return block("looks_changeeffectby", {
|
|
1214
|
-
inputs: { CHANGE: fromPrimitiveSource(value) },
|
|
1211
|
+
inputs: { CHANGE: fromPrimitiveSource(InputType.Number, value, 10) },
|
|
1215
1212
|
fields: { EFFECT: [effect, null] }
|
|
1216
1213
|
});
|
|
1217
1214
|
};
|
|
@@ -1233,7 +1230,7 @@ const changeLooksEffectBy = (effect, value) => {
|
|
|
1233
1230
|
*/
|
|
1234
1231
|
const setLooksEffectTo = (effect, value) => {
|
|
1235
1232
|
return block("looks_seteffectto", {
|
|
1236
|
-
inputs: { VALUE: fromPrimitiveSource(value) },
|
|
1233
|
+
inputs: { VALUE: fromPrimitiveSource(InputType.Number, value, 100) },
|
|
1237
1234
|
fields: { EFFECT: [effect, null] }
|
|
1238
1235
|
});
|
|
1239
1236
|
};
|
|
@@ -1270,7 +1267,7 @@ const clearGraphicEffects = () => {
|
|
|
1270
1267
|
* ```
|
|
1271
1268
|
*/
|
|
1272
1269
|
const changeSizeBy = (value) => {
|
|
1273
|
-
return block("looks_changesizeby", { inputs: { CHANGE: fromPrimitiveSource(value) } });
|
|
1270
|
+
return block("looks_changesizeby", { inputs: { CHANGE: fromPrimitiveSource(InputType.Number, value, 10) } });
|
|
1274
1271
|
};
|
|
1275
1272
|
/**
|
|
1276
1273
|
* Sets size.
|
|
@@ -1288,7 +1285,7 @@ const changeSizeBy = (value) => {
|
|
|
1288
1285
|
* ```
|
|
1289
1286
|
*/
|
|
1290
1287
|
const setSizeTo = (value) => {
|
|
1291
|
-
return block("looks_setsizeto", { inputs: { SIZE: fromPrimitiveSource(value) } });
|
|
1288
|
+
return block("looks_setsizeto", { inputs: { SIZE: fromPrimitiveSource(InputType.Number, value, 100) } });
|
|
1292
1289
|
};
|
|
1293
1290
|
/**
|
|
1294
1291
|
* Moves sprite layer.
|
|
@@ -1326,7 +1323,7 @@ const goToFrontBack = (position) => {
|
|
|
1326
1323
|
*/
|
|
1327
1324
|
const goForwardBackwardLayers = (direction, layers) => {
|
|
1328
1325
|
return block("looks_goforwardbackwardlayers", {
|
|
1329
|
-
inputs: { NUM: fromPrimitiveSource(layers) },
|
|
1326
|
+
inputs: { NUM: fromPrimitiveSource(InputType.Integer, layers, 1) },
|
|
1330
1327
|
fields: { FORWARD_BACKWARD: [direction, null] }
|
|
1331
1328
|
});
|
|
1332
1329
|
};
|
|
@@ -1402,7 +1399,7 @@ const getBackdropNumberName = (value) => {
|
|
|
1402
1399
|
* ```
|
|
1403
1400
|
*/
|
|
1404
1401
|
const moveSteps = (steps) => {
|
|
1405
|
-
return block("motion_movesteps", { inputs: { STEPS: fromPrimitiveSource(steps) } });
|
|
1402
|
+
return block("motion_movesteps", { inputs: { STEPS: fromPrimitiveSource(InputType.Number, steps, 10) } });
|
|
1406
1403
|
};
|
|
1407
1404
|
/**
|
|
1408
1405
|
* Moves to coordinates.
|
|
@@ -1422,8 +1419,8 @@ const moveSteps = (steps) => {
|
|
|
1422
1419
|
*/
|
|
1423
1420
|
const gotoXY = (x, y) => {
|
|
1424
1421
|
return block("motion_gotoxy", { inputs: {
|
|
1425
|
-
X: fromPrimitiveSource(x),
|
|
1426
|
-
Y: fromPrimitiveSource(y)
|
|
1422
|
+
X: fromPrimitiveSource(InputType.Number, x, 0),
|
|
1423
|
+
Y: fromPrimitiveSource(InputType.Number, y, 0)
|
|
1427
1424
|
} });
|
|
1428
1425
|
};
|
|
1429
1426
|
/**
|
|
@@ -1442,7 +1439,7 @@ const gotoXY = (x, y) => {
|
|
|
1442
1439
|
* ```
|
|
1443
1440
|
*/
|
|
1444
1441
|
const changeXBy = (dx) => {
|
|
1445
|
-
return block("motion_changexby", { inputs: { DX: fromPrimitiveSource(dx) } });
|
|
1442
|
+
return block("motion_changexby", { inputs: { DX: fromPrimitiveSource(InputType.Number, dx, 10) } });
|
|
1446
1443
|
};
|
|
1447
1444
|
/**
|
|
1448
1445
|
* Changes Y.
|
|
@@ -1460,7 +1457,7 @@ const changeXBy = (dx) => {
|
|
|
1460
1457
|
* ```
|
|
1461
1458
|
*/
|
|
1462
1459
|
const changeYBy = (dy) => {
|
|
1463
|
-
return block("motion_changeyby", { inputs: { DY: fromPrimitiveSource(dy) } });
|
|
1460
|
+
return block("motion_changeyby", { inputs: { DY: fromPrimitiveSource(InputType.Number, dy, 10) } });
|
|
1464
1461
|
};
|
|
1465
1462
|
/**
|
|
1466
1463
|
* Sets X.
|
|
@@ -1478,7 +1475,7 @@ const changeYBy = (dy) => {
|
|
|
1478
1475
|
* ```
|
|
1479
1476
|
*/
|
|
1480
1477
|
const setX = (x) => {
|
|
1481
|
-
return block("motion_setx", { inputs: { X: fromPrimitiveSource(x) } });
|
|
1478
|
+
return block("motion_setx", { inputs: { X: fromPrimitiveSource(InputType.Number, x, 0) } });
|
|
1482
1479
|
};
|
|
1483
1480
|
/**
|
|
1484
1481
|
* Sets Y.
|
|
@@ -1496,7 +1493,7 @@ const setX = (x) => {
|
|
|
1496
1493
|
* ```
|
|
1497
1494
|
*/
|
|
1498
1495
|
const setY = (y) => {
|
|
1499
|
-
return block("motion_sety", { inputs: { Y: fromPrimitiveSource(y) } });
|
|
1496
|
+
return block("motion_sety", { inputs: { Y: fromPrimitiveSource(InputType.Number, y, 0) } });
|
|
1500
1497
|
};
|
|
1501
1498
|
/**
|
|
1502
1499
|
* Moves to target.
|
|
@@ -1539,7 +1536,7 @@ const menuOfGoTo = (target = GOTO_RANDOM) => {
|
|
|
1539
1536
|
* ```
|
|
1540
1537
|
*/
|
|
1541
1538
|
const turnRight = (degrees) => {
|
|
1542
|
-
return block("motion_turnright", { inputs: { DEGREES: fromPrimitiveSource(degrees) } });
|
|
1539
|
+
return block("motion_turnright", { inputs: { DEGREES: fromPrimitiveSource(InputType.Number, degrees, 15) } });
|
|
1543
1540
|
};
|
|
1544
1541
|
/**
|
|
1545
1542
|
* Turns left.
|
|
@@ -1557,7 +1554,7 @@ const turnRight = (degrees) => {
|
|
|
1557
1554
|
* ```
|
|
1558
1555
|
*/
|
|
1559
1556
|
const turnLeft = (degrees) => {
|
|
1560
|
-
return block("motion_turnleft", { inputs: { DEGREES: fromPrimitiveSource(degrees) } });
|
|
1557
|
+
return block("motion_turnleft", { inputs: { DEGREES: fromPrimitiveSource(InputType.Number, degrees, 15) } });
|
|
1561
1558
|
};
|
|
1562
1559
|
/**
|
|
1563
1560
|
* Points direction.
|
|
@@ -1575,7 +1572,7 @@ const turnLeft = (degrees) => {
|
|
|
1575
1572
|
* ```
|
|
1576
1573
|
*/
|
|
1577
1574
|
const pointInDirection = (direction) => {
|
|
1578
|
-
return block("motion_pointindirection", { inputs: { DIRECTION: fromPrimitiveSource(direction) } });
|
|
1575
|
+
return block("motion_pointindirection", { inputs: { DIRECTION: fromPrimitiveSource(InputType.Angle, direction, 90) } });
|
|
1579
1576
|
};
|
|
1580
1577
|
/**
|
|
1581
1578
|
* Points toward target.
|
|
@@ -1621,9 +1618,9 @@ const menuOfPointTowards = (target = TOWARDS_MOUSE_POINTER) => {
|
|
|
1621
1618
|
*/
|
|
1622
1619
|
const glide = (seconds, x, y) => {
|
|
1623
1620
|
return block("motion_glidesecstoxy", { inputs: {
|
|
1624
|
-
SECS: fromPrimitiveSource(seconds),
|
|
1625
|
-
X: fromPrimitiveSource(x),
|
|
1626
|
-
Y: fromPrimitiveSource(y)
|
|
1621
|
+
SECS: fromPrimitiveSource(InputType.Number, seconds, 1),
|
|
1622
|
+
X: fromPrimitiveSource(InputType.Number, x, 0),
|
|
1623
|
+
Y: fromPrimitiveSource(InputType.Number, y, 0)
|
|
1627
1624
|
} });
|
|
1628
1625
|
};
|
|
1629
1626
|
/**
|
|
@@ -1644,7 +1641,7 @@ const glide = (seconds, x, y) => {
|
|
|
1644
1641
|
*/
|
|
1645
1642
|
const glideTo = (seconds, target) => {
|
|
1646
1643
|
return block("motion_glideto", { inputs: {
|
|
1647
|
-
SECS: fromPrimitiveSource(seconds),
|
|
1644
|
+
SECS: fromPrimitiveSource(InputType.Number, seconds, 1),
|
|
1648
1645
|
TO: menuInput(target, menuOfGlideTo)
|
|
1649
1646
|
} });
|
|
1650
1647
|
};
|
|
@@ -1761,8 +1758,8 @@ const getDirection = () => {
|
|
|
1761
1758
|
*/
|
|
1762
1759
|
const playDrumForBeats = (drum, beats) => {
|
|
1763
1760
|
return block("music_playDrumForBeats", { inputs: {
|
|
1764
|
-
DRUM: fromPrimitiveSource(drum),
|
|
1765
|
-
BEATS: fromPrimitiveSource(beats)
|
|
1761
|
+
DRUM: fromPrimitiveSource(InputType.Number, drum, 1),
|
|
1762
|
+
BEATS: fromPrimitiveSource(InputType.Number, beats, .25)
|
|
1766
1763
|
} });
|
|
1767
1764
|
};
|
|
1768
1765
|
/**
|
|
@@ -1783,8 +1780,8 @@ const playDrumForBeats = (drum, beats) => {
|
|
|
1783
1780
|
*/
|
|
1784
1781
|
const midiPlayDrumForBeats = (drum, beats) => {
|
|
1785
1782
|
return block("music_midiPlayDrumForBeats", { inputs: {
|
|
1786
|
-
DRUM: fromPrimitiveSource(drum),
|
|
1787
|
-
BEATS: fromPrimitiveSource(beats)
|
|
1783
|
+
DRUM: fromPrimitiveSource(InputType.Number, drum, 1),
|
|
1784
|
+
BEATS: fromPrimitiveSource(InputType.Number, beats, .25)
|
|
1788
1785
|
} });
|
|
1789
1786
|
};
|
|
1790
1787
|
/**
|
|
@@ -1803,7 +1800,7 @@ const midiPlayDrumForBeats = (drum, beats) => {
|
|
|
1803
1800
|
* ```
|
|
1804
1801
|
*/
|
|
1805
1802
|
const restForBeats = (beats) => {
|
|
1806
|
-
return block("music_restForBeats", { inputs: { BEATS: fromPrimitiveSource(beats) } });
|
|
1803
|
+
return block("music_restForBeats", { inputs: { BEATS: fromPrimitiveSource(InputType.Number, beats, .25) } });
|
|
1807
1804
|
};
|
|
1808
1805
|
/**
|
|
1809
1806
|
* Plays note for beats.
|
|
@@ -1823,8 +1820,8 @@ const restForBeats = (beats) => {
|
|
|
1823
1820
|
*/
|
|
1824
1821
|
const playNoteForBeats = (note, beats) => {
|
|
1825
1822
|
return block("music_playNoteForBeats", { inputs: {
|
|
1826
|
-
NOTE: fromPrimitiveSource(note),
|
|
1827
|
-
BEATS: fromPrimitiveSource(beats)
|
|
1823
|
+
NOTE: fromPrimitiveSource(InputType.Number, note, 60),
|
|
1824
|
+
BEATS: fromPrimitiveSource(InputType.Number, beats, .25)
|
|
1828
1825
|
} });
|
|
1829
1826
|
};
|
|
1830
1827
|
/**
|
|
@@ -1843,7 +1840,7 @@ const playNoteForBeats = (note, beats) => {
|
|
|
1843
1840
|
* ```
|
|
1844
1841
|
*/
|
|
1845
1842
|
const setInstrument = (instrument) => {
|
|
1846
|
-
return block("music_setInstrument", { inputs: { INSTRUMENT: fromPrimitiveSource(instrument) } });
|
|
1843
|
+
return block("music_setInstrument", { inputs: { INSTRUMENT: fromPrimitiveSource(InputType.Number, instrument, 1) } });
|
|
1847
1844
|
};
|
|
1848
1845
|
/**
|
|
1849
1846
|
* Sets instrument with MIDI instrument mapping.
|
|
@@ -1861,7 +1858,7 @@ const setInstrument = (instrument) => {
|
|
|
1861
1858
|
* ```
|
|
1862
1859
|
*/
|
|
1863
1860
|
const midiSetInstrument = (instrument) => {
|
|
1864
|
-
return block("music_midiSetInstrument", { inputs: { INSTRUMENT: fromPrimitiveSource(instrument) } });
|
|
1861
|
+
return block("music_midiSetInstrument", { inputs: { INSTRUMENT: fromPrimitiveSource(InputType.Number, instrument, 1) } });
|
|
1865
1862
|
};
|
|
1866
1863
|
/**
|
|
1867
1864
|
* Sets tempo.
|
|
@@ -1879,7 +1876,7 @@ const midiSetInstrument = (instrument) => {
|
|
|
1879
1876
|
* ```
|
|
1880
1877
|
*/
|
|
1881
1878
|
const setTempo = (tempo) => {
|
|
1882
|
-
return block("music_setTempo", { inputs: { TEMPO: fromPrimitiveSource(tempo) } });
|
|
1879
|
+
return block("music_setTempo", { inputs: { TEMPO: fromPrimitiveSource(InputType.Number, tempo, 20) } });
|
|
1883
1880
|
};
|
|
1884
1881
|
/**
|
|
1885
1882
|
* Changes tempo.
|
|
@@ -1897,7 +1894,7 @@ const setTempo = (tempo) => {
|
|
|
1897
1894
|
* ```
|
|
1898
1895
|
*/
|
|
1899
1896
|
const changeTempo = (tempo) => {
|
|
1900
|
-
return block("music_changeTempo", { inputs: { TEMPO: fromPrimitiveSource(tempo) } });
|
|
1897
|
+
return block("music_changeTempo", { inputs: { TEMPO: fromPrimitiveSource(InputType.Number, tempo, 20) } });
|
|
1901
1898
|
};
|
|
1902
1899
|
/**
|
|
1903
1900
|
* Returns tempo.
|
|
@@ -1937,8 +1934,8 @@ const getTempo = () => {
|
|
|
1937
1934
|
*/
|
|
1938
1935
|
const add = (a, b) => {
|
|
1939
1936
|
return valueBlock("operator_add", { inputs: {
|
|
1940
|
-
NUM1: fromPrimitiveSource(a),
|
|
1941
|
-
NUM2: fromPrimitiveSource(b)
|
|
1937
|
+
NUM1: fromPrimitiveSource(InputType.Number, a, 0),
|
|
1938
|
+
NUM2: fromPrimitiveSource(InputType.Number, b, 0)
|
|
1942
1939
|
} });
|
|
1943
1940
|
};
|
|
1944
1941
|
/**
|
|
@@ -1959,8 +1956,8 @@ const add = (a, b) => {
|
|
|
1959
1956
|
*/
|
|
1960
1957
|
const subtract = (a, b) => {
|
|
1961
1958
|
return valueBlock("operator_subtract", { inputs: {
|
|
1962
|
-
NUM1: fromPrimitiveSource(a),
|
|
1963
|
-
NUM2: fromPrimitiveSource(b)
|
|
1959
|
+
NUM1: fromPrimitiveSource(InputType.Number, a, 0),
|
|
1960
|
+
NUM2: fromPrimitiveSource(InputType.Number, b, 0)
|
|
1964
1961
|
} });
|
|
1965
1962
|
};
|
|
1966
1963
|
/**
|
|
@@ -1981,8 +1978,8 @@ const subtract = (a, b) => {
|
|
|
1981
1978
|
*/
|
|
1982
1979
|
const multiply = (a, b) => {
|
|
1983
1980
|
return valueBlock("operator_multiply", { inputs: {
|
|
1984
|
-
NUM1: fromPrimitiveSource(a),
|
|
1985
|
-
NUM2: fromPrimitiveSource(b)
|
|
1981
|
+
NUM1: fromPrimitiveSource(InputType.Number, a, 0),
|
|
1982
|
+
NUM2: fromPrimitiveSource(InputType.Number, b, 0)
|
|
1986
1983
|
} });
|
|
1987
1984
|
};
|
|
1988
1985
|
/**
|
|
@@ -2003,8 +2000,8 @@ const multiply = (a, b) => {
|
|
|
2003
2000
|
*/
|
|
2004
2001
|
const divide = (a, b) => {
|
|
2005
2002
|
return valueBlock("operator_divide", { inputs: {
|
|
2006
|
-
NUM1: fromPrimitiveSource(a),
|
|
2007
|
-
NUM2: fromPrimitiveSource(b)
|
|
2003
|
+
NUM1: fromPrimitiveSource(InputType.Number, a, 0),
|
|
2004
|
+
NUM2: fromPrimitiveSource(InputType.Number, b, 0)
|
|
2008
2005
|
} });
|
|
2009
2006
|
};
|
|
2010
2007
|
/**
|
|
@@ -2025,8 +2022,8 @@ const divide = (a, b) => {
|
|
|
2025
2022
|
*/
|
|
2026
2023
|
const lt = (a, b) => {
|
|
2027
2024
|
return valueBlock("operator_lt", { inputs: {
|
|
2028
|
-
OPERAND1: fromPrimitiveSource(a),
|
|
2029
|
-
OPERAND2: fromPrimitiveSource(b)
|
|
2025
|
+
OPERAND1: fromPrimitiveSource(InputType.String, a, ""),
|
|
2026
|
+
OPERAND2: fromPrimitiveSource(InputType.String, b, "")
|
|
2030
2027
|
} });
|
|
2031
2028
|
};
|
|
2032
2029
|
/**
|
|
@@ -2047,8 +2044,8 @@ const lt = (a, b) => {
|
|
|
2047
2044
|
*/
|
|
2048
2045
|
const equals = (a, b) => {
|
|
2049
2046
|
return valueBlock("operator_equals", { inputs: {
|
|
2050
|
-
OPERAND1: fromPrimitiveSource(a),
|
|
2051
|
-
OPERAND2: fromPrimitiveSource(b)
|
|
2047
|
+
OPERAND1: fromPrimitiveSource(InputType.String, a, ""),
|
|
2048
|
+
OPERAND2: fromPrimitiveSource(InputType.String, b, "")
|
|
2052
2049
|
} });
|
|
2053
2050
|
};
|
|
2054
2051
|
/**
|
|
@@ -2069,8 +2066,8 @@ const equals = (a, b) => {
|
|
|
2069
2066
|
*/
|
|
2070
2067
|
const gt = (a, b) => {
|
|
2071
2068
|
return valueBlock("operator_gt", { inputs: {
|
|
2072
|
-
OPERAND1: fromPrimitiveSource(a),
|
|
2073
|
-
OPERAND2: fromPrimitiveSource(b)
|
|
2069
|
+
OPERAND1: fromPrimitiveSource(InputType.String, a, ""),
|
|
2070
|
+
OPERAND2: fromPrimitiveSource(InputType.String, b, "")
|
|
2074
2071
|
} });
|
|
2075
2072
|
};
|
|
2076
2073
|
/**
|
|
@@ -2091,8 +2088,8 @@ const gt = (a, b) => {
|
|
|
2091
2088
|
*/
|
|
2092
2089
|
const and = (a, b) => {
|
|
2093
2090
|
return valueBlock("operator_and", { inputs: {
|
|
2094
|
-
OPERAND1:
|
|
2095
|
-
OPERAND2:
|
|
2091
|
+
OPERAND1: fromBooleanSource(a),
|
|
2092
|
+
OPERAND2: fromBooleanSource(b)
|
|
2096
2093
|
} });
|
|
2097
2094
|
};
|
|
2098
2095
|
/**
|
|
@@ -2113,8 +2110,8 @@ const and = (a, b) => {
|
|
|
2113
2110
|
*/
|
|
2114
2111
|
const or = (a, b) => {
|
|
2115
2112
|
return valueBlock("operator_or", { inputs: {
|
|
2116
|
-
OPERAND1:
|
|
2117
|
-
OPERAND2:
|
|
2113
|
+
OPERAND1: fromBooleanSource(a),
|
|
2114
|
+
OPERAND2: fromBooleanSource(b)
|
|
2118
2115
|
} });
|
|
2119
2116
|
};
|
|
2120
2117
|
/**
|
|
@@ -2133,7 +2130,7 @@ const or = (a, b) => {
|
|
|
2133
2130
|
* ```
|
|
2134
2131
|
*/
|
|
2135
2132
|
const not = (operand) => {
|
|
2136
|
-
return valueBlock("operator_not", { inputs: { OPERAND:
|
|
2133
|
+
return valueBlock("operator_not", { inputs: { OPERAND: fromBooleanSource(operand) } });
|
|
2137
2134
|
};
|
|
2138
2135
|
/**
|
|
2139
2136
|
* Random number.
|
|
@@ -2153,8 +2150,8 @@ const not = (operand) => {
|
|
|
2153
2150
|
*/
|
|
2154
2151
|
const random = (from, to) => {
|
|
2155
2152
|
return valueBlock("operator_random", { inputs: {
|
|
2156
|
-
FROM: fromPrimitiveSource(from),
|
|
2157
|
-
TO: fromPrimitiveSource(to)
|
|
2153
|
+
FROM: fromPrimitiveSource(InputType.Number, from, 1),
|
|
2154
|
+
TO: fromPrimitiveSource(InputType.Number, to, 10)
|
|
2158
2155
|
} });
|
|
2159
2156
|
};
|
|
2160
2157
|
/**
|
|
@@ -2175,8 +2172,8 @@ const random = (from, to) => {
|
|
|
2175
2172
|
*/
|
|
2176
2173
|
const join = (a, b) => {
|
|
2177
2174
|
return valueBlock("operator_join", { inputs: {
|
|
2178
|
-
STRING1: fromPrimitiveSource(a),
|
|
2179
|
-
STRING2: fromPrimitiveSource(b)
|
|
2175
|
+
STRING1: fromPrimitiveSource(InputType.String, a, "apple"),
|
|
2176
|
+
STRING2: fromPrimitiveSource(InputType.String, b, "banana")
|
|
2180
2177
|
} });
|
|
2181
2178
|
};
|
|
2182
2179
|
/**
|
|
@@ -2197,8 +2194,8 @@ const join = (a, b) => {
|
|
|
2197
2194
|
*/
|
|
2198
2195
|
const letterOf = (letter, text) => {
|
|
2199
2196
|
return valueBlock("operator_letter_of", { inputs: {
|
|
2200
|
-
LETTER: fromPrimitiveSource(letter),
|
|
2201
|
-
STRING: fromPrimitiveSource(text)
|
|
2197
|
+
LETTER: fromPrimitiveSource(InputType.PositiveInteger, letter, 1),
|
|
2198
|
+
STRING: fromPrimitiveSource(InputType.String, text, "apple")
|
|
2202
2199
|
} });
|
|
2203
2200
|
};
|
|
2204
2201
|
/**
|
|
@@ -2217,7 +2214,7 @@ const letterOf = (letter, text) => {
|
|
|
2217
2214
|
* ```
|
|
2218
2215
|
*/
|
|
2219
2216
|
const length = (text) => {
|
|
2220
|
-
return valueBlock("operator_length", { inputs: { STRING: fromPrimitiveSource(text) } });
|
|
2217
|
+
return valueBlock("operator_length", { inputs: { STRING: fromPrimitiveSource(InputType.String, text, "apple") } });
|
|
2221
2218
|
};
|
|
2222
2219
|
/**
|
|
2223
2220
|
* Substring check.
|
|
@@ -2237,8 +2234,8 @@ const length = (text) => {
|
|
|
2237
2234
|
*/
|
|
2238
2235
|
const contains = (text, substring) => {
|
|
2239
2236
|
return valueBlock("operator_contains", { inputs: {
|
|
2240
|
-
STRING1: fromPrimitiveSource(text),
|
|
2241
|
-
STRING2: fromPrimitiveSource(substring)
|
|
2237
|
+
STRING1: fromPrimitiveSource(InputType.String, text, "apple"),
|
|
2238
|
+
STRING2: fromPrimitiveSource(InputType.String, substring, "a")
|
|
2242
2239
|
} });
|
|
2243
2240
|
};
|
|
2244
2241
|
/**
|
|
@@ -2259,8 +2256,8 @@ const contains = (text, substring) => {
|
|
|
2259
2256
|
*/
|
|
2260
2257
|
const mod = (a, b) => {
|
|
2261
2258
|
return valueBlock("operator_mod", { inputs: {
|
|
2262
|
-
NUM1: fromPrimitiveSource(a),
|
|
2263
|
-
NUM2: fromPrimitiveSource(b)
|
|
2259
|
+
NUM1: fromPrimitiveSource(InputType.Number, a, 0),
|
|
2260
|
+
NUM2: fromPrimitiveSource(InputType.Number, b, 0)
|
|
2264
2261
|
} });
|
|
2265
2262
|
};
|
|
2266
2263
|
/**
|
|
@@ -2279,7 +2276,7 @@ const mod = (a, b) => {
|
|
|
2279
2276
|
* ```
|
|
2280
2277
|
*/
|
|
2281
2278
|
const round = (value) => {
|
|
2282
|
-
return valueBlock("operator_round", { inputs: { NUM: fromPrimitiveSource(value) } });
|
|
2279
|
+
return valueBlock("operator_round", { inputs: { NUM: fromPrimitiveSource(InputType.Number, value, 0) } });
|
|
2283
2280
|
};
|
|
2284
2281
|
/**
|
|
2285
2282
|
* Math operation (sin, cos, log, etc.).
|
|
@@ -2299,7 +2296,7 @@ const round = (value) => {
|
|
|
2299
2296
|
*/
|
|
2300
2297
|
const mathop = (operator, value) => {
|
|
2301
2298
|
return valueBlock("operator_mathop", {
|
|
2302
|
-
inputs: { NUM: fromPrimitiveSource(value) },
|
|
2299
|
+
inputs: { NUM: fromPrimitiveSource(InputType.Number, value, 0) },
|
|
2303
2300
|
fields: { OPERATOR: [operator, null] }
|
|
2304
2301
|
});
|
|
2305
2302
|
};
|
|
@@ -2404,7 +2401,7 @@ const penUp = () => {
|
|
|
2404
2401
|
* ```
|
|
2405
2402
|
*/
|
|
2406
2403
|
const setPenColorTo = (color) => {
|
|
2407
|
-
return block("pen_setPenColorToColor", { inputs: { COLOR:
|
|
2404
|
+
return block("pen_setPenColorToColor", { inputs: { COLOR: fromPrimitiveSource(InputType.Color, color) } });
|
|
2408
2405
|
};
|
|
2409
2406
|
/**
|
|
2410
2407
|
* Alias for {@link setPenColorTo}.
|
|
@@ -2440,7 +2437,7 @@ const setPenColorToColor = setPenColorTo;
|
|
|
2440
2437
|
const changePenColorParamBy = (param, value) => {
|
|
2441
2438
|
return block("pen_changePenColorParamBy", { inputs: {
|
|
2442
2439
|
COLOR_PARAM: menuInput(param, menuOfPenColorParam),
|
|
2443
|
-
VALUE: fromPrimitiveSource(value)
|
|
2440
|
+
VALUE: fromPrimitiveSource(InputType.Number, value, 10)
|
|
2444
2441
|
} });
|
|
2445
2442
|
};
|
|
2446
2443
|
const menuOfPenColorParam = (colorParam = "color") => {
|
|
@@ -2468,7 +2465,7 @@ const menuOfPenColorParam = (colorParam = "color") => {
|
|
|
2468
2465
|
const setPenColorParamTo = (param, value) => {
|
|
2469
2466
|
return block("pen_setPenColorParamTo", { inputs: {
|
|
2470
2467
|
COLOR_PARAM: menuInput(param, menuOfPenColorParam),
|
|
2471
|
-
VALUE: fromPrimitiveSource(value)
|
|
2468
|
+
VALUE: fromPrimitiveSource(InputType.Number, value, 10)
|
|
2472
2469
|
} });
|
|
2473
2470
|
};
|
|
2474
2471
|
/**
|
|
@@ -2487,7 +2484,7 @@ const setPenColorParamTo = (param, value) => {
|
|
|
2487
2484
|
* ```
|
|
2488
2485
|
*/
|
|
2489
2486
|
const changePenSizeBy = (size) => {
|
|
2490
|
-
return block("pen_changePenSizeBy", { inputs: { SIZE: fromPrimitiveSource(size) } });
|
|
2487
|
+
return block("pen_changePenSizeBy", { inputs: { SIZE: fromPrimitiveSource(InputType.Number, size, 1) } });
|
|
2491
2488
|
};
|
|
2492
2489
|
/**
|
|
2493
2490
|
* Sets pen size to value.
|
|
@@ -2505,7 +2502,7 @@ const changePenSizeBy = (size) => {
|
|
|
2505
2502
|
* ```
|
|
2506
2503
|
*/
|
|
2507
2504
|
const setPenSizeTo = (size) => {
|
|
2508
|
-
return block("pen_setPenSizeTo", { inputs: { SIZE: fromPrimitiveSource(size) } });
|
|
2505
|
+
return block("pen_setPenSizeTo", { inputs: { SIZE: fromPrimitiveSource(InputType.Number, size, 1) } });
|
|
2509
2506
|
};
|
|
2510
2507
|
/**
|
|
2511
2508
|
* Sets pen shade to value.
|
|
@@ -2523,7 +2520,7 @@ const setPenSizeTo = (size) => {
|
|
|
2523
2520
|
* ```
|
|
2524
2521
|
*/
|
|
2525
2522
|
const setPenShadeToNumber = (shade) => {
|
|
2526
|
-
return block("pen_setPenShadeToNumber", { inputs: { SHADE: fromPrimitiveSource(shade) } });
|
|
2523
|
+
return block("pen_setPenShadeToNumber", { inputs: { SHADE: fromPrimitiveSource(InputType.Number, shade, 50) } });
|
|
2527
2524
|
};
|
|
2528
2525
|
/**
|
|
2529
2526
|
* Changes pen shade by amount.
|
|
@@ -2541,7 +2538,7 @@ const setPenShadeToNumber = (shade) => {
|
|
|
2541
2538
|
* ```
|
|
2542
2539
|
*/
|
|
2543
2540
|
const changePenShadeBy = (shade) => {
|
|
2544
|
-
return block("pen_changePenShadeBy", { inputs: { SHADE: fromPrimitiveSource(shade) } });
|
|
2541
|
+
return block("pen_changePenShadeBy", { inputs: { SHADE: fromPrimitiveSource(InputType.Number, shade, 50) } });
|
|
2545
2542
|
};
|
|
2546
2543
|
/**
|
|
2547
2544
|
* Sets pen hue to value.
|
|
@@ -2559,7 +2556,7 @@ const changePenShadeBy = (shade) => {
|
|
|
2559
2556
|
* ```
|
|
2560
2557
|
*/
|
|
2561
2558
|
const setPenHueToNumber = (hue) => {
|
|
2562
|
-
return block("pen_setPenHueToNumber", { inputs: { HUE: fromPrimitiveSource(hue) } });
|
|
2559
|
+
return block("pen_setPenHueToNumber", { inputs: { HUE: fromPrimitiveSource(InputType.Number, hue, 0) } });
|
|
2563
2560
|
};
|
|
2564
2561
|
/**
|
|
2565
2562
|
* Changes pen hue by amount.
|
|
@@ -2577,7 +2574,7 @@ const setPenHueToNumber = (hue) => {
|
|
|
2577
2574
|
* ```
|
|
2578
2575
|
*/
|
|
2579
2576
|
const changePenHueBy = (hue) => {
|
|
2580
|
-
return block("pen_changePenHueBy", { inputs: { HUE: fromPrimitiveSource(hue) } });
|
|
2577
|
+
return block("pen_changePenHueBy", { inputs: { HUE: fromPrimitiveSource(InputType.Number, hue, 0) } });
|
|
2581
2578
|
};
|
|
2582
2579
|
|
|
2583
2580
|
//#endregion
|
|
@@ -2609,7 +2606,7 @@ const procedureLabel = (text) => {
|
|
|
2609
2606
|
* ```ts
|
|
2610
2607
|
* import { procedureBoolean } from 'hikkaku/blocks'
|
|
2611
2608
|
*
|
|
2612
|
-
* procedureBoolean(
|
|
2609
|
+
* procedureBoolean('flag')
|
|
2613
2610
|
* ```
|
|
2614
2611
|
*/
|
|
2615
2612
|
const procedureBoolean = (name) => {
|
|
@@ -2627,7 +2624,7 @@ const procedureBoolean = (name) => {
|
|
|
2627
2624
|
* ```ts
|
|
2628
2625
|
* import { procedureStringOrNumber } from 'hikkaku/blocks'
|
|
2629
2626
|
*
|
|
2630
|
-
* procedureStringOrNumber(
|
|
2627
|
+
* procedureStringOrNumber('value')
|
|
2631
2628
|
* ```
|
|
2632
2629
|
*/
|
|
2633
2630
|
const procedureStringOrNumber = (name) => {
|
|
@@ -2765,21 +2762,25 @@ const callProcedure = (proccodeOrReference, argumentIdsOrInputs, inputsOrWarp, w
|
|
|
2765
2762
|
let proccode = "";
|
|
2766
2763
|
let argumentIds = [];
|
|
2767
2764
|
let inputs = {};
|
|
2765
|
+
let procedureReference = null;
|
|
2768
2766
|
if (typeof proccodeOrReference === "string") {
|
|
2769
2767
|
proccode = proccodeOrReference;
|
|
2770
2768
|
argumentIds = argumentIdsOrInputs;
|
|
2771
2769
|
inputs = (typeof inputsOrWarp === "object" ? inputsOrWarp : void 0) ?? {};
|
|
2772
2770
|
warp = typeof inputsOrWarp === "boolean" ? inputsOrWarp : warp;
|
|
2773
2771
|
} else {
|
|
2774
|
-
|
|
2772
|
+
procedureReference = "reference" in proccodeOrReference ? proccodeOrReference.reference : proccodeOrReference;
|
|
2775
2773
|
proccode = procedureReference.proccode;
|
|
2776
2774
|
argumentIds = procedureReference.argumentids;
|
|
2777
2775
|
warp = typeof inputsOrWarp === "boolean" ? inputsOrWarp : procedureReference.warp;
|
|
2778
2776
|
if (Array.isArray(argumentIdsOrInputs) && argumentIdsOrInputs.every((input) => typeof input === "object" && input !== null && "reference" in input && "value" in input)) for (const input of argumentIdsOrInputs) inputs[input.reference.id] = input.value;
|
|
2779
2777
|
else if (!Array.isArray(argumentIdsOrInputs)) inputs = argumentIdsOrInputs;
|
|
2780
2778
|
}
|
|
2779
|
+
const argumentTypeMap = {};
|
|
2780
|
+
if (procedureReference) for (const arg of Object.values(procedureReference.arguments)) argumentTypeMap[arg.id] = arg.type;
|
|
2781
2781
|
const resolvedInputs = {};
|
|
2782
|
-
for (const [key, value] of Object.entries(inputs)) resolvedInputs[key] =
|
|
2782
|
+
for (const [key, value] of Object.entries(inputs)) if (argumentTypeMap[key] === "boolean") resolvedInputs[key] = fromBooleanSource(value);
|
|
2783
|
+
else resolvedInputs[key] = fromPrimitiveSource(InputType.String, value, "");
|
|
2783
2784
|
return block("procedures_call", {
|
|
2784
2785
|
inputs: resolvedInputs,
|
|
2785
2786
|
mutation: {
|
|
@@ -2800,7 +2801,13 @@ const callProcedure = (proccodeOrReference, argumentIdsOrInputs, inputsOrWarp, w
|
|
|
2800
2801
|
* ```ts
|
|
2801
2802
|
* import { argumentReporterStringNumber } from 'hikkaku/blocks'
|
|
2802
2803
|
*
|
|
2803
|
-
* argumentReporterStringNumber(
|
|
2804
|
+
* argumentReporterStringNumber({
|
|
2805
|
+
* isProcedureArgument: true,
|
|
2806
|
+
* name: 'value',
|
|
2807
|
+
* type: 'stringOrNumber',
|
|
2808
|
+
* id: 'var-id',
|
|
2809
|
+
* getter: () => valueBlock<HikkakuString | HikkakuNumber>('argument_reporter_string_number', { fields: { VALUE: ['value', null] } }),
|
|
2810
|
+
* })
|
|
2804
2811
|
* ```
|
|
2805
2812
|
*/
|
|
2806
2813
|
const argumentReporterStringNumber = (reference) => {
|
|
@@ -2815,7 +2822,13 @@ const argumentReporterStringNumber = (reference) => {
|
|
|
2815
2822
|
* ```ts
|
|
2816
2823
|
* import { argumentReporterBoolean } from 'hikkaku/blocks'
|
|
2817
2824
|
*
|
|
2818
|
-
* argumentReporterBoolean(
|
|
2825
|
+
* argumentReporterBoolean({
|
|
2826
|
+
* isProcedureArgument: true,
|
|
2827
|
+
* name: 'flag',
|
|
2828
|
+
* type: 'boolean',
|
|
2829
|
+
* id: 'flag-id',
|
|
2830
|
+
* getter: () => valueBlock<HikkakuBool>('argument_reporter_boolean', { fields: { VALUE: ['flag', null] } }),
|
|
2831
|
+
* })
|
|
2819
2832
|
* ```
|
|
2820
2833
|
*/
|
|
2821
2834
|
const argumentReporterBoolean = (reference) => {
|
|
@@ -2901,7 +2914,7 @@ const menuOfTouchingObject = (target = "_mouse_") => {
|
|
|
2901
2914
|
* ```
|
|
2902
2915
|
*/
|
|
2903
2916
|
const touchingColor = (color) => {
|
|
2904
|
-
return valueBlock("sensing_touchingcolor", { inputs: { COLOR:
|
|
2917
|
+
return valueBlock("sensing_touchingcolor", { inputs: { COLOR: fromPrimitiveSource(InputType.Color, color) } });
|
|
2905
2918
|
};
|
|
2906
2919
|
/**
|
|
2907
2920
|
* Color overlap check.
|
|
@@ -2921,8 +2934,8 @@ const touchingColor = (color) => {
|
|
|
2921
2934
|
*/
|
|
2922
2935
|
const colorTouchingColor = (color, targetColor) => {
|
|
2923
2936
|
return valueBlock("sensing_coloristouchingcolor", { inputs: {
|
|
2924
|
-
COLOR:
|
|
2925
|
-
COLOR2:
|
|
2937
|
+
COLOR: fromPrimitiveSource(InputType.Color, color),
|
|
2938
|
+
COLOR2: fromPrimitiveSource(InputType.Color, targetColor)
|
|
2926
2939
|
} });
|
|
2927
2940
|
};
|
|
2928
2941
|
/**
|
|
@@ -3155,7 +3168,7 @@ const isLoud = () => {
|
|
|
3155
3168
|
* ```
|
|
3156
3169
|
*/
|
|
3157
3170
|
const askAndWait = (question) => {
|
|
3158
|
-
return block("sensing_askandwait", { inputs: { QUESTION: fromPrimitiveSource(question) } });
|
|
3171
|
+
return block("sensing_askandwait", { inputs: { QUESTION: fromPrimitiveSource(InputType.String, question, "What's your name?") } });
|
|
3159
3172
|
};
|
|
3160
3173
|
/**
|
|
3161
3174
|
* Returns last answer.
|
|
@@ -3288,7 +3301,7 @@ const stopAllSounds = () => {
|
|
|
3288
3301
|
*/
|
|
3289
3302
|
const setSoundEffectTo = (effect, value) => {
|
|
3290
3303
|
return block("sound_seteffectto", {
|
|
3291
|
-
inputs: { VALUE: fromPrimitiveSource(value) },
|
|
3304
|
+
inputs: { VALUE: fromPrimitiveSource(InputType.Number, value, 10) },
|
|
3292
3305
|
fields: { EFFECT: [effect, null] }
|
|
3293
3306
|
});
|
|
3294
3307
|
};
|
|
@@ -3310,7 +3323,7 @@ const setSoundEffectTo = (effect, value) => {
|
|
|
3310
3323
|
*/
|
|
3311
3324
|
const changeSoundEffectBy = (effect, value) => {
|
|
3312
3325
|
return block("sound_changeeffectby", {
|
|
3313
|
-
inputs: { VALUE: fromPrimitiveSource(value) },
|
|
3326
|
+
inputs: { VALUE: fromPrimitiveSource(InputType.Number, value, 10) },
|
|
3314
3327
|
fields: { EFFECT: [effect, null] }
|
|
3315
3328
|
});
|
|
3316
3329
|
};
|
|
@@ -3347,7 +3360,7 @@ const clearEffects = () => {
|
|
|
3347
3360
|
* ```
|
|
3348
3361
|
*/
|
|
3349
3362
|
const setVolumeTo = (value) => {
|
|
3350
|
-
return block("sound_setvolumeto", { inputs: { VOLUME: fromPrimitiveSource(value) } });
|
|
3363
|
+
return block("sound_setvolumeto", { inputs: { VOLUME: fromPrimitiveSource(InputType.Number, value, 10) } });
|
|
3351
3364
|
};
|
|
3352
3365
|
/**
|
|
3353
3366
|
* Changes volume.
|
|
@@ -3365,7 +3378,7 @@ const setVolumeTo = (value) => {
|
|
|
3365
3378
|
* ```
|
|
3366
3379
|
*/
|
|
3367
3380
|
const changeVolumeBy = (value) => {
|
|
3368
|
-
return block("sound_changevolumeby", { inputs: { VOLUME: fromPrimitiveSource(value) } });
|
|
3381
|
+
return block("sound_changevolumeby", { inputs: { VOLUME: fromPrimitiveSource(InputType.Number, value, 10) } });
|
|
3369
3382
|
};
|
|
3370
3383
|
/**
|
|
3371
3384
|
* Returns volume.
|