file io
This commit is contained in:
@@ -6,6 +6,7 @@ using Microsoft.Xna.Framework;
|
|||||||
using Barotrauma.Networking;
|
using Barotrauma.Networking;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Barotrauma.Items.Components;
|
using Barotrauma.Items.Components;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Barotrauma
|
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:
|
// hooks:
|
||||||
// chatMessage
|
// chatMessage
|
||||||
// think
|
// think
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using MoonSharp.Interpreter;
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Barotrauma.Items.Components;
|
using Barotrauma.Items.Components;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -92,6 +93,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public LuaSetup()
|
public LuaSetup()
|
||||||
{
|
{
|
||||||
PrintMessage("Lua!");
|
PrintMessage("Lua!");
|
||||||
@@ -122,6 +124,7 @@ namespace Barotrauma
|
|||||||
UserData.RegisterType<LuaGame>();
|
UserData.RegisterType<LuaGame>();
|
||||||
UserData.RegisterType<LuaRandom>();
|
UserData.RegisterType<LuaRandom>();
|
||||||
UserData.RegisterType<LuaTimer>();
|
UserData.RegisterType<LuaTimer>();
|
||||||
|
UserData.RegisterType<LuaFile>();
|
||||||
UserData.RegisterType<Vector2>();
|
UserData.RegisterType<Vector2>();
|
||||||
UserData.RegisterType<Vector3>();
|
UserData.RegisterType<Vector3>();
|
||||||
UserData.RegisterType<Vector4>();
|
UserData.RegisterType<Vector4>();
|
||||||
@@ -174,6 +177,7 @@ namespace Barotrauma
|
|||||||
lua.Globals["Hook"] = hook;
|
lua.Globals["Hook"] = hook;
|
||||||
lua.Globals["Random"] = new LuaRandom();
|
lua.Globals["Random"] = new LuaRandom();
|
||||||
lua.Globals["Timer"] = new LuaTimer(this);
|
lua.Globals["Timer"] = new LuaTimer(this);
|
||||||
|
lua.Globals["File"] = UserData.CreateStatic<LuaFile>();
|
||||||
lua.Globals["WayPoint"] = UserData.CreateStatic<WayPoint>();
|
lua.Globals["WayPoint"] = UserData.CreateStatic<WayPoint>();
|
||||||
lua.Globals["SpawnType"] = UserData.CreateStatic<SpawnType>();
|
lua.Globals["SpawnType"] = UserData.CreateStatic<SpawnType>();
|
||||||
lua.Globals["ChatMessageType"] = UserData.CreateStatic<ChatMessageType>();
|
lua.Globals["ChatMessageType"] = UserData.CreateStatic<ChatMessageType>();
|
||||||
|
|||||||
Reference in New Issue
Block a user