made modules partially work and replace/removed useless functions
This commit is contained in:
@@ -61,6 +61,7 @@ namespace Barotrauma
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
return lua.DoFile(file);
|
return lua.DoFile(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -71,6 +72,21 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public DynValue LoadFile(string file)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return lua.LoadFile(file);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
HandleLuaException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static DynValue CreateUserDataSafe(object o)
|
public static DynValue CreateUserDataSafe(object o)
|
||||||
{
|
{
|
||||||
if(o == null)
|
if(o == null)
|
||||||
@@ -86,6 +102,7 @@ namespace Barotrauma
|
|||||||
PrintMessage("Lua!");
|
PrintMessage("Lua!");
|
||||||
|
|
||||||
LuaScriptLoader luaScriptLoader = new LuaScriptLoader(this);
|
LuaScriptLoader luaScriptLoader = new LuaScriptLoader(this);
|
||||||
|
luaScriptLoader.ModulePaths = new string[] { };
|
||||||
|
|
||||||
LuaCustomConverters.RegisterAll();
|
LuaCustomConverters.RegisterAll();
|
||||||
|
|
||||||
@@ -163,6 +180,9 @@ namespace Barotrauma
|
|||||||
game = new LuaGame(this);
|
game = new LuaGame(this);
|
||||||
|
|
||||||
lua.Globals["dofile"] = (Func<string, DynValue>)DoFile;
|
lua.Globals["dofile"] = (Func<string, DynValue>)DoFile;
|
||||||
|
lua.Globals["loadfile"] = (Func<string, DynValue>)LoadFile;
|
||||||
|
lua.Globals["loadfilesafe"] = null;
|
||||||
|
|
||||||
lua.Globals["Player"] = new LuaPlayer();
|
lua.Globals["Player"] = new LuaPlayer();
|
||||||
lua.Globals["Game"] = game;
|
lua.Globals["Game"] = game;
|
||||||
lua.Globals["Hook"] = hook;
|
lua.Globals["Hook"] = hook;
|
||||||
@@ -196,23 +216,19 @@ namespace Barotrauma
|
|||||||
lua.Globals["InvSlotType"] = UserData.CreateStatic<InvSlotType>();
|
lua.Globals["InvSlotType"] = UserData.CreateStatic<InvSlotType>();
|
||||||
lua.Globals["Gap"] = UserData.CreateStatic<Gap>();
|
lua.Globals["Gap"] = UserData.CreateStatic<Gap>();
|
||||||
|
|
||||||
|
List<string> modulePaths = new List<string>();
|
||||||
|
|
||||||
foreach (string d in Directory.GetDirectories("Mods"))
|
foreach (string d in Directory.GetDirectories("Mods"))
|
||||||
{
|
{
|
||||||
|
modulePaths.Add(d + "/Lua/?.lua");
|
||||||
|
|
||||||
if (Directory.Exists(d + "/Lua/Autorun"))
|
if (Directory.Exists(d + "/Lua/Autorun"))
|
||||||
{
|
{
|
||||||
luaScriptLoader.RunFolder(d + "/Lua/Autorun");
|
luaScriptLoader.RunFolder(d + "/Lua/Autorun");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Directory.Exists(d + "/LuaRaw"))
|
|
||||||
{
|
|
||||||
foreach (string d2 in Directory.GetDirectories(d + "/LuaRaw"))
|
|
||||||
{
|
|
||||||
luaScriptLoader.RunFolder(d2 + "/Autorun");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaScriptLoader.ModulePaths = modulePaths.ToArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user