Skip to content

Commit 0a67d6b

Browse files
authored
Update index.js
1 parent b129f0f commit 0a67d6b

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/Typings/Script/index.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
11
const Soup = require('@stews/soup');
22
const aepl = require('aepl');
33
const OUT = new Soup(Object);
4+
const yaml = require('js-yaml');
45

56

6-
class Script {}
7+
class Script {
8+
translate(code, meta) {
9+
Object.assign(this, yaml.load(meta)); // load and add the scene's metadata
10+
this.code = new this.parent.UnityscriptObject("code", code);
11+
12+
let lines = code.split("\n");
13+
this.lines = new this.parent.UnityscriptObject("lines", lines);
14+
15+
let flag = " }";
16+
17+
const stStart = code.indexOf("void Start");
18+
const stEnd = code.indexOf(flag);
19+
20+
const upStart = code.indexOf("void Update");
21+
const upEnd = code.lastIndexOf(flag);
22+
23+
this.start = code.substring(stStart, stEnd+flag.length);
24+
this.update = code.substring(upStart, upEnd+flag.length);
25+
26+
this.start = new this.parent.UnityscriptObject("start", this.start);
27+
this.update = new this.parent.UnityscriptObject("update", this.update);
28+
}
29+
}
730

831

932
OUT.push("Script", aepl.init("Script", Script));

0 commit comments

Comments
 (0)