How can I use MoonSharp to load a lua table?
<p>After looking through various Lua interpreters for C#, it seems that only one is truly pure c# - MoonSharp.  LuaInterpreter (defunct from 2009) which later became NLua depends on one of two other c# librariers KeraLua or another lib, and requires a customized lua52.dll (you can not use the one from lua.org, and). They have a bug report which is closed that says look at the readme for the download location of their customized lua52.dll, however it is absent. You are forced to download these libs from various sources and pray they work together in addition have a multi-file distribution which may have/cause compatibility issues with other programs due to several lua52.dll variations on the end users computer (assuming they will use more than just your program).</p>

<p>The one shining beacon of light on NLua is it's apparently popularity, however the project has not received any significant update in several years.  MoonSharp on the other hand appears to be completely self-contained, yet is lacking in documentation for common tasks such as loading a table that was built with lua and working with it.</p>

<p>I have come up with the following code based on the singular example they provided on Git, and then duplicated on their site at moonsharp.org (whichever came first, i am unsure, but having 1 example is not sufficient) :</p>

<pre><code>using System;
using System.IO;
using MoonSharp.Interpreter;

class Foo {

       function Bar( string accountName, string warcraftPath ) {
             string datastore = Path.Combine(warcraftPath, "WTF", "Account", accountName, "SavedVariables", "DataStore_Containers.lua";

             DynValue table = Script.RunString( File.ReadAllText( datastore ) );

             Console.WriteLine( table.Table.Keys.Count().ToString() );
       }
}
</code></pre>

<p>Results in the following (code in picture is slightly different as I adjusted the pasted code here for cleanliness and to make it easier for you to reproduce the problem using the table data in the pastebin link below.)</p>

<p><a href="https://i.stack.imgur.com/a9zym.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a9zym.png" alt="MoonSharp.Interpreter Table Load Lua Failure"></a></p>

<p>The table I am trying to read looks like the following (simplified had to paste on pastebin due to the size exceeding 30,000 characters):</p>

<p><a href="http://pastebin.com/z5CLya8h" rel="nofollow noreferrer">World of Warcraft - Datastore_Containers Lua table sample data</a></p>

<p>I sort of have something sort of working, it's a bit hackish, but doesn't seem to be away to loop through the values or explicitly get the subtables / values or key of the value.</p>

<pre><code>    Script s = new Script(CoreModules.Preset_Complete);

    // hacked by appending ' return DataStore_ContainersDB ' to return the table as DoString seems to only work to run a function expecting a result to be returned.
    DynValue dv = s.DoString(luaTable + "\nreturn DataStore_ContainersDB;");
    Table t = dv.Table;
    foreach(var v in t.Keys)
    {
        Console.WriteLine( v.ToPrintString() );
    }
</code></pre>

<p>The problem is that there doesn't seem to be any way for me to enter the sub-table result sets or to explicitly access those like <code>t["global"]</code> or <code>t.global</code>. </p>