diff --git a/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaClasses.cs b/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaClasses.cs index c58059f78..8ea9302c8 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaClasses.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaClasses.cs @@ -84,20 +84,20 @@ namespace Barotrauma env = e; } - public static void SendMessage(string msg, int messageType = 0, Client sender = null, Character character = null) + public static void SendMessage(string msg, ChatMessageType messageType = ChatMessageType.Server, Client sender = null, Character character = null) { - GameMain.Server.SendChatMessage(msg, (ChatMessageType)messageType, sender, character); + GameMain.Server.SendChatMessage(msg, messageType, sender, character); } - public static void SendTraitorMessage(Client client, string msg, int type) + public static void SendTraitorMessage(Client client, string msg, TraitorMessageType type) { - GameMain.Server.SendTraitorMessage(client, msg, "", (TraitorMessageType)type); + GameMain.Server.SendTraitorMessage(client, msg, "", type); } - public static void SendDirectChatMessage(string sendername, string text, Character sender, int messageType = 0, Client client = null) + public static void SendDirectChatMessage(string sendername, string text, Character sender, ChatMessageType messageType = ChatMessageType.Private, Client client = null) { - ChatMessage cm = ChatMessage.Create(sendername, text, (ChatMessageType)messageType, sender, client); + ChatMessage cm = ChatMessage.Create(sendername, text, messageType, sender, client); GameMain.Server.SendDirectChatMessage(cm, client); @@ -113,9 +113,9 @@ namespace Barotrauma overrideRespawnSub = o; } - public static void Log(string message, int type) + public static void Log(string message, ServerLog.MessageType type) { - GameServer.Log(message, (ServerLog.MessageType)type); + GameServer.Log(message, type); } public static void Explode(Vector2 pos, float range = 100, float force = 30, float damage = 30, float structureDamage = 30, float itemDamage = 30, float empStrength = 0, float ballastFloraStrength = 0) @@ -182,10 +182,36 @@ namespace Barotrauma return GameMain.Server.RespawnManager.RespawnShuttle; } + public static Items.Components.Steering GetSubmarineSteering(Submarine sub) + { + foreach (Item item in Item.ItemList) + { + if (item.Submarine != sub) continue; + + var steering = item.GetComponent(); + if (steering != null) + { + return steering; + } + } + + return null; + } + public static void DispatchRespawnSub() { GameMain.Server.RespawnManager.DispatchShuttle(); } + + public static void SetRespawnSubTeam(int team) + { + GameMain.Server.RespawnManager.RespawnShuttle.TeamID = (CharacterTeamType)team; + } + + public static void ExecuteCommand(string command) + { + DebugConsole.ExecuteCommand(command); + } } @@ -284,7 +310,11 @@ namespace Barotrauma { try { - return env.Call(hf.function, args); + var result = env.Call(hf.function, args); + if (result.IsNil() == false) + { + return result; + } } catch (Exception e) { diff --git a/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaSetup.cs b/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaSetup.cs index d3495a4c9..1cd65f9dc 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaSetup.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaSetup.cs @@ -83,12 +83,20 @@ namespace Barotrauma { Console.WriteLine("Lua!"); - LuaScriptLoader luaScriptLoader = new LuaScriptLoader(this); LuaCustomConverters.RegisterAll(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); UserData.RegisterType(); + UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); @@ -112,6 +120,18 @@ namespace Barotrauma lua.Globals["Hook"] = hook; lua.Globals["Random"] = new LuaRandom(); lua.Globals["Timer"] = new LuaTimer(this); + lua.Globals["WayPoint"] = UserData.CreateStatic(); + lua.Globals["SpawnType"] = UserData.CreateStatic(); + lua.Globals["ChatMessageType"] = UserData.CreateStatic(); + lua.Globals["ServerLog_MessageType"] = UserData.CreateStatic(); + lua.Globals["Submarine"] = UserData.CreateStatic(); + lua.Globals["Client"] = UserData.CreateStatic(); + lua.Globals["Character"] = UserData.CreateStatic(); + lua.Globals["Item"] = UserData.CreateStatic(); + lua.Globals["Level"] = UserData.CreateStatic(); + lua.Globals["Vector2"] = UserData.CreateStatic(); + lua.Globals["Vector3"] = UserData.CreateStatic(); + lua.Globals["PositionType"] = UserData.CreateStatic(); foreach (string d in Directory.GetDirectories("Lua")) {