-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblocks.ts
136 lines (136 loc) · 3.17 KB
/
blocks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import * as SB3 from './SB3';
import { v4 as uuidv4 } from 'uuid';
import { ParsedInputValue } from './types';
export class SendBroadcast extends SB3.Block {
constructor(broadcastId: string, broadcastName: string) {
super(
uuidv4(),
'event_broadcastandwait',
null,
null,
false,
[],
[
new SB3.Input('BROADCAST_INPUT', 'shadow', [
SB3.InputType.Broadcast,
broadcastName,
broadcastId,
]),
]
);
}
}
export class Say extends SB3.Block {
constructor(id: string, message: ParsedInputValue) {
console.log(message);
super(
id,
'looks_say',
null,
null,
false,
[],
[
new SB3.Input(
'MESSAGE',
'shadow',
message.type === 'objectLiteral'
? [SB3.InputType.Text, message.value]
: message.id
),
]
);
}
}
export class SayForSecs extends SB3.Block {
constructor(id: string, message: ParsedInputValue, time: ParsedInputValue) {
super(
id,
'looks_sayforsecs',
null,
null,
false,
[],
[
new SB3.Input(
'MESSAGE',
'shadow',
message.type === 'objectLiteral'
? [SB3.InputType.Text, message.value]
: message.id
),
new SB3.Input(
'SECS',
'shadow',
time.type === 'objectLiteral'
? [SB3.InputType.MathNum, time.value]
: time.id
),
]
);
}
}
export class DeleteFromListSimple extends SB3.Block {
constructor(list: SB3.List, index: number) {
super(
uuidv4(),
'data_deleteoflist',
null,
null,
false,
[SB3.Field.createNewField('LIST', list.name, list.id)],
[new SB3.Input('INDEX', 'shadow', [SB3.InputType.Int, index.toString()])]
);
}
}
export class InsertIntoList extends SB3.Block {
constructor(list: SB3.List, index: number, text: ParsedInputValue) {
super(
uuidv4(),
'data_insertatlist',
null,
null,
false,
[SB3.Field.createNewField('LIST', list.name, list.id)],
[
new SB3.Input('INDEX', 'shadow', [SB3.InputType.Int, index.toString()]),
new SB3.Input(
'ITEM',
'shadow',
text.type === 'objectLiteral'
? [SB3.InputType.Text, text.value]
: text.id
),
]
);
}
}
export class InsertIntoListSimple extends SB3.Block {
constructor(list: SB3.List, index: number, text: string) {
super(
uuidv4(),
'data_insertatlist',
null,
null,
false,
[SB3.Field.createNewField('LIST', list.name, list.id)],
[
new SB3.Input('INDEX', 'shadow', [SB3.InputType.Int, index.toString()]),
new SB3.Input('ITEM', 'shadow', [SB3.InputType.Text, text]),
]
);
}
}
export class ItemFromListSimple extends SB3.Block {
constructor(list: SB3.List, index: number) {
super(
uuidv4(),
'data_itemoflist',
null,
null,
false,
[SB3.Field.createNewField('LIST', list.name, list.id)],
[new SB3.Input('INDEX', 'shadow', [SB3.InputType.Int, index.toString()])]
);
}
}