-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.js
More file actions
42 lines (38 loc) · 1.3 KB
/
extension.js
File metadata and controls
42 lines (38 loc) · 1.3 KB
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
class Finite {
constructor() {
this.ready = createModule
}
async _mod() {
return await this.ready;
}
async getInfo () {
return {
id: 'inf',
name: 'libfinite',
// blockIconURI: miiicon,
// menuIconURI: miiicon,
docsURI: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
color1: '#f6ab31',
color2: '#ca0303',
blocks: [
{
opcode: "logMessage",
blockType: Scratch.BlockType.COMMAND,
text: "log [message] at level [level]",
arguments: {
message: { type: Scratch.ArgumentType.STRING, defaultValue: "Hi Mom!" },
level: { type: Scratch.ArgumentType.STRING, defaultValue: "INFO" }
}
}
]
};
}
async logMessage({ message, level }) {
const mod = await this._mod();
const levelMap = { DEBUG: 0, INFO: 1, WARNING: 2, ERROR: 3, FATAL: 4 };
mod.ccall("finite_log_internal", null,
["number", "string", "number", "string", "string"],
[levelMap[level], "scratch", 0, "logMessage", message]);
}
}
Scratch.extensions.register(new Finite());