C
C#10mo ago
toxidworm

NLua problem

I'm trying to embed lua in my application and I'm stuck over a problem that it cannot pick method names from .NET LUA:
import ('System.Diagnostics')

Process:Start("notepad")
import ('System.Diagnostics')

Process:Start("notepad")
C#:
static void Main()
{
Lua state = new Lua();
state.LoadCLRPackage();
string script = File.ReadAllText("script.lua");
state.DoString(script);
}
static void Main()
{
Lua state = new Lua();
state.LoadCLRPackage();
string script = File.ReadAllText("script.lua");
state.DoString(script);
}
The error
Unhandled Exception: NLua.Exceptions.LuaScriptException: [string "chunk"]:3: attempt to index a nil value (global 'Process')
at NLua.Lua.ThrowExceptionFromError(Int32 oldTop)
at NLua.Lua.DoString(String chunk, String chunkName)
at LuaEmbed.Program.Main() in D:\Dev\Sharp\LuaEmbed\LuaEmbed\Program.cs:line 15
Unhandled Exception: NLua.Exceptions.LuaScriptException: [string "chunk"]:3: attempt to index a nil value (global 'Process')
at NLua.Lua.ThrowExceptionFromError(Int32 oldTop)
at NLua.Lua.DoString(String chunk, String chunkName)
at LuaEmbed.Program.Main() in D:\Dev\Sharp\LuaEmbed\LuaEmbed\Program.cs:line 15
20 Replies
x0rld
x0rld10mo ago
Stack Overflow
How to Integrate Lua with .Net
Requirement is user should be able to add Lua script in text box, and then I need to check user has added proper Lua script and if script is correct then I need to run that script. Can anyone sugge...
toxidworm
toxidworm10mo ago
I'm looking to use C# namespaces in lua
x0rld
x0rld10mo ago
I don't find anything about that
canton7
canton710mo ago
toxidworm
toxidworm10mo ago
Ohhh
canton7
canton710mo ago
I know nothing about NLua, but that was about 20 secs into reading the first google hit for "NLua"
toxidworm
toxidworm10mo ago
I guess i'm blind lol It's still saying that the class doesn't exist
attempt to index a nil value (global 'Process')
attempt to index a nil value (global 'Process')
import ('System.Diagnostics')

Process.Start("notepad")
import ('System.Diagnostics')

Process.Start("notepad")
x0rld
x0rld10mo ago
try System.Diagnostics.Process.Start("notepad.exe")
toxidworm
toxidworm10mo ago
Nope
x0rld
x0rld10mo ago
(╯°□°)╯︵ ┻━┻
toxidworm
toxidworm10mo ago
attempt to index a nil value (global 'System')
x0rld
x0rld10mo ago
GitHub
Calling C# function from lua. · Issue #420 · NLua/NLua
I'm a total newbie when it comes to NLua but I have made a script that should work according to what I read in the read the readme. Here's my Lua code: function init() cs:Init() end functio...
x0rld
x0rld10mo ago
check this issue maybe
canton7
canton710mo ago
Can you create a new Process instance? Can you do anything with any NET class?
toxidworm
toxidworm10mo ago
This issue has no answers to my problem I'll try right now
x0rld
x0rld10mo ago
they say how to give lua a c# class instance
toxidworm
toxidworm10mo ago
they say how to give c# a lua function instead of giving the guy who wrote the issue instructions how to pass a c# class to lua
x0rld
x0rld10mo ago
GitHub
Calling C# function from lua. · Issue #420 · NLua/NLua
I'm a total newbie when it comes to NLua but I have made a script that should work according to what I read in the read the readme. Here's my Lua code: function init() cs:Init() end functio...
x0rld
x0rld10mo ago
that
toxidworm
toxidworm10mo ago
I think I figured it out But it's weird I'm able to call MessageBox.Show static method from System.Windows.Forms But I'm not able to call Process.Start from System.Diagnostics I'm able to call static classes using moonsharp @xtreit
Want results from more Discord servers?
Add your server