scripting
This commit is contained in:
@@ -1,18 +1,33 @@
|
||||
package funkin.scripting;
|
||||
|
||||
import hscript.Expr.Error;
|
||||
import openfl.Assets;
|
||||
import hscript.*;
|
||||
|
||||
class HScript extends Script {
|
||||
var interp:Interp;
|
||||
public override function create(path:String) {
|
||||
super.create(path);
|
||||
public override function onCreate(path:String) {
|
||||
super.onCreate(path);
|
||||
|
||||
interp = new Interp();
|
||||
|
||||
var code:String = Assets.getText(path);
|
||||
interp = new Interp();
|
||||
var parser = new hscript.Parser();
|
||||
parser.allowJSON = parser.allowMetadata = parser.allowTypes = true;
|
||||
var expr:Expr;
|
||||
try {
|
||||
expr = parser.parseString(code, filename);
|
||||
} catch(e) {
|
||||
return;
|
||||
}
|
||||
interp.errorHandler = _errorHandler;
|
||||
}
|
||||
|
||||
public override function call() {
|
||||
private function _errorHandler(error:Error) {
|
||||
error('$fileName:${error.line}: ${Std.string(error.e)}');
|
||||
}
|
||||
|
||||
public override function call(func:String, parameters:Array<Dynamic>) {
|
||||
// TODO: call
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user