LuaScriptException: [string "chunk"]:3: attempt to index a global 'Test' (a nil value)
ZachHofmeister opened this issue · 0 comments
ZachHofmeister commented
I'm having a problem accessing a function from a C# script through lua. This is the error given when the Lua script is run. Here is the function that runs the lua script:
`void RunPlayerScript () {
if (fileManager.activeFile != "") {
source = File.ReadAllText (Application.persistentDataPath + "/" + fileManager.activeFile + ".lua");
env = new Lua ();
env.LoadCLRPackage ();
try {
env.DoString (source);
} catch (NLua.Exceptions.LuaException e) {
Debug.LogError (FormatException (e), gameObject);
}
//Call ("");
}
}`
Here is the Lua script being run:
import 'Piloting.Navigation'
Navigation.Test()
And here is the script containing the function being run from the Lua:
using UnityEngine;
namespace Piloting.Navigation {
public static class Navigation {
public static void Test () {
Debug.Log ("Hello World!");
}
}
}
Anyone have any idea what is going wrong? Thanks!