Merge branch 'unstable-tests' of https://github.com/evilfactory/Barotrauma-lua-attempt into unstable-tests
This commit is contained in:
@@ -9,13 +9,13 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (!File.Exists(LuaCsSetup.VERSION_FILE)) { return; }
|
if (!File.Exists(LuaCsSetup.VERSION_FILE)) { return; }
|
||||||
|
|
||||||
ContentPackage luaCsPackage = LuaCsSetup.GetPackage();
|
ContentPackage luaPackage = LuaCsSetup.GetPackage("LuaForBarotraumaUnstable");
|
||||||
string luaCsPath = Path.GetDirectoryName(luaCsPackage.Path);
|
string luaCsPath = Path.GetDirectoryName(luaPackage.Path);
|
||||||
|
|
||||||
if (luaCsPackage == null) { return; }
|
if (luaPackage == null) { return; }
|
||||||
|
|
||||||
string clientVersion = File.ReadAllText(LuaCsSetup.VERSION_FILE);
|
string clientVersion = File.ReadAllText(LuaCsSetup.VERSION_FILE);
|
||||||
string workshopVersion = luaCsPackage.ModVersion;
|
string workshopVersion = luaPackage.ModVersion;
|
||||||
|
|
||||||
if (clientVersion == workshopVersion) { return; }
|
if (clientVersion == workshopVersion) { return; }
|
||||||
|
|
||||||
|
|||||||
@@ -1255,11 +1255,11 @@ namespace Barotrauma
|
|||||||
GameMain.LuaCs.Initialize();
|
GameMain.LuaCs.Initialize();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
commands.Add(new Command("install_cl_lua", "Installs client-Side Lua into your client.", (string[] args) =>
|
commands.Add(new Command("install_cl_lua", "Installs Client-Side Lua into your client.", (string[] args) =>
|
||||||
{
|
{
|
||||||
ContentPackage luaCsPackage = LuaCsSetup.GetPackage();
|
ContentPackage luaPackage = LuaCsSetup.GetPackage("LuaForBarotraumaUnstable");
|
||||||
|
|
||||||
if (luaCsPackage == null)
|
if (luaPackage == null)
|
||||||
{
|
{
|
||||||
GameMain.Server.SendChatMessage("Couldn't find the LuaCsForBarotrauma package.", ChatMessageType.ServerMessageBox);
|
GameMain.Server.SendChatMessage("Couldn't find the LuaCsForBarotrauma package.", ChatMessageType.ServerMessageBox);
|
||||||
return;
|
return;
|
||||||
@@ -1267,7 +1267,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string path = Path.GetDirectoryName(luaCsPackage.Path);
|
string path = Path.GetDirectoryName(luaPackage.Path);
|
||||||
|
|
||||||
string[] filesToCopy = new string[]
|
string[] filesToCopy = new string[]
|
||||||
{
|
{
|
||||||
@@ -1297,7 +1297,7 @@ namespace Barotrauma
|
|||||||
File.Copy(Path.Combine(path, "Binary", file), file, true);
|
File.Copy(Path.Combine(path, "Binary", file), file, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
File.WriteAllText(LuaCsSetup.VERSION_FILE, luaCsPackage.ModVersion);
|
File.WriteAllText(LuaCsSetup.VERSION_FILE, luaPackage.ModVersion);
|
||||||
}
|
}
|
||||||
catch (UnauthorizedAccessException e)
|
catch (UnauthorizedAccessException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
catch (CompilationErrorException ex)
|
catch (CompilationErrorException ex)
|
||||||
{
|
{
|
||||||
string errStr = "Cmopilation Error in '" + folder + "':";
|
string errStr = "Compilation Error in '" + folder + "':";
|
||||||
foreach (var diag in ex.Diagnostics)
|
foreach (var diag in ex.Diagnostics)
|
||||||
{
|
{
|
||||||
errStr += "\n" + diag.ToString();
|
errStr += "\n" + diag.ToString();
|
||||||
@@ -95,7 +95,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
IEnumerable<Diagnostic> failures = result.Diagnostics.Where(d => d.IsWarningAsError || d.Severity == DiagnosticSeverity.Error);
|
IEnumerable<Diagnostic> failures = result.Diagnostics.Where(d => d.IsWarningAsError || d.Severity == DiagnosticSeverity.Error);
|
||||||
|
|
||||||
string errStr = "NET MODS NOT LOADED | Mod cmopilation errors:";
|
string errStr = "NET MODS NOT LOADED | Mod compilation errors:";
|
||||||
foreach (Diagnostic diagnostic in failures)
|
foreach (Diagnostic diagnostic in failures)
|
||||||
errStr += $"\n{diagnostic}";
|
errStr += $"\n{diagnostic}";
|
||||||
LuaCsSetup.PrintCsError(errStr);
|
LuaCsSetup.PrintCsError(errStr);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
IEnumerable<Diagnostic> failures = result.Diagnostics.Where(d => d.IsWarningAsError || d.Severity == DiagnosticSeverity.Error);
|
IEnumerable<Diagnostic> failures = result.Diagnostics.Where(d => d.IsWarningAsError || d.Severity == DiagnosticSeverity.Error);
|
||||||
|
|
||||||
string errStr = "Script cmopilation errors:";
|
string errStr = "Script compilation errors:";
|
||||||
var lineErr = new SortedDictionary<int, (string, string)>();
|
var lineErr = new SortedDictionary<int, (string, string)>();
|
||||||
foreach (Diagnostic diagnostic in failures)
|
foreach (Diagnostic diagnostic in failures)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ContentPackage GetPackage()
|
public static ContentPackage GetPackage(Identifier name)
|
||||||
{
|
{
|
||||||
foreach (ContentPackage package in ContentPackageManager.LocalPackages)
|
foreach (ContentPackage package in ContentPackageManager.LocalPackages)
|
||||||
{
|
{
|
||||||
if (package.NameMatches(new Identifier("LuaCsForBarotraumaUnstable")))
|
if (package.NameMatches(name))
|
||||||
{
|
{
|
||||||
return package;
|
return package;
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (ContentPackage package in ContentPackageManager.AllPackages)
|
foreach (ContentPackage package in ContentPackageManager.AllPackages)
|
||||||
{
|
{
|
||||||
if (package.NameMatches(new Identifier("LuaCsForBarotraumaUnstable")))
|
if (package.NameMatches(name))
|
||||||
{
|
{
|
||||||
return package;
|
return package;
|
||||||
}
|
}
|
||||||
@@ -297,13 +297,11 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
PrintMessage("LuaCs! Version " + AssemblyInfo.GitRevision);
|
PrintMessage("Lua! Version " + AssemblyInfo.GitRevision);
|
||||||
|
|
||||||
LuaScriptLoader = new LuaScriptLoader();
|
LuaScriptLoader = new LuaScriptLoader();
|
||||||
LuaScriptLoader.ModulePaths = new string[] { };
|
LuaScriptLoader.ModulePaths = new string[] { };
|
||||||
|
|
||||||
NetScriptLoader = new CsScriptLoader(this);
|
|
||||||
|
|
||||||
LuaCustomConverters.RegisterAll();
|
LuaCustomConverters.RegisterAll();
|
||||||
|
|
||||||
lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.Debug);
|
lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.Debug);
|
||||||
@@ -358,21 +356,29 @@ namespace Barotrauma
|
|||||||
|
|
||||||
// LuaDocs.GenerateDocsAll();
|
// LuaDocs.GenerateDocsAll();
|
||||||
|
|
||||||
|
ContentPackage csPackage = GetPackage("CsForBarotrauma");
|
||||||
|
|
||||||
NetScriptLoader.SearchFolders();
|
|
||||||
if (NetScriptLoader == null) throw new Exception("LuaCsSetup was not properly initialized.");
|
if (csPackage != null)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var modTypes = NetScriptLoader.Compile();
|
NetScriptLoader = new CsScriptLoader(this);
|
||||||
modTypes.ForEach(t => t.GetConstructor(new Type[] { })?.Invoke(null));
|
|
||||||
}
|
NetScriptLoader.SearchFolders();
|
||||||
catch (Exception ex)
|
try
|
||||||
{
|
{
|
||||||
HandleException(ex, exceptionType: ExceptionType.CSharp);
|
var modTypes = NetScriptLoader.Compile();
|
||||||
|
modTypes.ForEach(t => t.GetConstructor(new Type[] { })?.Invoke(null));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HandleException(ex, exceptionType: ExceptionType.CSharp);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintMessage("Cs! Version " + AssemblyInfo.GitRevision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ContentPackage luaCsPackage = GetPackage();
|
ContentPackage luaPackage = GetPackage("LuaForBarotraumaUnstable");
|
||||||
|
|
||||||
if (File.Exists(LUASETUP_FILE))
|
if (File.Exists(LUASETUP_FILE))
|
||||||
{
|
{
|
||||||
@@ -385,9 +391,9 @@ namespace Barotrauma
|
|||||||
HandleException(e);
|
HandleException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (luaCsPackage != null)
|
else if (luaPackage != null)
|
||||||
{
|
{
|
||||||
string path = Path.GetDirectoryName(luaCsPackage.Path);
|
string path = Path.GetDirectoryName(luaPackage.Path);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user