Implemented permissions for lua and some commands to work with it.
TSHOCKPLUGINS-4 is completed.
This commit is contained in:
parent
15d9a2aa8c
commit
d28fef8e1e
3 changed files with 83 additions and 20 deletions
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using LuaInterface;
|
||||
|
||||
namespace TShockAPI.LuaSystem
|
||||
|
|
@ -36,14 +37,7 @@ namespace TShockAPI.LuaSystem
|
|||
foreach (string s in Directory.GetFiles(LuaAutorunPath))
|
||||
{
|
||||
SendLuaDebugMsg("Loading: " + s);
|
||||
try
|
||||
{
|
||||
Lua.DoFile(s);
|
||||
}
|
||||
catch (LuaException e)
|
||||
{
|
||||
SendLuaDebugMsg(e.Message);
|
||||
}
|
||||
RunLuaFile(s);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
@ -53,6 +47,30 @@ namespace TShockAPI.LuaSystem
|
|||
}
|
||||
}
|
||||
|
||||
public void RunLuaString(string s)
|
||||
{
|
||||
try
|
||||
{
|
||||
Lua.DoString(s);
|
||||
}
|
||||
catch (LuaException e)
|
||||
{
|
||||
SendLuaDebugMsg(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void RunLuaFile(string s)
|
||||
{
|
||||
try
|
||||
{
|
||||
Lua.DoFile(s);
|
||||
}
|
||||
catch (LuaException e)
|
||||
{
|
||||
SendLuaDebugMsg(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendLuaDebugMsg(string s)
|
||||
{
|
||||
ConsoleColor previousColor = Console.ForegroundColor;
|
||||
|
|
@ -66,6 +84,11 @@ namespace TShockAPI.LuaSystem
|
|||
LuaFunctions LuaFuncs = new LuaFunctions();
|
||||
Lua.RegisterFunction("Print", LuaFuncs, LuaFuncs.GetType().GetMethod("Print"));
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
SendLuaDebugMsg("Lua 5.1 shutting down. Terminating all Lua threads.");
|
||||
}
|
||||
}
|
||||
|
||||
public class LuaFunctions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue