remove unnecessary stuff

This commit is contained in:
Evil Factory
2022-03-17 12:50:59 -03:00
parent 86066282cc
commit 1d1747a2ca
2 changed files with 7 additions and 38 deletions
@@ -30,31 +30,31 @@ namespace Barotrauma
{ {
var function = v.Function; var function = v.Function;
return (GUIButton.OnClickedHandler)((GUIButton a, object b) => new LuaResult(LuaSetup.luaSetup.CallFunction(function, a, b)).Bool()); return (GUIButton.OnClickedHandler)((GUIButton a, object b) => new LuaResult(GameMain.Lua.CallFunction(function, a, b)).Bool());
}); });
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUITextBlock.TextGetterHandler), v => Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUITextBlock.TextGetterHandler), v =>
{ {
var function = v.Function; var function = v.Function;
return (GUITextBlock.TextGetterHandler)(() => new LuaResult(LuaSetup.luaSetup.CallFunction(function, new object[] {})).String()); return (GUITextBlock.TextGetterHandler)(() => new LuaResult(GameMain.Lua.CallFunction(function, new object[] {})).String());
}); });
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUITextBox.OnTextChangedHandler), v => Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUITextBox.OnTextChangedHandler), v =>
{ {
var function = v.Function; var function = v.Function;
return (GUITextBox.OnTextChangedHandler)((GUITextBox a, string b) => new LuaResult(LuaSetup.luaSetup.CallFunction(function, a, b)).Bool()); return (GUITextBox.OnTextChangedHandler)((GUITextBox a, string b) => new LuaResult(GameMain.Lua.CallFunction(function, a, b)).Bool());
}); });
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUITextBox.OnEnterHandler), v => Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUITextBox.OnEnterHandler), v =>
{ {
var function = v.Function; var function = v.Function;
return (GUITextBox.OnEnterHandler)((GUITextBox a, string b) => new LuaResult(LuaSetup.luaSetup.CallFunction(function, a, b)).Bool()); return (GUITextBox.OnEnterHandler)((GUITextBox a, string b) => new LuaResult(GameMain.Lua.CallFunction(function, a, b)).Bool());
}); });
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUITickBox.OnSelectedHandler), v => Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUITickBox.OnSelectedHandler), v =>
{ {
var function = v.Function; var function = v.Function;
return (GUITickBox.OnSelectedHandler)((GUITickBox a) => new LuaResult(LuaSetup.luaSetup.CallFunction(function, a)).Bool()); return (GUITickBox.OnSelectedHandler)((GUITickBox a) => new LuaResult(GameMain.Lua.CallFunction(function, a)).Bool());
}); });
#endif #endif
@@ -76,7 +76,7 @@ namespace Barotrauma
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action<T>), v => Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action<T>), v =>
{ {
var function = v.Function; var function = v.Function;
return (Action<T>)(p => LuaSetup.luaSetup.CallFunction(function, p)); return (Action<T>)(p => GameMain.Lua.CallFunction(function, p));
}); });
} }
@@ -85,7 +85,7 @@ namespace Barotrauma
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action), v => Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action), v =>
{ {
var function = v.Function; var function = v.Function;
return (Action)(() => LuaSetup.luaSetup.CallFunction(function)); return (Action)(() => GameMain.Lua.CallFunction(function));
}); });
} }
@@ -13,8 +13,6 @@ namespace Barotrauma
{ {
partial class LuaSetup partial class LuaSetup
{ {
public static LuaSetup luaSetup;
public Script lua; public Script lua;
public LuaHook hook; public LuaHook hook;
@@ -104,12 +102,6 @@ namespace Barotrauma
} }
public void PrintMessageNoLog(object message)
{
if (message == null) { message = "nil"; }
Console.WriteLine(message.ToString());
}
public DynValue DoString(string code, Table globalContext = null, string codeStringFriendly = null) public DynValue DoString(string code, Table globalContext = null, string codeStringFriendly = null)
{ {
try try
@@ -189,15 +181,6 @@ namespace Barotrauma
return null; return null;
} }
public static DynValue CreateUserDataSafe(object o)
{
if (o == null)
return DynValue.Nil;
return UserData.Create(o);
}
public object CallFunction(object function, params object[] arguments) public object CallFunction(object function, params object[] arguments)
{ {
try try
@@ -217,11 +200,6 @@ namespace Barotrauma
luaScriptLoader.ModulePaths = str; luaScriptLoader.ModulePaths = str;
} }
public float TestFunction(float value)
{
return value * 2;
}
public void Stop() public void Stop()
{ {
if (harmony != null) if (harmony != null)
@@ -234,17 +212,12 @@ namespace Barotrauma
game = null; game = null;
networking = null; networking = null;
luaScriptLoader = null; luaScriptLoader = null;
luaSetup = null;
} }
public void Initialize() public void Initialize()
{ {
Stop(); Stop();
luaSetup = this;
PrintMessage("Lua! Version " + AssemblyInfo.GitRevision); PrintMessage("Lua! Version " + AssemblyInfo.GitRevision);
luaScriptLoader = new LuaScriptLoader(this); luaScriptLoader = new LuaScriptLoader(this);
@@ -273,10 +246,6 @@ namespace Barotrauma
lua.Globals["setmodulepaths"] = (Action<string[]>)SetModulePaths; lua.Globals["setmodulepaths"] = (Action<string[]>)SetModulePaths;
lua.Globals["TestFunction"] = (Func<float, float>)TestFunction;
lua.Globals["printNoLog"] = (Action<object>)PrintMessageNoLog;
lua.Globals["dofile"] = (Func<string, Table, string, DynValue>)DoFile; lua.Globals["dofile"] = (Func<string, Table, string, DynValue>)DoFile;
lua.Globals["loadfile"] = (Func<string, Table, string, DynValue>)LoadFile; lua.Globals["loadfile"] = (Func<string, Table, string, DynValue>)LoadFile;
lua.Globals["require"] = (Func<string, Table, DynValue>)Require; lua.Globals["require"] = (Func<string, Table, DynValue>)Require;