• 13
• 27
• 9
• 9
• 20

Lua help

This topic is 4355 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I'm trying to get LuaInterface to work with C#, and when i try to load the "luanet" module i get an error saying it cant be found. [C#] using System; using System.Collections.Generic; using System.Text; using LuaInterface; namespace GameEngine.LuaScript { public class GameScript { public Lua lua; public GameScript() { lua = new Lua(); lua.OpenBaseLib(); lua.OpenStringLib(); lua.OpenIOLib(); lua.OpenLoadLib(); lua.DoFile("startup.lua"); } } } [startup.lua] require "compat-5.1.lua" require "luanet" luanet.load_assembly("GameEngine.UI") Window = import_type("GameEngine.UI.UI_Window") win1 = Window() i have placed luanet.dll in my working directory along with the script file and compat-5.1.lua. when i go to run my app, it throws an exception saying it cannot find module "luanet". Does anyone have any experience with Lua and C# that could help me out? thanks.

Share on other sites
Hi! I'm having the exact same problem as you!

at first, I could not run any script that has -> require "compat-5.1.lua". It would always complain that it could not find that module.

compat-5.1.lua was already loaded through LUA_INIT. To run the samples provided in luainterface, I had to remove all require"compat-5.1.lua" statements.

After removing those statements, I could run all the samples through the standalone interpreter. i.e. run lua50.exe and manually typed in dofile"form.lua"

However when I tried to lua.DoFile("form.lua"); I get the problem of being unable to load "luanet" module just like you:

An unhandled exception of type 'System.Exception' occurred in LuaInterface.dll
Additional information: form.lua:1: could not load package luanet' from path c:\testproj\test\bin\Debug\?.lua'

no matter what path I set LUA_PATH and LUA_CPATH to, it always return the same error message. I'm suprised that it is ?.lua and not ?.dll too.

Any help is deeply appreciated.

Share on other sites
oh... I've solved my problem... I had to remove -> require"luanet"
now it works in C#.. and yes the luanet.load_assembly() does work.

to get scripts to run by manual execution from lua50.exe:
remove all require "compat-5.1" statements

to get scripts to run in C# by calling DoFile("myscript.lua"); :
remove all require "compat-5.1" and require "luanet" statements

hope that solved your problem too