Basic Lua loading prep.

TSHOCKPLUGINS-4
This commit is contained in:
Lucas Nicodemus 2012-01-03 16:54:38 -07:00
parent 7e6aa3d288
commit c45291eb6b
5 changed files with 49 additions and 5 deletions

View 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;
}
}
}

View file

@ -48,5 +48,5 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// MMdd of the build // MMdd of the build
[assembly: AssemblyVersion("3.4.2.0102")] [assembly: AssemblyVersion("3.4.2.0103")]
[assembly: AssemblyFileVersion("3.4.2.0102")] [assembly: AssemblyFileVersion("3.4.2.0103")]

View file

@ -86,7 +86,7 @@ namespace TShockAPI
Environment.OSVersion + "&mono=" + Main.runningMono + "&port=" + Netplay.serverPort + Environment.OSVersion + "&mono=" + Main.runningMono + "&port=" + Netplay.serverPort +
"&plcount=" + TShock.Utils.ActivePlayers()); "&plcount=" + TShock.Utils.ActivePlayers());
} }
Log.ConsoleInfo("Stat Tracker: " + response + "\n"); Log.ConsoleInfo("Stat Tracker: " + response);
} }
catch (Exception e) catch (Exception e)
{ {

View file

@ -31,6 +31,7 @@ using MaxMind;
using Mono.Data.Sqlite; using Mono.Data.Sqlite;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using Rests; using Rests;
using TShockAPI.LuaSystem;
using Terraria; using Terraria;
using TShockAPI.DB; using TShockAPI.DB;
using TShockAPI.Net; using TShockAPI.Net;
@ -64,6 +65,7 @@ namespace TShockAPI
public static RestManager RestManager; public static RestManager RestManager;
public static Utils Utils = new Utils(); public static Utils Utils = new Utils();
public static StatTracker StatTracker = new StatTracker(); public static StatTracker StatTracker = new StatTracker();
public static LuaLoader LuaLoader;
/// <summary> /// <summary>
/// Called after TShock is initialized. Useful for plugins that needs hooks before tshock but also depend on tshock being loaded. /// 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(); RestApi.Start();
StatTracker.CheckIn(); StatTracker.CheckIn();
FixChestStacks(); FixChestStacks();
LuaLoader = new LuaLoader(Path.Combine(".", "lua"));
} }
private void FixChestStacks() private void FixChestStacks()

View file

@ -53,6 +53,9 @@
<Reference Include="HttpServer"> <Reference Include="HttpServer">
<HintPath>..\HttpBins\HttpServer.dll</HintPath> <HintPath>..\HttpBins\HttpServer.dll</HintPath>
</Reference> </Reference>
<Reference Include="LuaInterface">
<HintPath>..\LuaBins\LuaInterface.dll</HintPath>
</Reference>
<Reference Include="Mono.Data.Sqlite"> <Reference Include="Mono.Data.Sqlite">
<HintPath>..\SqlBins\Mono.Data.Sqlite.dll</HintPath> <HintPath>..\SqlBins\Mono.Data.Sqlite.dll</HintPath>
</Reference> </Reference>
@ -107,6 +110,7 @@
<Compile Include="Group.cs" /> <Compile Include="Group.cs" />
<Compile Include="Extensions\LinqExt.cs" /> <Compile Include="Extensions\LinqExt.cs" />
<Compile Include="Log.cs" /> <Compile Include="Log.cs" />
<Compile Include="LuaSystem\LuaLoader.cs" />
<Compile Include="Net\BaseMsg.cs" /> <Compile Include="Net\BaseMsg.cs" />
<Compile Include="Net\DisconnectMsg.cs" /> <Compile Include="Net\DisconnectMsg.cs" />
<Compile Include="Net\NetTile.cs" /> <Compile Include="Net\NetTile.cs" />
@ -187,7 +191,7 @@
</PropertyGroup> </PropertyGroup>
<ProjectExtensions> <ProjectExtensions>
<VisualStudio> <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> </VisualStudio>
</ProjectExtensions> </ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.