dev: 更新代码,并准备LuaMod
This commit is contained in:
@ -1,19 +1,19 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
using NLua;
|
||||
|
||||
class LuaMod : IDisposable {
|
||||
public class LuaModManager : IDisposable {
|
||||
private readonly Lua lua = new();
|
||||
private static readonly Logging.Logger logger = Logging.GetLogger("LuaMod");
|
||||
|
||||
public LuaMod(string path, string? package_path = null) {
|
||||
public LuaModManager(string path, string? package_path = null) {
|
||||
lua.LoadCLRPackage();
|
||||
lua.State.Encoding = System.Text.Encoding.UTF8;
|
||||
lua["package.path"] = package_path ?? Path.GetDirectoryName(path) + "/?.lua;";
|
||||
lua.RegisterFunction("print", new Action<object[]>(GD.Print).Method);
|
||||
// Action bar = () => { GD.Print("bar"); };
|
||||
// lua.RegisterFunction("bar", bar.Target, bar.Method);
|
||||
lua.RegisterFunction("print", new Action<object[]>(Godot.GD.Print).Method);
|
||||
|
||||
logger.Info("Loading Lua Mod: " + path);
|
||||
lua.DoFile(path);
|
||||
}
|
||||
|
||||
@ -36,5 +36,9 @@ class LuaMod : IDisposable {
|
||||
lua?.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public static void WriteComment(Delegate @delegate) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user