This commit is contained in:
Evil Factory
2021-08-20 19:01:28 -03:00
parent 529c1643a8
commit 1ff03398d6
2 changed files with 25 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ using Microsoft.Xna.Framework;
using Barotrauma.Networking;
using System.Threading.Tasks;
using Barotrauma.Items.Components;
using System.IO;
namespace Barotrauma
{
@@ -397,6 +398,26 @@ namespace Barotrauma
}
private class LuaFile
{
// TODO: SANDBOXING
public static string Read(string path)
{
return File.ReadAllText(path);
}
public static void Write(string path, string text)
{
File.WriteAllText(path, text);
}
public static bool Exists(string path)
{
return File.Exists(path);
}
}
// hooks:
// chatMessage
// think

View File

@@ -7,6 +7,7 @@ using MoonSharp.Interpreter;
using Microsoft.Xna.Framework;
using System.Threading.Tasks;
using Barotrauma.Items.Components;
using System.Diagnostics;
namespace Barotrauma
{
@@ -92,6 +93,7 @@ namespace Barotrauma
}
public LuaSetup()
{
PrintMessage("Lua!");
@@ -122,6 +124,7 @@ namespace Barotrauma
UserData.RegisterType<LuaGame>();
UserData.RegisterType<LuaRandom>();
UserData.RegisterType<LuaTimer>();
UserData.RegisterType<LuaFile>();
UserData.RegisterType<Vector2>();
UserData.RegisterType<Vector3>();
UserData.RegisterType<Vector4>();
@@ -174,6 +177,7 @@ namespace Barotrauma
lua.Globals["Hook"] = hook;
lua.Globals["Random"] = new LuaRandom();
lua.Globals["Timer"] = new LuaTimer(this);
lua.Globals["File"] = UserData.CreateStatic<LuaFile>();
lua.Globals["WayPoint"] = UserData.CreateStatic<WayPoint>();
lua.Globals["SpawnType"] = UserData.CreateStatic<SpawnType>();
lua.Globals["ChatMessageType"] = UserData.CreateStatic<ChatMessageType>();