C
C#โ€ข12mo 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 ๐Ÿ‘ป ๐ŸŽƒ
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
toxidwormOPโ€ข12mo ago
I'm looking to use C# namespaces in lua
x0rld ๐Ÿ‘ป ๐ŸŽƒ
I don't find anything about that
canton7
canton7โ€ข12mo ago
toxidworm
toxidwormOPโ€ข12mo ago
Ohhh
canton7
canton7โ€ข12mo ago
I know nothing about NLua, but that was about 20 secs into reading the first google hit for "NLua"
toxidworm
toxidwormOPโ€ข12mo 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 ๐Ÿ‘ป ๐ŸŽƒ
try System.Diagnostics.Process.Start("notepad.exe")
toxidworm
toxidwormOPโ€ข12mo ago
Nope
x0rld ๐Ÿ‘ป ๐ŸŽƒ
(โ•ฏยฐโ–กยฐ)โ•ฏ๏ธต โ”ปโ”โ”ป
toxidworm
toxidwormOPโ€ข12mo ago
attempt to index a nil value (global 'System')
x0rld ๐Ÿ‘ป ๐ŸŽƒ
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 ๐Ÿ‘ป ๐ŸŽƒ
check this issue maybe
canton7
canton7โ€ข12mo ago
Can you create a new Process instance? Can you do anything with any NET class?
toxidworm
toxidwormOPโ€ข12mo ago
This issue has no answers to my problem I'll try right now
x0rld ๐Ÿ‘ป ๐ŸŽƒ
they say how to give lua a c# class instance
toxidworm
toxidwormOPโ€ข12mo 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 ๐Ÿ‘ป ๐ŸŽƒ
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 ๐Ÿ‘ป ๐ŸŽƒ
that
toxidworm
toxidwormOPโ€ข12mo 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