hikkaku 0.3.3 → 0.3.5
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 -135
- 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,11 +971,7 @@ const broadcast = (message) => {
|
|
|
974
971
|
* ```
|
|
975
972
|
*/
|
|
976
973
|
const broadcastAndWait = (message) => {
|
|
977
|
-
return block("event_broadcastandwait", { inputs: { BROADCAST_INPUT:
|
|
978
|
-
InputType.Broadcast,
|
|
979
|
-
message,
|
|
980
|
-
message
|
|
981
|
-
]] : fromPrimitiveSource(message) } });
|
|
974
|
+
return block("event_broadcastandwait", { inputs: { BROADCAST_INPUT: fromPrimitiveSource(InputType.Broadcast, message, "message1") } });
|
|
982
975
|
};
|
|
983
976
|
|
|
984
977
|
//#endregion
|
|
@@ -999,7 +992,7 @@ const broadcastAndWait = (message) => {
|
|
|
999
992
|
* ```
|
|
1000
993
|
*/
|
|
1001
994
|
const say = (message) => {
|
|
1002
|
-
return block("looks_say", { inputs: { MESSAGE: fromPrimitiveSource(message) } });
|
|
995
|
+
return block("looks_say", { inputs: { MESSAGE: fromPrimitiveSource(InputType.String, message, "Hello!") } });
|
|
1003
996
|
};
|
|
1004
997
|
/**
|
|
1005
998
|
* Speaks for duration.
|
|
@@ -1019,8 +1012,8 @@ const say = (message) => {
|
|
|
1019
1012
|
*/
|
|
1020
1013
|
const sayForSecs = (message, seconds) => {
|
|
1021
1014
|
return block("looks_sayforsecs", { inputs: {
|
|
1022
|
-
MESSAGE: fromPrimitiveSource(message),
|
|
1023
|
-
SECS: fromPrimitiveSource(seconds)
|
|
1015
|
+
MESSAGE: fromPrimitiveSource(InputType.String, message, "Hello!"),
|
|
1016
|
+
SECS: fromPrimitiveSource(InputType.Number, seconds, 2)
|
|
1024
1017
|
} });
|
|
1025
1018
|
};
|
|
1026
1019
|
/**
|
|
@@ -1039,7 +1032,7 @@ const sayForSecs = (message, seconds) => {
|
|
|
1039
1032
|
* ```
|
|
1040
1033
|
*/
|
|
1041
1034
|
const think = (message) => {
|
|
1042
|
-
return block("looks_think", { inputs: { MESSAGE: fromPrimitiveSource(message) } });
|
|
1035
|
+
return block("looks_think", { inputs: { MESSAGE: fromPrimitiveSource(InputType.String, message, "Hello!") } });
|
|
1043
1036
|
};
|
|
1044
1037
|
/**
|
|
1045
1038
|
* Thinks for duration.
|
|
@@ -1059,8 +1052,8 @@ const think = (message) => {
|
|
|
1059
1052
|
*/
|
|
1060
1053
|
const thinkForSecs = (message, seconds) => {
|
|
1061
1054
|
return block("looks_thinkforsecs", { inputs: {
|
|
1062
|
-
MESSAGE: fromPrimitiveSource(message),
|
|
1063
|
-
SECS: fromPrimitiveSource(seconds)
|
|
1055
|
+
MESSAGE: fromPrimitiveSource(InputType.String, message, "Hello!"),
|
|
1056
|
+
SECS: fromPrimitiveSource(InputType.Number, seconds, 2)
|
|
1064
1057
|
} });
|
|
1065
1058
|
};
|
|
1066
1059
|
/**
|
|
@@ -1215,7 +1208,7 @@ const nextBackdrop = () => {
|
|
|
1215
1208
|
*/
|
|
1216
1209
|
const changeLooksEffectBy = (effect, value) => {
|
|
1217
1210
|
return block("looks_changeeffectby", {
|
|
1218
|
-
inputs: { CHANGE: fromPrimitiveSource(value) },
|
|
1211
|
+
inputs: { CHANGE: fromPrimitiveSource(InputType.Number, value, 10) },
|
|
1219
1212
|
fields: { EFFECT: [effect, null] }
|
|
1220
1213
|
});
|
|
1221
1214
|
};
|
|
@@ -1237,7 +1230,7 @@ const changeLooksEffectBy = (effect, value) => {
|
|
|
1237
1230
|
*/
|
|
1238
1231
|
const setLooksEffectTo = (effect, value) => {
|
|
1239
1232
|
return block("looks_seteffectto", {
|
|
1240
|
-
inputs: { VALUE: fromPrimitiveSource(value) },
|
|
1233
|
+
inputs: { VALUE: fromPrimitiveSource(InputType.Number, value, 100) },
|
|
1241
1234
|
fields: { EFFECT: [effect, null] }
|
|
1242
1235
|
});
|
|
1243
1236
|
};
|
|
@@ -1274,7 +1267,7 @@ const clearGraphicEffects = () => {
|
|
|
1274
1267
|
* ```
|
|
1275
1268
|
*/
|
|
1276
1269
|
const changeSizeBy = (value) => {
|
|
1277
|
-
return block("looks_changesizeby", { inputs: { CHANGE: fromPrimitiveSource(value) } });
|
|
1270
|
+
return block("looks_changesizeby", { inputs: { CHANGE: fromPrimitiveSource(InputType.Number, value, 10) } });
|
|
1278
1271
|
};
|
|
1279
1272
|
/**
|
|
1280
1273
|
* Sets size.
|
|
@@ -1292,7 +1285,7 @@ const changeSizeBy = (value) => {
|
|
|
1292
1285
|
* ```
|
|
1293
1286
|
*/
|
|
1294
1287
|
const setSizeTo = (value) => {
|
|
1295
|
-
return block("looks_setsizeto", { inputs: { SIZE: fromPrimitiveSource(value) } });
|
|
1288
|
+
return block("looks_setsizeto", { inputs: { SIZE: fromPrimitiveSource(InputType.Number, value, 100) } });
|
|
1296
1289
|
};
|
|
1297
1290
|
/**
|
|
1298
1291
|
* Moves sprite layer.
|
|
@@ -1330,7 +1323,7 @@ const goToFrontBack = (position) => {
|
|
|
1330
1323
|
*/
|
|
1331
1324
|
const goForwardBackwardLayers = (direction, layers) => {
|
|
1332
1325
|
return block("looks_goforwardbackwardlayers", {
|
|
1333
|
-
inputs: { NUM: fromPrimitiveSource(layers) },
|
|
1326
|
+
inputs: { NUM: fromPrimitiveSource(InputType.Integer, layers, 1) },
|
|
1334
1327
|
fields: { FORWARD_BACKWARD: [direction, null] }
|
|
1335
1328
|
});
|
|
1336
1329
|
};
|
|
@@ -1406,7 +1399,7 @@ const getBackdropNumberName = (value) => {
|
|
|
1406
1399
|
* ```
|
|
1407
1400
|
*/
|
|
1408
1401
|
const moveSteps = (steps) => {
|
|
1409
|
-
return block("motion_movesteps", { inputs: { STEPS: fromPrimitiveSource(steps) } });
|
|
1402
|
+
return block("motion_movesteps", { inputs: { STEPS: fromPrimitiveSource(InputType.Number, steps, 10) } });
|
|
1410
1403
|
};
|
|
1411
1404
|
/**
|
|
1412
1405
|
* Moves to coordinates.
|
|
@@ -1426,8 +1419,8 @@ const moveSteps = (steps) => {
|
|
|
1426
1419
|
*/
|
|
1427
1420
|
const gotoXY = (x, y) => {
|
|
1428
1421
|
return block("motion_gotoxy", { inputs: {
|
|
1429
|
-
X: fromPrimitiveSource(x),
|
|
1430
|
-
Y: fromPrimitiveSource(y)
|
|
1422
|
+
X: fromPrimitiveSource(InputType.Number, x, 0),
|
|
1423
|
+
Y: fromPrimitiveSource(InputType.Number, y, 0)
|
|
1431
1424
|
} });
|
|
1432
1425
|
};
|
|
1433
1426
|
/**
|
|
@@ -1446,7 +1439,7 @@ const gotoXY = (x, y) => {
|
|
|
1446
1439
|
* ```
|
|
1447
1440
|
*/
|
|
1448
1441
|
const changeXBy = (dx) => {
|
|
1449
|
-
return block("motion_changexby", { inputs: { DX: fromPrimitiveSource(dx) } });
|
|
1442
|
+
return block("motion_changexby", { inputs: { DX: fromPrimitiveSource(InputType.Number, dx, 10) } });
|
|
1450
1443
|
};
|
|
1451
1444
|
/**
|
|
1452
1445
|
* Changes Y.
|
|
@@ -1464,7 +1457,7 @@ const changeXBy = (dx) => {
|
|
|
1464
1457
|
* ```
|
|
1465
1458
|
*/
|
|
1466
1459
|
const changeYBy = (dy) => {
|
|
1467
|
-
return block("motion_changeyby", { inputs: { DY: fromPrimitiveSource(dy) } });
|
|
1460
|
+
return block("motion_changeyby", { inputs: { DY: fromPrimitiveSource(InputType.Number, dy, 10) } });
|
|
1468
1461
|
};
|
|
1469
1462
|
/**
|
|
1470
1463
|
* Sets X.
|
|
@@ -1482,7 +1475,7 @@ const changeYBy = (dy) => {
|
|
|
1482
1475
|
* ```
|
|
1483
1476
|
*/
|
|
1484
1477
|
const setX = (x) => {
|
|
1485
|
-
return block("motion_setx", { inputs: { X: fromPrimitiveSource(x) } });
|
|
1478
|
+
return block("motion_setx", { inputs: { X: fromPrimitiveSource(InputType.Number, x, 0) } });
|
|
1486
1479
|
};
|
|
1487
1480
|
/**
|
|
1488
1481
|
* Sets Y.
|
|
@@ -1500,7 +1493,7 @@ const setX = (x) => {
|
|
|
1500
1493
|
* ```
|
|
1501
1494
|
*/
|
|
1502
1495
|
const setY = (y) => {
|
|
1503
|
-
return block("motion_sety", { inputs: { Y: fromPrimitiveSource(y) } });
|
|
1496
|
+
return block("motion_sety", { inputs: { Y: fromPrimitiveSource(InputType.Number, y, 0) } });
|
|
1504
1497
|
};
|
|
1505
1498
|
/**
|
|
1506
1499
|
* Moves to target.
|
|
@@ -1543,7 +1536,7 @@ const menuOfGoTo = (target = GOTO_RANDOM) => {
|
|
|
1543
1536
|
* ```
|
|
1544
1537
|
*/
|
|
1545
1538
|
const turnRight = (degrees) => {
|
|
1546
|
-
return block("motion_turnright", { inputs: { DEGREES: fromPrimitiveSource(degrees) } });
|
|
1539
|
+
return block("motion_turnright", { inputs: { DEGREES: fromPrimitiveSource(InputType.Number, degrees, 15) } });
|
|
1547
1540
|
};
|
|
1548
1541
|
/**
|
|
1549
1542
|
* Turns left.
|
|
@@ -1561,7 +1554,7 @@ const turnRight = (degrees) => {
|
|
|
1561
1554
|
* ```
|
|
1562
1555
|
*/
|
|
1563
1556
|
const turnLeft = (degrees) => {
|
|
1564
|
-
return block("motion_turnleft", { inputs: { DEGREES: fromPrimitiveSource(degrees) } });
|
|
1557
|
+
return block("motion_turnleft", { inputs: { DEGREES: fromPrimitiveSource(InputType.Number, degrees, 15) } });
|
|
1565
1558
|
};
|
|
1566
1559
|
/**
|
|
1567
1560
|
* Points direction.
|
|
@@ -1579,7 +1572,7 @@ const turnLeft = (degrees) => {
|
|
|
1579
1572
|
* ```
|
|
1580
1573
|
*/
|
|
1581
1574
|
const pointInDirection = (direction) => {
|
|
1582
|
-
return block("motion_pointindirection", { inputs: { DIRECTION: fromPrimitiveSource(direction) } });
|
|
1575
|
+
return block("motion_pointindirection", { inputs: { DIRECTION: fromPrimitiveSource(InputType.Angle, direction, 90) } });
|
|
1583
1576
|
};
|
|
1584
1577
|
/**
|
|
1585
1578
|
* Points toward target.
|
|
@@ -1625,9 +1618,9 @@ const menuOfPointTowards = (target = TOWARDS_MOUSE_POINTER) => {
|
|
|
1625
1618
|
*/
|
|
1626
1619
|
const glide = (seconds, x, y) => {
|
|
1627
1620
|
return block("motion_glidesecstoxy", { inputs: {
|
|
1628
|
-
SECS: fromPrimitiveSource(seconds),
|
|
1629
|
-
X: fromPrimitiveSource(x),
|
|
1630
|
-
Y: fromPrimitiveSource(y)
|
|
1621
|
+
SECS: fromPrimitiveSource(InputType.Number, seconds, 1),
|
|
1622
|
+
X: fromPrimitiveSource(InputType.Number, x, 0),
|
|
1623
|
+
Y: fromPrimitiveSource(InputType.Number, y, 0)
|
|
1631
1624
|
} });
|
|
1632
1625
|
};
|
|
1633
1626
|
/**
|
|
@@ -1648,7 +1641,7 @@ const glide = (seconds, x, y) => {
|
|
|
1648
1641
|
*/
|
|
1649
1642
|
const glideTo = (seconds, target) => {
|
|
1650
1643
|
return block("motion_glideto", { inputs: {
|
|
1651
|
-
SECS: fromPrimitiveSource(seconds),
|
|
1644
|
+
SECS: fromPrimitiveSource(InputType.Number, seconds, 1),
|
|
1652
1645
|
TO: menuInput(target, menuOfGlideTo)
|
|
1653
1646
|
} });
|
|
1654
1647
|
};
|
|
@@ -1765,8 +1758,8 @@ const getDirection = () => {
|
|
|
1765
1758
|
*/
|
|
1766
1759
|
const playDrumForBeats = (drum, beats) => {
|
|
1767
1760
|
return block("music_playDrumForBeats", { inputs: {
|
|
1768
|
-
DRUM: fromPrimitiveSource(drum),
|
|
1769
|
-
BEATS: fromPrimitiveSource(beats)
|
|
1761
|
+
DRUM: fromPrimitiveSource(InputType.Number, drum, 1),
|
|
1762
|
+
BEATS: fromPrimitiveSource(InputType.Number, beats, .25)
|
|
1770
1763
|
} });
|
|
1771
1764
|
};
|
|
1772
1765
|
/**
|
|
@@ -1787,8 +1780,8 @@ const playDrumForBeats = (drum, beats) => {
|
|
|
1787
1780
|
*/
|
|
1788
1781
|
const midiPlayDrumForBeats = (drum, beats) => {
|
|
1789
1782
|
return block("music_midiPlayDrumForBeats", { inputs: {
|
|
1790
|
-
DRUM: fromPrimitiveSource(drum),
|
|
1791
|
-
BEATS: fromPrimitiveSource(beats)
|
|
1783
|
+
DRUM: fromPrimitiveSource(InputType.Number, drum, 1),
|
|
1784
|
+
BEATS: fromPrimitiveSource(InputType.Number, beats, .25)
|
|
1792
1785
|
} });
|
|
1793
1786
|
};
|
|
1794
1787
|
/**
|
|
@@ -1807,7 +1800,7 @@ const midiPlayDrumForBeats = (drum, beats) => {
|
|
|
1807
1800
|
* ```
|
|
1808
1801
|
*/
|
|
1809
1802
|
const restForBeats = (beats) => {
|
|
1810
|
-
return block("music_restForBeats", { inputs: { BEATS: fromPrimitiveSource(beats) } });
|
|
1803
|
+
return block("music_restForBeats", { inputs: { BEATS: fromPrimitiveSource(InputType.Number, beats, .25) } });
|
|
1811
1804
|
};
|
|
1812
1805
|
/**
|
|
1813
1806
|
* Plays note for beats.
|
|
@@ -1827,8 +1820,8 @@ const restForBeats = (beats) => {
|
|
|
1827
1820
|
*/
|
|
1828
1821
|
const playNoteForBeats = (note, beats) => {
|
|
1829
1822
|
return block("music_playNoteForBeats", { inputs: {
|
|
1830
|
-
NOTE: fromPrimitiveSource(note),
|
|
1831
|
-
BEATS: fromPrimitiveSource(beats)
|
|
1823
|
+
NOTE: fromPrimitiveSource(InputType.Number, note, 60),
|
|
1824
|
+
BEATS: fromPrimitiveSource(InputType.Number, beats, .25)
|
|
1832
1825
|
} });
|
|
1833
1826
|
};
|
|
1834
1827
|
/**
|
|
@@ -1847,7 +1840,7 @@ const playNoteForBeats = (note, beats) => {
|
|
|
1847
1840
|
* ```
|
|
1848
1841
|
*/
|
|
1849
1842
|
const setInstrument = (instrument) => {
|
|
1850
|
-
return block("music_setInstrument", { inputs: { INSTRUMENT: fromPrimitiveSource(instrument) } });
|
|
1843
|
+
return block("music_setInstrument", { inputs: { INSTRUMENT: fromPrimitiveSource(InputType.Number, instrument, 1) } });
|
|
1851
1844
|
};
|
|
1852
1845
|
/**
|
|
1853
1846
|
* Sets instrument with MIDI instrument mapping.
|
|
@@ -1865,7 +1858,7 @@ const setInstrument = (instrument) => {
|
|
|
1865
1858
|
* ```
|
|
1866
1859
|
*/
|
|
1867
1860
|
const midiSetInstrument = (instrument) => {
|
|
1868
|
-
return block("music_midiSetInstrument", { inputs: { INSTRUMENT: fromPrimitiveSource(instrument) } });
|
|
1861
|
+
return block("music_midiSetInstrument", { inputs: { INSTRUMENT: fromPrimitiveSource(InputType.Number, instrument, 1) } });
|
|
1869
1862
|
};
|
|
1870
1863
|
/**
|
|
1871
1864
|
* Sets tempo.
|
|
@@ -1883,7 +1876,7 @@ const midiSetInstrument = (instrument) => {
|
|
|
1883
1876
|
* ```
|
|
1884
1877
|
*/
|
|
1885
1878
|
const setTempo = (tempo) => {
|
|
1886
|
-
return block("music_setTempo", { inputs: { TEMPO: fromPrimitiveSource(tempo) } });
|
|
1879
|
+
return block("music_setTempo", { inputs: { TEMPO: fromPrimitiveSource(InputType.Number, tempo, 20) } });
|
|
1887
1880
|
};
|
|
1888
1881
|
/**
|
|
1889
1882
|
* Changes tempo.
|
|
@@ -1901,7 +1894,7 @@ const setTempo = (tempo) => {
|
|
|
1901
1894
|
* ```
|
|
1902
1895
|
*/
|
|
1903
1896
|
const changeTempo = (tempo) => {
|
|
1904
|
-
return block("music_changeTempo", { inputs: { TEMPO: fromPrimitiveSource(tempo) } });
|
|
1897
|
+
return block("music_changeTempo", { inputs: { TEMPO: fromPrimitiveSource(InputType.Number, tempo, 20) } });
|
|
1905
1898
|
};
|
|
1906
1899
|
/**
|
|
1907
1900
|
* Returns tempo.
|
|
@@ -1941,8 +1934,8 @@ const getTempo = () => {
|
|
|
1941
1934
|
*/
|
|
1942
1935
|
const add = (a, b) => {
|
|
1943
1936
|
return valueBlock("operator_add", { inputs: {
|
|
1944
|
-
NUM1: fromPrimitiveSource(a),
|
|
1945
|
-
NUM2: fromPrimitiveSource(b)
|
|
1937
|
+
NUM1: fromPrimitiveSource(InputType.Number, a, 0),
|
|
1938
|
+
NUM2: fromPrimitiveSource(InputType.Number, b, 0)
|
|
1946
1939
|
} });
|
|
1947
1940
|
};
|
|
1948
1941
|
/**
|
|
@@ -1963,8 +1956,8 @@ const add = (a, b) => {
|
|
|
1963
1956
|
*/
|
|
1964
1957
|
const subtract = (a, b) => {
|
|
1965
1958
|
return valueBlock("operator_subtract", { inputs: {
|
|
1966
|
-
NUM1: fromPrimitiveSource(a),
|
|
1967
|
-
NUM2: fromPrimitiveSource(b)
|
|
1959
|
+
NUM1: fromPrimitiveSource(InputType.Number, a, 0),
|
|
1960
|
+
NUM2: fromPrimitiveSource(InputType.Number, b, 0)
|
|
1968
1961
|
} });
|
|
1969
1962
|
};
|
|
1970
1963
|
/**
|
|
@@ -1985,8 +1978,8 @@ const subtract = (a, b) => {
|
|
|
1985
1978
|
*/
|
|
1986
1979
|
const multiply = (a, b) => {
|
|
1987
1980
|
return valueBlock("operator_multiply", { inputs: {
|
|
1988
|
-
NUM1: fromPrimitiveSource(a),
|
|
1989
|
-
NUM2: fromPrimitiveSource(b)
|
|
1981
|
+
NUM1: fromPrimitiveSource(InputType.Number, a, 0),
|
|
1982
|
+
NUM2: fromPrimitiveSource(InputType.Number, b, 0)
|
|
1990
1983
|
} });
|
|
1991
1984
|
};
|
|
1992
1985
|
/**
|
|
@@ -2007,8 +2000,8 @@ const multiply = (a, b) => {
|
|
|
2007
2000
|
*/
|
|
2008
2001
|
const divide = (a, b) => {
|
|
2009
2002
|
return valueBlock("operator_divide", { inputs: {
|
|
2010
|
-
NUM1: fromPrimitiveSource(a),
|
|
2011
|
-
NUM2: fromPrimitiveSource(b)
|
|
2003
|
+
NUM1: fromPrimitiveSource(InputType.Number, a, 0),
|
|
2004
|
+
NUM2: fromPrimitiveSource(InputType.Number, b, 0)
|
|
2012
2005
|
} });
|
|
2013
2006
|
};
|
|
2014
2007
|
/**
|
|
@@ -2029,8 +2022,8 @@ const divide = (a, b) => {
|
|
|
2029
2022
|
*/
|
|
2030
2023
|
const lt = (a, b) => {
|
|
2031
2024
|
return valueBlock("operator_lt", { inputs: {
|
|
2032
|
-
OPERAND1: fromPrimitiveSource(a),
|
|
2033
|
-
OPERAND2: fromPrimitiveSource(b)
|
|
2025
|
+
OPERAND1: fromPrimitiveSource(InputType.String, a, ""),
|
|
2026
|
+
OPERAND2: fromPrimitiveSource(InputType.String, b, "")
|
|
2034
2027
|
} });
|
|
2035
2028
|
};
|
|
2036
2029
|
/**
|
|
@@ -2051,8 +2044,8 @@ const lt = (a, b) => {
|
|
|
2051
2044
|
*/
|
|
2052
2045
|
const equals = (a, b) => {
|
|
2053
2046
|
return valueBlock("operator_equals", { inputs: {
|
|
2054
|
-
OPERAND1: fromPrimitiveSource(a),
|
|
2055
|
-
OPERAND2: fromPrimitiveSource(b)
|
|
2047
|
+
OPERAND1: fromPrimitiveSource(InputType.String, a, ""),
|
|
2048
|
+
OPERAND2: fromPrimitiveSource(InputType.String, b, "")
|
|
2056
2049
|
} });
|
|
2057
2050
|
};
|
|
2058
2051
|
/**
|
|
@@ -2073,8 +2066,8 @@ const equals = (a, b) => {
|
|
|
2073
2066
|
*/
|
|
2074
2067
|
const gt = (a, b) => {
|
|
2075
2068
|
return valueBlock("operator_gt", { inputs: {
|
|
2076
|
-
OPERAND1: fromPrimitiveSource(a),
|
|
2077
|
-
OPERAND2: fromPrimitiveSource(b)
|
|
2069
|
+
OPERAND1: fromPrimitiveSource(InputType.String, a, ""),
|
|
2070
|
+
OPERAND2: fromPrimitiveSource(InputType.String, b, "")
|
|
2078
2071
|
} });
|
|
2079
2072
|
};
|
|
2080
2073
|
/**
|
|
@@ -2095,8 +2088,8 @@ const gt = (a, b) => {
|
|
|
2095
2088
|
*/
|
|
2096
2089
|
const and = (a, b) => {
|
|
2097
2090
|
return valueBlock("operator_and", { inputs: {
|
|
2098
|
-
OPERAND1:
|
|
2099
|
-
OPERAND2:
|
|
2091
|
+
OPERAND1: fromBooleanSource(a),
|
|
2092
|
+
OPERAND2: fromBooleanSource(b)
|
|
2100
2093
|
} });
|
|
2101
2094
|
};
|
|
2102
2095
|
/**
|
|
@@ -2117,8 +2110,8 @@ const and = (a, b) => {
|
|
|
2117
2110
|
*/
|
|
2118
2111
|
const or = (a, b) => {
|
|
2119
2112
|
return valueBlock("operator_or", { inputs: {
|
|
2120
|
-
OPERAND1:
|
|
2121
|
-
OPERAND2:
|
|
2113
|
+
OPERAND1: fromBooleanSource(a),
|
|
2114
|
+
OPERAND2: fromBooleanSource(b)
|
|
2122
2115
|
} });
|
|
2123
2116
|
};
|
|
2124
2117
|
/**
|
|
@@ -2137,7 +2130,7 @@ const or = (a, b) => {
|
|
|
2137
2130
|
* ```
|
|
2138
2131
|
*/
|
|
2139
2132
|
const not = (operand) => {
|
|
2140
|
-
return valueBlock("operator_not", { inputs: { OPERAND:
|
|
2133
|
+
return valueBlock("operator_not", { inputs: { OPERAND: fromBooleanSource(operand) } });
|
|
2141
2134
|
};
|
|
2142
2135
|
/**
|
|
2143
2136
|
* Random number.
|
|
@@ -2157,8 +2150,8 @@ const not = (operand) => {
|
|
|
2157
2150
|
*/
|
|
2158
2151
|
const random = (from, to) => {
|
|
2159
2152
|
return valueBlock("operator_random", { inputs: {
|
|
2160
|
-
FROM: fromPrimitiveSource(from),
|
|
2161
|
-
TO: fromPrimitiveSource(to)
|
|
2153
|
+
FROM: fromPrimitiveSource(InputType.Number, from, 1),
|
|
2154
|
+
TO: fromPrimitiveSource(InputType.Number, to, 10)
|
|
2162
2155
|
} });
|
|
2163
2156
|
};
|
|
2164
2157
|
/**
|
|
@@ -2179,8 +2172,8 @@ const random = (from, to) => {
|
|
|
2179
2172
|
*/
|
|
2180
2173
|
const join = (a, b) => {
|
|
2181
2174
|
return valueBlock("operator_join", { inputs: {
|
|
2182
|
-
STRING1: fromPrimitiveSource(a),
|
|
2183
|
-
STRING2: fromPrimitiveSource(b)
|
|
2175
|
+
STRING1: fromPrimitiveSource(InputType.String, a, "apple"),
|
|
2176
|
+
STRING2: fromPrimitiveSource(InputType.String, b, "banana")
|
|
2184
2177
|
} });
|
|
2185
2178
|
};
|
|
2186
2179
|
/**
|
|
@@ -2201,8 +2194,8 @@ const join = (a, b) => {
|
|
|
2201
2194
|
*/
|
|
2202
2195
|
const letterOf = (letter, text) => {
|
|
2203
2196
|
return valueBlock("operator_letter_of", { inputs: {
|
|
2204
|
-
LETTER: fromPrimitiveSource(letter),
|
|
2205
|
-
STRING: fromPrimitiveSource(text)
|
|
2197
|
+
LETTER: fromPrimitiveSource(InputType.PositiveInteger, letter, 1),
|
|
2198
|
+
STRING: fromPrimitiveSource(InputType.String, text, "apple")
|
|
2206
2199
|
} });
|
|
2207
2200
|
};
|
|
2208
2201
|
/**
|
|
@@ -2221,7 +2214,7 @@ const letterOf = (letter, text) => {
|
|
|
2221
2214
|
* ```
|
|
2222
2215
|
*/
|
|
2223
2216
|
const length = (text) => {
|
|
2224
|
-
return valueBlock("operator_length", { inputs: { STRING: fromPrimitiveSource(text) } });
|
|
2217
|
+
return valueBlock("operator_length", { inputs: { STRING: fromPrimitiveSource(InputType.String, text, "apple") } });
|
|
2225
2218
|
};
|
|
2226
2219
|
/**
|
|
2227
2220
|
* Substring check.
|
|
@@ -2241,8 +2234,8 @@ const length = (text) => {
|
|
|
2241
2234
|
*/
|
|
2242
2235
|
const contains = (text, substring) => {
|
|
2243
2236
|
return valueBlock("operator_contains", { inputs: {
|
|
2244
|
-
STRING1: fromPrimitiveSource(text),
|
|
2245
|
-
STRING2: fromPrimitiveSource(substring)
|
|
2237
|
+
STRING1: fromPrimitiveSource(InputType.String, text, "apple"),
|
|
2238
|
+
STRING2: fromPrimitiveSource(InputType.String, substring, "a")
|
|
2246
2239
|
} });
|
|
2247
2240
|
};
|
|
2248
2241
|
/**
|
|
@@ -2263,8 +2256,8 @@ const contains = (text, substring) => {
|
|
|
2263
2256
|
*/
|
|
2264
2257
|
const mod = (a, b) => {
|
|
2265
2258
|
return valueBlock("operator_mod", { inputs: {
|
|
2266
|
-
NUM1: fromPrimitiveSource(a),
|
|
2267
|
-
NUM2: fromPrimitiveSource(b)
|
|
2259
|
+
NUM1: fromPrimitiveSource(InputType.Number, a, 0),
|
|
2260
|
+
NUM2: fromPrimitiveSource(InputType.Number, b, 0)
|
|
2268
2261
|
} });
|
|
2269
2262
|
};
|
|
2270
2263
|
/**
|
|
@@ -2283,7 +2276,7 @@ const mod = (a, b) => {
|
|
|
2283
2276
|
* ```
|
|
2284
2277
|
*/
|
|
2285
2278
|
const round = (value) => {
|
|
2286
|
-
return valueBlock("operator_round", { inputs: { NUM: fromPrimitiveSource(value) } });
|
|
2279
|
+
return valueBlock("operator_round", { inputs: { NUM: fromPrimitiveSource(InputType.Number, value, 0) } });
|
|
2287
2280
|
};
|
|
2288
2281
|
/**
|
|
2289
2282
|
* Math operation (sin, cos, log, etc.).
|
|
@@ -2303,7 +2296,7 @@ const round = (value) => {
|
|
|
2303
2296
|
*/
|
|
2304
2297
|
const mathop = (operator, value) => {
|
|
2305
2298
|
return valueBlock("operator_mathop", {
|
|
2306
|
-
inputs: { NUM: fromPrimitiveSource(value) },
|
|
2299
|
+
inputs: { NUM: fromPrimitiveSource(InputType.Number, value, 0) },
|
|
2307
2300
|
fields: { OPERATOR: [operator, null] }
|
|
2308
2301
|
});
|
|
2309
2302
|
};
|
|
@@ -2408,7 +2401,7 @@ const penUp = () => {
|
|
|
2408
2401
|
* ```
|
|
2409
2402
|
*/
|
|
2410
2403
|
const setPenColorTo = (color) => {
|
|
2411
|
-
return block("pen_setPenColorToColor", { inputs: { COLOR:
|
|
2404
|
+
return block("pen_setPenColorToColor", { inputs: { COLOR: fromPrimitiveSource(InputType.Color, color) } });
|
|
2412
2405
|
};
|
|
2413
2406
|
/**
|
|
2414
2407
|
* Alias for {@link setPenColorTo}.
|
|
@@ -2444,7 +2437,7 @@ const setPenColorToColor = setPenColorTo;
|
|
|
2444
2437
|
const changePenColorParamBy = (param, value) => {
|
|
2445
2438
|
return block("pen_changePenColorParamBy", { inputs: {
|
|
2446
2439
|
COLOR_PARAM: menuInput(param, menuOfPenColorParam),
|
|
2447
|
-
VALUE: fromPrimitiveSource(value)
|
|
2440
|
+
VALUE: fromPrimitiveSource(InputType.Number, value, 10)
|
|
2448
2441
|
} });
|
|
2449
2442
|
};
|
|
2450
2443
|
const menuOfPenColorParam = (colorParam = "color") => {
|
|
@@ -2472,7 +2465,7 @@ const menuOfPenColorParam = (colorParam = "color") => {
|
|
|
2472
2465
|
const setPenColorParamTo = (param, value) => {
|
|
2473
2466
|
return block("pen_setPenColorParamTo", { inputs: {
|
|
2474
2467
|
COLOR_PARAM: menuInput(param, menuOfPenColorParam),
|
|
2475
|
-
VALUE: fromPrimitiveSource(value)
|
|
2468
|
+
VALUE: fromPrimitiveSource(InputType.Number, value, 10)
|
|
2476
2469
|
} });
|
|
2477
2470
|
};
|
|
2478
2471
|
/**
|
|
@@ -2491,7 +2484,7 @@ const setPenColorParamTo = (param, value) => {
|
|
|
2491
2484
|
* ```
|
|
2492
2485
|
*/
|
|
2493
2486
|
const changePenSizeBy = (size) => {
|
|
2494
|
-
return block("pen_changePenSizeBy", { inputs: { SIZE: fromPrimitiveSource(size) } });
|
|
2487
|
+
return block("pen_changePenSizeBy", { inputs: { SIZE: fromPrimitiveSource(InputType.Number, size, 1) } });
|
|
2495
2488
|
};
|
|
2496
2489
|
/**
|
|
2497
2490
|
* Sets pen size to value.
|
|
@@ -2509,7 +2502,7 @@ const changePenSizeBy = (size) => {
|
|
|
2509
2502
|
* ```
|
|
2510
2503
|
*/
|
|
2511
2504
|
const setPenSizeTo = (size) => {
|
|
2512
|
-
return block("pen_setPenSizeTo", { inputs: { SIZE: fromPrimitiveSource(size) } });
|
|
2505
|
+
return block("pen_setPenSizeTo", { inputs: { SIZE: fromPrimitiveSource(InputType.Number, size, 1) } });
|
|
2513
2506
|
};
|
|
2514
2507
|
/**
|
|
2515
2508
|
* Sets pen shade to value.
|
|
@@ -2527,7 +2520,7 @@ const setPenSizeTo = (size) => {
|
|
|
2527
2520
|
* ```
|
|
2528
2521
|
*/
|
|
2529
2522
|
const setPenShadeToNumber = (shade) => {
|
|
2530
|
-
return block("pen_setPenShadeToNumber", { inputs: { SHADE: fromPrimitiveSource(shade) } });
|
|
2523
|
+
return block("pen_setPenShadeToNumber", { inputs: { SHADE: fromPrimitiveSource(InputType.Number, shade, 50) } });
|
|
2531
2524
|
};
|
|
2532
2525
|
/**
|
|
2533
2526
|
* Changes pen shade by amount.
|
|
@@ -2545,7 +2538,7 @@ const setPenShadeToNumber = (shade) => {
|
|
|
2545
2538
|
* ```
|
|
2546
2539
|
*/
|
|
2547
2540
|
const changePenShadeBy = (shade) => {
|
|
2548
|
-
return block("pen_changePenShadeBy", { inputs: { SHADE: fromPrimitiveSource(shade) } });
|
|
2541
|
+
return block("pen_changePenShadeBy", { inputs: { SHADE: fromPrimitiveSource(InputType.Number, shade, 50) } });
|
|
2549
2542
|
};
|
|
2550
2543
|
/**
|
|
2551
2544
|
* Sets pen hue to value.
|
|
@@ -2563,7 +2556,7 @@ const changePenShadeBy = (shade) => {
|
|
|
2563
2556
|
* ```
|
|
2564
2557
|
*/
|
|
2565
2558
|
const setPenHueToNumber = (hue) => {
|
|
2566
|
-
return block("pen_setPenHueToNumber", { inputs: { HUE: fromPrimitiveSource(hue) } });
|
|
2559
|
+
return block("pen_setPenHueToNumber", { inputs: { HUE: fromPrimitiveSource(InputType.Number, hue, 0) } });
|
|
2567
2560
|
};
|
|
2568
2561
|
/**
|
|
2569
2562
|
* Changes pen hue by amount.
|
|
@@ -2581,7 +2574,7 @@ const setPenHueToNumber = (hue) => {
|
|
|
2581
2574
|
* ```
|
|
2582
2575
|
*/
|
|
2583
2576
|
const changePenHueBy = (hue) => {
|
|
2584
|
-
return block("pen_changePenHueBy", { inputs: { HUE: fromPrimitiveSource(hue) } });
|
|
2577
|
+
return block("pen_changePenHueBy", { inputs: { HUE: fromPrimitiveSource(InputType.Number, hue, 0) } });
|
|
2585
2578
|
};
|
|
2586
2579
|
|
|
2587
2580
|
//#endregion
|
|
@@ -2613,7 +2606,7 @@ const procedureLabel = (text) => {
|
|
|
2613
2606
|
* ```ts
|
|
2614
2607
|
* import { procedureBoolean } from 'hikkaku/blocks'
|
|
2615
2608
|
*
|
|
2616
|
-
* procedureBoolean(
|
|
2609
|
+
* procedureBoolean('flag')
|
|
2617
2610
|
* ```
|
|
2618
2611
|
*/
|
|
2619
2612
|
const procedureBoolean = (name) => {
|
|
@@ -2631,7 +2624,7 @@ const procedureBoolean = (name) => {
|
|
|
2631
2624
|
* ```ts
|
|
2632
2625
|
* import { procedureStringOrNumber } from 'hikkaku/blocks'
|
|
2633
2626
|
*
|
|
2634
|
-
* procedureStringOrNumber(
|
|
2627
|
+
* procedureStringOrNumber('value')
|
|
2635
2628
|
* ```
|
|
2636
2629
|
*/
|
|
2637
2630
|
const procedureStringOrNumber = (name) => {
|
|
@@ -2769,21 +2762,25 @@ const callProcedure = (proccodeOrReference, argumentIdsOrInputs, inputsOrWarp, w
|
|
|
2769
2762
|
let proccode = "";
|
|
2770
2763
|
let argumentIds = [];
|
|
2771
2764
|
let inputs = {};
|
|
2765
|
+
let procedureReference = null;
|
|
2772
2766
|
if (typeof proccodeOrReference === "string") {
|
|
2773
2767
|
proccode = proccodeOrReference;
|
|
2774
2768
|
argumentIds = argumentIdsOrInputs;
|
|
2775
2769
|
inputs = (typeof inputsOrWarp === "object" ? inputsOrWarp : void 0) ?? {};
|
|
2776
2770
|
warp = typeof inputsOrWarp === "boolean" ? inputsOrWarp : warp;
|
|
2777
2771
|
} else {
|
|
2778
|
-
|
|
2772
|
+
procedureReference = "reference" in proccodeOrReference ? proccodeOrReference.reference : proccodeOrReference;
|
|
2779
2773
|
proccode = procedureReference.proccode;
|
|
2780
2774
|
argumentIds = procedureReference.argumentids;
|
|
2781
2775
|
warp = typeof inputsOrWarp === "boolean" ? inputsOrWarp : procedureReference.warp;
|
|
2782
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;
|
|
2783
2777
|
else if (!Array.isArray(argumentIdsOrInputs)) inputs = argumentIdsOrInputs;
|
|
2784
2778
|
}
|
|
2779
|
+
const argumentTypeMap = {};
|
|
2780
|
+
if (procedureReference) for (const arg of Object.values(procedureReference.arguments)) argumentTypeMap[arg.id] = arg.type;
|
|
2785
2781
|
const resolvedInputs = {};
|
|
2786
|
-
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, "");
|
|
2787
2784
|
return block("procedures_call", {
|
|
2788
2785
|
inputs: resolvedInputs,
|
|
2789
2786
|
mutation: {
|
|
@@ -2804,7 +2801,13 @@ const callProcedure = (proccodeOrReference, argumentIdsOrInputs, inputsOrWarp, w
|
|
|
2804
2801
|
* ```ts
|
|
2805
2802
|
* import { argumentReporterStringNumber } from 'hikkaku/blocks'
|
|
2806
2803
|
*
|
|
2807
|
-
* 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
|
+
* })
|
|
2808
2811
|
* ```
|
|
2809
2812
|
*/
|
|
2810
2813
|
const argumentReporterStringNumber = (reference) => {
|
|
@@ -2819,7 +2822,13 @@ const argumentReporterStringNumber = (reference) => {
|
|
|
2819
2822
|
* ```ts
|
|
2820
2823
|
* import { argumentReporterBoolean } from 'hikkaku/blocks'
|
|
2821
2824
|
*
|
|
2822
|
-
* 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
|
+
* })
|
|
2823
2832
|
* ```
|
|
2824
2833
|
*/
|
|
2825
2834
|
const argumentReporterBoolean = (reference) => {
|
|
@@ -2905,7 +2914,7 @@ const menuOfTouchingObject = (target = "_mouse_") => {
|
|
|
2905
2914
|
* ```
|
|
2906
2915
|
*/
|
|
2907
2916
|
const touchingColor = (color) => {
|
|
2908
|
-
return valueBlock("sensing_touchingcolor", { inputs: { COLOR:
|
|
2917
|
+
return valueBlock("sensing_touchingcolor", { inputs: { COLOR: fromPrimitiveSource(InputType.Color, color) } });
|
|
2909
2918
|
};
|
|
2910
2919
|
/**
|
|
2911
2920
|
* Color overlap check.
|
|
@@ -2925,8 +2934,8 @@ const touchingColor = (color) => {
|
|
|
2925
2934
|
*/
|
|
2926
2935
|
const colorTouchingColor = (color, targetColor) => {
|
|
2927
2936
|
return valueBlock("sensing_coloristouchingcolor", { inputs: {
|
|
2928
|
-
COLOR:
|
|
2929
|
-
COLOR2:
|
|
2937
|
+
COLOR: fromPrimitiveSource(InputType.Color, color),
|
|
2938
|
+
COLOR2: fromPrimitiveSource(InputType.Color, targetColor)
|
|
2930
2939
|
} });
|
|
2931
2940
|
};
|
|
2932
2941
|
/**
|
|
@@ -3159,7 +3168,7 @@ const isLoud = () => {
|
|
|
3159
3168
|
* ```
|
|
3160
3169
|
*/
|
|
3161
3170
|
const askAndWait = (question) => {
|
|
3162
|
-
return block("sensing_askandwait", { inputs: { QUESTION: fromPrimitiveSource(question) } });
|
|
3171
|
+
return block("sensing_askandwait", { inputs: { QUESTION: fromPrimitiveSource(InputType.String, question, "What's your name?") } });
|
|
3163
3172
|
};
|
|
3164
3173
|
/**
|
|
3165
3174
|
* Returns last answer.
|
|
@@ -3292,7 +3301,7 @@ const stopAllSounds = () => {
|
|
|
3292
3301
|
*/
|
|
3293
3302
|
const setSoundEffectTo = (effect, value) => {
|
|
3294
3303
|
return block("sound_seteffectto", {
|
|
3295
|
-
inputs: { VALUE: fromPrimitiveSource(value) },
|
|
3304
|
+
inputs: { VALUE: fromPrimitiveSource(InputType.Number, value, 10) },
|
|
3296
3305
|
fields: { EFFECT: [effect, null] }
|
|
3297
3306
|
});
|
|
3298
3307
|
};
|
|
@@ -3314,7 +3323,7 @@ const setSoundEffectTo = (effect, value) => {
|
|
|
3314
3323
|
*/
|
|
3315
3324
|
const changeSoundEffectBy = (effect, value) => {
|
|
3316
3325
|
return block("sound_changeeffectby", {
|
|
3317
|
-
inputs: { VALUE: fromPrimitiveSource(value) },
|
|
3326
|
+
inputs: { VALUE: fromPrimitiveSource(InputType.Number, value, 10) },
|
|
3318
3327
|
fields: { EFFECT: [effect, null] }
|
|
3319
3328
|
});
|
|
3320
3329
|
};
|
|
@@ -3351,7 +3360,7 @@ const clearEffects = () => {
|
|
|
3351
3360
|
* ```
|
|
3352
3361
|
*/
|
|
3353
3362
|
const setVolumeTo = (value) => {
|
|
3354
|
-
return block("sound_setvolumeto", { inputs: { VOLUME: fromPrimitiveSource(value) } });
|
|
3363
|
+
return block("sound_setvolumeto", { inputs: { VOLUME: fromPrimitiveSource(InputType.Number, value, 10) } });
|
|
3355
3364
|
};
|
|
3356
3365
|
/**
|
|
3357
3366
|
* Changes volume.
|
|
@@ -3369,7 +3378,7 @@ const setVolumeTo = (value) => {
|
|
|
3369
3378
|
* ```
|
|
3370
3379
|
*/
|
|
3371
3380
|
const changeVolumeBy = (value) => {
|
|
3372
|
-
return block("sound_changevolumeby", { inputs: { VOLUME: fromPrimitiveSource(value) } });
|
|
3381
|
+
return block("sound_changevolumeby", { inputs: { VOLUME: fromPrimitiveSource(InputType.Number, value, 10) } });
|
|
3373
3382
|
};
|
|
3374
3383
|
/**
|
|
3375
3384
|
* Returns volume.
|