lua now runs on sub editor, added Game.GetEnabledContentPackages back for compatibility and printerror
This commit is contained in:
@@ -523,6 +523,8 @@ namespace Barotrauma
|
|||||||
#region Selection
|
#region Selection
|
||||||
public override void Select()
|
public override void Select()
|
||||||
{
|
{
|
||||||
|
GameMain.Lua.Stop();
|
||||||
|
|
||||||
if (WorkshopItemsToUpdate.Any())
|
if (WorkshopItemsToUpdate.Any())
|
||||||
{
|
{
|
||||||
while (WorkshopItemsToUpdate.TryDequeue(out ulong workshopId))
|
while (WorkshopItemsToUpdate.TryDequeue(out ulong workshopId))
|
||||||
|
|||||||
@@ -1042,12 +1042,15 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GameSession gameSession = new GameSession(backedUpSubInfo, "", GameModePreset.TestMode, CampaignSettings.Empty, null);
|
GameSession gameSession = new GameSession(backedUpSubInfo, "", GameModePreset.TestMode, CampaignSettings.Empty, null);
|
||||||
gameSession.StartRound(null, false);
|
gameSession.StartRound(null, false);
|
||||||
|
|
||||||
(gameSession.GameMode as TestGameMode).OnRoundEnd = () =>
|
(gameSession.GameMode as TestGameMode).OnRoundEnd = () =>
|
||||||
{
|
{
|
||||||
Submarine.Unload();
|
Submarine.Unload();
|
||||||
GameMain.SubEditorScreen.Select();
|
GameMain.SubEditorScreen.Select();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameMain.Lua.Initialize();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1316,6 +1319,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void Select(bool enableAutoSave = true)
|
public void Select(bool enableAutoSave = true)
|
||||||
{
|
{
|
||||||
|
GameMain.Lua.Stop();
|
||||||
|
|
||||||
base.Select();
|
base.Select();
|
||||||
|
|
||||||
GUI.PreventPauseMenuToggle = false;
|
GUI.PreventPauseMenuToggle = false;
|
||||||
|
|||||||
@@ -51,8 +51,11 @@ local function runFolder(folder, rootFolder, package)
|
|||||||
local s = search[i]:gsub("\\", "/")
|
local s = search[i]:gsub("\\", "/")
|
||||||
|
|
||||||
if endsWith(s, ".lua") then
|
if endsWith(s, ".lua") then
|
||||||
executeProtected(s, rootFolder)
|
|
||||||
print(string.format("%s: Executing %s", package.Name, getFileName(s)))
|
print(string.format("%s: Executing %s", package.Name, getFileName(s)))
|
||||||
|
local ok, result = pcall(executeProtected, s, rootFolder)
|
||||||
|
if not ok then
|
||||||
|
printerror(result)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -103,7 +106,6 @@ for package in allPackages do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
setmodulepaths(modulePaths)
|
setmodulepaths(modulePaths)
|
||||||
|
|
||||||
Hook.Add("stop", "luaSetup.stop", function ()
|
Hook.Add("stop", "luaSetup.stop", function ()
|
||||||
|
|||||||
@@ -211,6 +211,11 @@ namespace Barotrauma
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ContentPackage[] GetEnabledContentPackages()
|
||||||
|
{
|
||||||
|
return ContentPackageManager.EnabledPackages.All.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
public static ItemPrefab GetItemPrefab(string itemNameOrId)
|
public static ItemPrefab GetItemPrefab(string itemNameOrId)
|
||||||
{
|
{
|
||||||
ItemPrefab itemPrefab =
|
ItemPrefab itemPrefab =
|
||||||
|
|||||||
@@ -282,6 +282,8 @@ namespace Barotrauma
|
|||||||
UserData.RegisterType<LuaUserData>();
|
UserData.RegisterType<LuaUserData>();
|
||||||
UserData.RegisterType<IUserDataDescriptor>();
|
UserData.RegisterType<IUserDataDescriptor>();
|
||||||
|
|
||||||
|
lua.Globals["printerror"] = (Action<object>)PrintError;
|
||||||
|
|
||||||
lua.Globals["setmodulepaths"] = (Action<string[]>)SetModulePaths;
|
lua.Globals["setmodulepaths"] = (Action<string[]>)SetModulePaths;
|
||||||
|
|
||||||
lua.Globals["dofile"] = (Func<string, Table, string, DynValue>)DoFile;
|
lua.Globals["dofile"] = (Func<string, Table, string, DynValue>)DoFile;
|
||||||
|
|||||||
Reference in New Issue
Block a user