27 lines
596 B
C#
27 lines
596 B
C#
using IronPython.Hosting;
|
|
using Microsoft.Scripting.Hosting;
|
|
|
|
namespace Dungeoneer {
|
|
|
|
public static class Scripting {
|
|
private static ScriptEngine Engine;
|
|
private static dynamic Scope;
|
|
|
|
static Scripting() {
|
|
// set up python engine
|
|
Engine = Python.CreateEngine();
|
|
Scope = Engine.CreateScope();
|
|
dynamic Builtin = Engine.GetBuiltinModule();
|
|
|
|
// set up python environment
|
|
Builtin.Remove("open");
|
|
Scope.roll = new Func<int, int>((sides) => { return Dungeoneer.Util.Roll(sides); });
|
|
}
|
|
|
|
public static void Run(string file) {
|
|
Engine.ExecuteFile(file, Scope);
|
|
}
|
|
}
|
|
|
|
}
|
|
|