You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a project and we have a lot of .lua scripts already done, hundred scripts. Loading them takes a few seconds (2-4 seconds) which is actually a little bit overkill. Of course I could just load the scripts only once and it would work, except for only one thing, only the scripts that call static C# functions would work.
This works until I need to call the functions that need an actor to work. They do not need an actor in the LUA context, but I need LUA to execute the methods from the actor.
I know that if I do lua.RegisterFunction("ActorFunction", actor, typeof(Actor).GetMethod("MethodName")) this will register the actor within the method, but my actor is dynamic and I cannot be loading the Lua files every for every actor (not only because of the time and the delay caused in the application, but ONE instance of Lua with all scripts loaded takes up to 800MB in memory).
The .lua files has a lot of scripts ready to be run by the application, calling LuaMgr.Run won't add new scripts, it will just execute the currently loaded ones (Example: LuaMgr.Run("UpdateWindow(1,2,3)", actor)).
Is there any way to clone the main Lua instance and register the functions within the actor only to the current context? There's anyway I can do it without editing every single file to pass the actor back to C#?
The LuaRunner is planned to be registered with the function. Basically most function calls will be to static functions, but few ones will ask for information about the actor who is executing the action.
I thought about making it register the methods every time I create a new LuaRunner instance, but the NewThread which I was thinking that would fit my needs returns an instance of KeraLua.Lua, which I couldn't find anything about how to register a C# function to it.
I'm stuck with this, been researching with NLua, KeraLua, MoonSharp and others but couldn't find anything like this. The closest issue that I found about this subject was about AI (check here), and it's almost my problem.
Except that it's not for AI, but for game events (like killing a monster, clicking a NPC or an item etc).
There's any way to achieve what I'm trying to? Can I get any direction?
The text was updated successfully, but these errors were encountered:
I'm sorry if I misunderstand something, but why can't you just create a single Lua environment with all the scripts, and pass the "actor" to the Lua methods you're calling, so that they know what actor to work on? Isn't it just the same as passing a variable?
Or build and maintain a table with your actors within the Lua environemnt so that it has some kind of access to them?
I'm working on a project and we have a lot of .lua scripts already done, hundred scripts. Loading them takes a few seconds (2-4 seconds) which is actually a little bit overkill. Of course I could just load the scripts only once and it would work, except for only one thing, only the scripts that call static C# functions would work.
This works until I need to call the functions that need an actor to work. They do not need an actor in the LUA context, but I need LUA to execute the methods from the actor.
I know that if I do
lua.RegisterFunction("ActorFunction", actor, typeof(Actor).GetMethod("MethodName"))
this will register the actor within the method, but my actor is dynamic and I cannot be loading the Lua files every for every actor (not only because of the time and the delay caused in the application, but ONE instance of Lua with all scripts loaded takes up to 800MB in memory).The .lua files has a lot of scripts ready to be run by the application, calling
LuaMgr.Run
won't add new scripts, it will just execute the currently loaded ones (Example:LuaMgr.Run("UpdateWindow(1,2,3)", actor)
).Is there any way to clone the main Lua instance and register the functions within the actor only to the current context? There's anyway I can do it without editing every single file to pass the actor back to C#?
The LuaRunner class
The
LuaRunner
is planned to be registered with the function. Basically most function calls will be to static functions, but few ones will ask for information about the actor who is executing the action.I thought about making it register the methods every time I create a new
LuaRunner
instance, but theNewThread
which I was thinking that would fit my needs returns an instance of KeraLua.Lua, which I couldn't find anything about how to register a C# function to it.It would be something like this
I'm stuck with this, been researching with NLua, KeraLua, MoonSharp and others but couldn't find anything like this. The closest issue that I found about this subject was about AI (check here), and it's almost my problem.
Except that it's not for AI, but for game events (like killing a monster, clicking a NPC or an item etc).
There's any way to achieve what I'm trying to? Can I get any direction?
The text was updated successfully, but these errors were encountered: