Update moonsharp and move extension methods to register Lua file

This commit is contained in:
EvilFactory
2024-10-07 19:22:24 -03:00
parent 068d49f9c5
commit 3e4b649162
6 changed files with 33 additions and 4 deletions
@@ -23,6 +23,18 @@ namespace Barotrauma
return UserData.RegisterType(type);
}
public static void RegisterExtensionType(string typeName)
{
Type type = GetType(typeName);
if (type == null)
{
throw new ScriptRuntimeException($"tried to register a type that doesn't exist: {typeName}.");
}
UserData.RegisterExtensionType(type);
}
public static bool IsRegistered(string typeName)
{
Type type = GetType(typeName);
@@ -420,9 +420,6 @@ namespace Barotrauma
UserData.RegisterType<LuaCsPerformanceCounter>();
UserData.RegisterType<IUserDataDescriptor>();
UserData.RegisterExtensionType(typeof(MathUtils));
UserData.RegisterExtensionType(typeof(XMLExtensions));
Lua.Globals["printerror"] = (DynValue o) => { LuaCsLogger.LogError(o.ToString(), LuaCsMessageOrigin.LuaMod); };
Lua.Globals["setmodulepaths"] = (Action<string[]>)SetModulePaths;