remove unnecessary stuff
This commit is contained in:
@@ -30,31 +30,31 @@ namespace Barotrauma
|
||||
{
|
||||
|
||||
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 =>
|
||||
{
|
||||
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 =>
|
||||
{
|
||||
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 =>
|
||||
{
|
||||
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 =>
|
||||
{
|
||||
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
|
||||
@@ -76,7 +76,7 @@ namespace Barotrauma
|
||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action<T>), v =>
|
||||
{
|
||||
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 =>
|
||||
{
|
||||
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
|
||||
{
|
||||
public static LuaSetup luaSetup;
|
||||
|
||||
public Script lua;
|
||||
|
||||
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)
|
||||
{
|
||||
try
|
||||
@@ -189,15 +181,6 @@ namespace Barotrauma
|
||||
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)
|
||||
{
|
||||
try
|
||||
@@ -217,11 +200,6 @@ namespace Barotrauma
|
||||
luaScriptLoader.ModulePaths = str;
|
||||
}
|
||||
|
||||
public float TestFunction(float value)
|
||||
{
|
||||
return value * 2;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (harmony != null)
|
||||
@@ -234,17 +212,12 @@ namespace Barotrauma
|
||||
game = null;
|
||||
networking = null;
|
||||
luaScriptLoader = null;
|
||||
|
||||
luaSetup = null;
|
||||
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Stop();
|
||||
|
||||
luaSetup = this;
|
||||
|
||||
PrintMessage("Lua! Version " + AssemblyInfo.GitRevision);
|
||||
|
||||
luaScriptLoader = new LuaScriptLoader(this);
|
||||
@@ -273,10 +246,6 @@ namespace Barotrauma
|
||||
|
||||
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["loadfile"] = (Func<string, Table, string, DynValue>)LoadFile;
|
||||
lua.Globals["require"] = (Func<string, Table, DynValue>)Require;
|
||||
|
||||
Reference in New Issue
Block a user