serverLog hook and added a way to notify clients in custom interface
This commit is contained in:
@@ -5,6 +5,19 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
partial class CustomInterface : ItemComponent, IClientSerializable, IServerSerializable
|
partial class CustomInterface : ItemComponent, IClientSerializable, IServerSerializable
|
||||||
{
|
{
|
||||||
|
public void UpdateClients()
|
||||||
|
{
|
||||||
|
|
||||||
|
//notify all clients of the new state
|
||||||
|
GameMain.Server.CreateEntityEvent(item, new object[]
|
||||||
|
{
|
||||||
|
NetEntityEvent.Type.ComponentState,
|
||||||
|
item.GetComponentIndex(this)
|
||||||
|
});
|
||||||
|
|
||||||
|
item.CreateServerEvent(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void ServerRead(ClientNetObject type, IReadMessage msg, Client c)
|
public void ServerRead(ClientNetObject type, IReadMessage msg, Client c)
|
||||||
{
|
{
|
||||||
bool[] elementStates = new bool[customInterfaceElementList.Count];
|
bool[] elementStates = new bool[customInterfaceElementList.Count];
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PrintMessageNoLog(object message)
|
||||||
|
{
|
||||||
|
Console.WriteLine(message.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
public DynValue DoString(string code, Table globalContext = null, string codeStringFriendly = null)
|
public DynValue DoString(string code, Table globalContext = null, string codeStringFriendly = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -211,7 +216,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
hook = new LuaHook(this);
|
hook = new LuaHook(this);
|
||||||
game = new LuaGame(this);
|
game = new LuaGame(this);
|
||||||
|
|
||||||
|
lua.Globals["printNoLog"] = (Action<object>)PrintMessageNoLog;
|
||||||
|
|
||||||
lua.Globals["dofile"] = (Func<string, Table, string, DynValue>)DoFile;
|
lua.Globals["dofile"] = (Func<string, Table, string, DynValue>)DoFile;
|
||||||
lua.Globals["loadfile"] = (Func<string, Table, string, DynValue>)LoadFile;
|
lua.Globals["loadfile"] = (Func<string, Table, string, DynValue>)LoadFile;
|
||||||
lua.Globals["require"] = (Func<string, Table, DynValue>)Require;
|
lua.Globals["require"] = (Func<string, Table, DynValue>)Require;
|
||||||
@@ -257,7 +264,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (string d in Directory.GetDirectories("Mods"))
|
foreach (string d in Directory.GetDirectories("Mods"))
|
||||||
{
|
{
|
||||||
modulePaths.Add(d + "/Lua/?.lua");
|
modulePaths.Add(d + "/Lua/?");
|
||||||
|
|
||||||
if (Directory.Exists(d + "/Lua/Autorun"))
|
if (Directory.Exists(d + "/Lua/Autorun"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3842,6 +3842,8 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
if (GameMain.Server == null || !GameMain.Server.ServerSettings.SaveServerLogs) { return; }
|
if (GameMain.Server == null || !GameMain.Server.ServerSettings.SaveServerLogs) { return; }
|
||||||
|
|
||||||
|
GameMain.Lua.hook.Call("serverLog", new object[] { line, messageType });
|
||||||
|
|
||||||
GameMain.Server.ServerSettings.ServerLog.WriteLine(line, messageType);
|
GameMain.Server.ServerSettings.ServerLog.WriteLine(line, messageType);
|
||||||
|
|
||||||
foreach (Client client in GameMain.Server.ConnectedClients)
|
foreach (Client client in GameMain.Server.ConnectedClients)
|
||||||
|
|||||||
Reference in New Issue
Block a user