neolithos / neolua

A Lua implementation for the Dynamic Language Runtime (DLR).
https://neolua.codeplex.com/
Apache License 2.0
471 stars 76 forks source link

Possible to use require() without loading from the filesystem? #99

Closed Drachenkaetzchen closed 5 years ago

Drachenkaetzchen commented 5 years ago

Hi,

I'm working on a project where I'd like to keep a required module in a Resource (resx). With MoonSharp, I can simply create a custom script loader.

Is something similar possible with neolua?

neolithos commented 5 years ago

Hi, it is possible, you need to inherit from LuaGlobal and implement your own require logic.

public class MyLuaGlobal : LuaGlobal
{
...
    [LuaMember("require")]
    public LuaResult LuaRequire(object modname)
    {
...
    }
...
}
Drachenkaetzchen commented 5 years ago

Thank you :) I'll try it out soon.