-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLua.js
More file actions
36 lines (28 loc) · 699 Bytes
/
Lua.js
File metadata and controls
36 lines (28 loc) · 699 Bytes
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
const outEl = document.getElementById("out");
const code = document.getElementById("code");
var runCode = function() {}
function handleChange() {
code.style.height = "auto";
code.style.height = (25 + document.getElementById("code").scrollHeight) + "px";
runCode();
}
console.log = (msg) => {
outEl.innerHTML += he.encode(msg) + "\n"
}
var Module = {};
Module.onRuntimeInitialized = () => {
const runLua = Module.cwrap(
"run_lua",
"number",
["string"]
);
runCode = function () {
outEl.innerHTML = "";
const errPtr = runLua(code.value);
if (errPtr) {
const err = UTF8ToString(errPtr);
outEl.innerHTML = he.encode(err);
}
}
runCode()
}