2017-04-08 00:34:45 +02:00
|
|
|
package armory.logicnode;
|
|
|
|
|
2017-04-08 20:05:35 +02:00
|
|
|
class ScriptNode extends LogicNode {
|
2017-04-08 00:34:45 +02:00
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
public var property0: String;
|
|
|
|
var result: Dynamic;
|
2017-04-08 00:34:45 +02:00
|
|
|
|
2019-04-06 15:37:58 +02:00
|
|
|
#if hscript
|
2019-12-19 23:54:08 +01:00
|
|
|
var parser: hscript.Parser = null;
|
|
|
|
var interp: hscript.Interp = null;
|
|
|
|
var ast: hscript.Expr = null;
|
2017-10-18 09:51:35 +02:00
|
|
|
#end
|
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
public function new(tree: LogicTree) {
|
2017-04-08 00:34:45 +02:00
|
|
|
super(tree);
|
|
|
|
}
|
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
override function run(from: Int) {
|
2017-04-08 00:34:45 +02:00
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
var v: Dynamic = inputs[1].get();
|
2017-10-18 09:51:35 +02:00
|
|
|
|
2019-04-06 15:37:58 +02:00
|
|
|
#if hscript
|
2017-10-18 09:51:35 +02:00
|
|
|
if (parser == null) {
|
|
|
|
parser = new hscript.Parser();
|
|
|
|
parser.allowJSON = true;
|
|
|
|
parser.allowTypes = true;
|
|
|
|
ast = parser.parseString(property0);
|
|
|
|
interp = new hscript.Interp();
|
|
|
|
interp.variables.set("Math", Math);
|
2018-02-25 19:40:40 +01:00
|
|
|
interp.variables.set("Std", Std);
|
2017-10-18 09:51:35 +02:00
|
|
|
}
|
|
|
|
interp.variables.set("input", v);
|
2017-04-08 00:34:45 +02:00
|
|
|
result = interp.execute(ast);
|
2017-07-03 15:16:15 +02:00
|
|
|
#end
|
2017-04-08 00:34:45 +02:00
|
|
|
|
2018-10-22 10:10:33 +02:00
|
|
|
runOutput(0);
|
2017-04-08 00:34:45 +02:00
|
|
|
}
|
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
override function get(from: Int): Dynamic {
|
2017-04-08 00:34:45 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|