Basic Lua loading prep.
TSHOCKPLUGINS-4
This commit is contained in:
parent
7e6aa3d288
commit
c45291eb6b
5 changed files with 49 additions and 5 deletions
38
TShockAPI/LuaSystem/LuaLoader.cs
Normal file
38
TShockAPI/LuaSystem/LuaLoader.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using LuaInterface;
|
||||
|
||||
namespace TShockAPI.LuaSystem
|
||||
{
|
||||
public class LuaLoader
|
||||
{
|
||||
private Lua Lua = null;
|
||||
public string LuaPath = "";
|
||||
public LuaLoader(string path)
|
||||
{
|
||||
Lua = new Lua();
|
||||
LuaPath = path;
|
||||
SendLuaDebugMsg("Lua 5.1 (serverside) initialized.");
|
||||
}
|
||||
|
||||
public void LoadServerAutoruns()
|
||||
{
|
||||
foreach (string s in Directory.GetFiles(Path.Combine(LuaPath, "autorun")))
|
||||
{
|
||||
Lua.DoFile(s);
|
||||
SendLuaDebugMsg("Loaded file: " + s);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendLuaDebugMsg(string s)
|
||||
{
|
||||
ConsoleColor previousColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine("Lua: " + s);
|
||||
Console.ForegroundColor = previousColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -48,5 +48,5 @@ using System.Runtime.InteropServices;
|
|||
// Build Number
|
||||
// MMdd of the build
|
||||
|
||||
[assembly: AssemblyVersion("3.4.2.0102")]
|
||||
[assembly: AssemblyFileVersion("3.4.2.0102")]
|
||||
[assembly: AssemblyVersion("3.4.2.0103")]
|
||||
[assembly: AssemblyFileVersion("3.4.2.0103")]
|
||||
|
|
@ -86,7 +86,7 @@ namespace TShockAPI
|
|||
Environment.OSVersion + "&mono=" + Main.runningMono + "&port=" + Netplay.serverPort +
|
||||
"&plcount=" + TShock.Utils.ActivePlayers());
|
||||
}
|
||||
Log.ConsoleInfo("Stat Tracker: " + response + "\n");
|
||||
Log.ConsoleInfo("Stat Tracker: " + response);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ using MaxMind;
|
|||
using Mono.Data.Sqlite;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Rests;
|
||||
using TShockAPI.LuaSystem;
|
||||
using Terraria;
|
||||
using TShockAPI.DB;
|
||||
using TShockAPI.Net;
|
||||
|
|
@ -64,6 +65,7 @@ namespace TShockAPI
|
|||
public static RestManager RestManager;
|
||||
public static Utils Utils = new Utils();
|
||||
public static StatTracker StatTracker = new StatTracker();
|
||||
public static LuaLoader LuaLoader;
|
||||
|
||||
/// <summary>
|
||||
/// Called after TShock is initialized. Useful for plugins that needs hooks before tshock but also depend on tshock being loaded.
|
||||
|
|
@ -418,8 +420,8 @@ namespace TShockAPI
|
|||
RestApi.Start();
|
||||
|
||||
StatTracker.CheckIn();
|
||||
|
||||
FixChestStacks();
|
||||
LuaLoader = new LuaLoader(Path.Combine(".", "lua"));
|
||||
}
|
||||
|
||||
private void FixChestStacks()
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@
|
|||
<Reference Include="HttpServer">
|
||||
<HintPath>..\HttpBins\HttpServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="LuaInterface">
|
||||
<HintPath>..\LuaBins\LuaInterface.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Data.Sqlite">
|
||||
<HintPath>..\SqlBins\Mono.Data.Sqlite.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -107,6 +110,7 @@
|
|||
<Compile Include="Group.cs" />
|
||||
<Compile Include="Extensions\LinqExt.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="LuaSystem\LuaLoader.cs" />
|
||||
<Compile Include="Net\BaseMsg.cs" />
|
||||
<Compile Include="Net\DisconnectMsg.cs" />
|
||||
<Compile Include="Net\NetTile.cs" />
|
||||
|
|
@ -187,7 +191,7 @@
|
|||
</PropertyGroup>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
|
||||
<UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildAction="Both" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_StartDate="2011/6/17" BuildVersion_IncrementBeforeBuild="False" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue