I'm trying to learn lua and how lua can be used with C#. So I've created a lua script in which I declared a string variable called "x":
local x = "String variable"
Then I've tried to load the string from the c# program like this:
LuaFunction vsa = lua.LoadString("x", "root.lua");
When I try to compile I receive this error:
[string "root.lua"]:1: '=' expected near '<eof>'
The function you are trying to make is basically this:
This function isn't valid; You're reading
xbut not doing anything with it, and since Lua expressions can't exist as statements, you get a parse error.What you meant is probably
lua.LoadString("return x", "root.lua"). However, this still won't work, becausexis local to the file which you defined it in; outside functions can't access it. Eitherxneeds to be global or (more preferably) you define a getter function inside the file that you definexin.