Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,093 changes: 4,093 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/package-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
REPOSITORY_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
PROJECT_NAME: Lua
PROJECT_NAME: FluffyVoid.Lua
jobs:
build:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Lua.sln → FluffyVoid.Lua.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lua", "Lua\Lua.csproj", "{657AC6CF-712A-46FC-81C5-0257BB021F3B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluffyVoid.Lua", "FluffyVoid.Lua\FluffyVoid.Lua.csproj", "{657AC6CF-712A-46FC-81C5-0257BB021F3B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
449 changes: 449 additions & 0 deletions FluffyVoid.Lua.sln.DotSettings

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions FluffyVoid.Lua/Debug.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using FluffyVoid.Logging;
using MoonSharp.Interpreter;

namespace FluffyVoid.Lua
{
/// <summary>
/// Debug class that is exposed to the lua scripts by default, allowing debug
/// tools for lua script debugging
/// </summary>
[MoonSharpUserData, Serializable,]
public class Debug
{
/// <summary>
/// Color code for Dark Magenta
/// </summary>
private const string DarkMagenta = "8b008b";
/// <summary>
/// The name of the lua script
/// </summary>
[MoonSharpHidden]
public string Name { get; protected set; }

/// <summary>
/// Category string for use with the LogManager
/// </summary>
[MoonSharpHidden]
protected string LuaScriptCategory => $"{Name}.lua";

/// <summary>
/// Constructor used to initialize the Debug object
/// </summary>
/// <param name="name">
/// The name of the lua script that is initializing the debug
/// object
/// </param>
[MoonSharpHidden]
internal Debug(string name)
{
Name = name;
}

/// <summary>
/// Logs a lua message to the LogManager
/// </summary>
/// <param name="logMessage">The message to log out</param>
public void Log(string logMessage)
{
LogManager.Log(logMessage, LuaScriptCategory, DarkMagenta);
}
/// <summary>
/// Logs an error message to the LogManager
/// </summary>
/// <param name="logMessage">The message to log out</param>
public void LogError(string logMessage)
{
LogManager.LogError(logMessage, LuaScriptCategory);
}
/// <summary>
/// Logs a warning message to the LogManager
/// </summary>
/// <param name="logMessage">The message to log out</param>
public void LogWarning(string logMessage)
{
LogManager.LogWarning(logMessage, LuaScriptCategory);
}
}
}
12 changes: 6 additions & 6 deletions Lua/Lua.csproj → FluffyVoid.Lua/FluffyVoid.Lua.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<Description>C# lua manager that utilizes Moonsharp to process and manage lua scripts.</Description>
<Company>FluffyVoid</Company>
<Product>FluffyVoid.Lua</Product>
<AssemblyVersion>1.0.2</AssemblyVersion>
<FileVersion>1.0.2</FileVersion>
<Version>1.0.2</Version>
<AssemblyVersion>1.0.3</AssemblyVersion>
<FileVersion>1.0.3</FileVersion>
<Version>1.0.3</Version>
<RepositoryUrl>https://github.com/ashiryn/Lua</RepositoryUrl>
</PropertyGroup>

Expand All @@ -28,10 +28,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="fluffyvoid.fileutilities" Version="1.0.3" />
<PackageReference Include="FluffyVoid.Logging" Version="1.0.2" />
<PackageReference Include="FluffyVoid.FileUtilities" Version="1.0.5" />
<PackageReference Include="FluffyVoid.Logging" Version="1.0.3" />
<PackageReference Include="MoonSharp" Version="2.0.0"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.4"/>
</ItemGroup>
<ItemGroup>
<None Include="bin/$(Configuration)/FluffyVoid.Lua.xml" Pack="true">
Expand Down
66 changes: 66 additions & 0 deletions FluffyVoid.Lua/LuaApplication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using FluffyVoid.FileUtilities;
using MoonSharp.Interpreter;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace FluffyVoid.Lua
{
/// <summary>
/// Exposed Actions that Lua scripts can use to directly interact with Lua or
/// the Lua Manager
/// </summary>
[MoonSharpUserData]
public class LuaApplication
{
/// <summary>
/// Function used to register an event from a Lua script with the C# Lua Script
/// class
/// </summary>
public Action<string, DynValue>? RegisterEvent;

/// <summary>
/// Appends text to a text file
/// </summary>
/// <param name="fileName">The file to append text to</param>
/// <param name="text">The text to append to the file</param>
public void AppendToTextFile(string fileName, string text)
{
DataLoader.SaveTextFile(fileName, text, append: true);
}
/// <summary>
/// Loads the text from a text file
/// </summary>
/// <param name="fileName">The file to read text from</param>
/// <returns>The string of text that was loaded from the file</returns>
public string? LoadTextFile(string fileName)
{
if (DataLoader.LoadTextFile(fileName, out string result))
{
return !string.IsNullOrEmpty(result)
? result
: null;
}

return null;
}
/// <summary>
/// Write the data to a json file
/// </summary>
/// <param name="fileName">The file to write text to</param>
/// <param name="contents">The data to write to the file</param>
public void WriteToJsonFile(string fileName, string contents)
{
contents = JToken.Parse(contents).ToString(Formatting.Indented);
DataLoader.SaveTextFile(fileName, contents);
}
/// <summary>
/// Writes the text to a text file
/// </summary>
/// <param name="fileName">The file to write text to</param>
/// <param name="text">The text to write to the file</param>
public void WriteToTextFile(string fileName, string text)
{
DataLoader.SaveTextFile(fileName, text);
}
}
}
Loading
Loading