C# method override in Lua
See original GitHub issueNeoLua Version: 5.3 (Nuget 1.3.10)
Hi, I’m just starting to use NeoLua, which is pretty good, and I fall into an issue… I want to know if it’s possible to override a virtual method defined in C# from Lua.
I’ve tried to do like this
Component = clr.AlienEngine.Core.Gaming.LuaComponent;
cmp = Component();
cmp.Update = function()
print "Updated";
end;
where LuaComponent
is just a proxy of the abstract Component
class for the use in lua code.
When I want to execute this code, I got the error 'LuaComponent:Update' is not writable
.
I’ve also tried to do:
Component = clr.AlienEngine.Core.Gaming.LuaComponent;
cmp = Component();
function cmp:Update()
print "Updated";
end;
and I got the error No conversion defined from LuaComponent to LuaTable.
So please I want to know if it’s possible or if there is another way to achieve this goal. Thanks
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Overriding c++ method in lua and call it back in c++
AFAIK, when you call methods (or functions) in C++, you are referring to an address where the instruction is located. And there is...
Read more >override function metatable with lua code · Issue #583
Hi, I was wondering if it is possible to override a usertype function metatable at runtime using Lua code? I'm trying to bind...
Read more >(Solved) class.lua doesn't override and call parent methods ...
can someone tell me why my class.lua instead of overriding and inheriting it's parents methods though self.base.<methodname> it seems to use ...
Read more >Thread: Override lua Function
Is there a way to override a function in lua similar to how you can apply a merge property of join to an...
Read more >Override a local function/variable from another function
How can I override a local function/variable that's in a different function/environment? e.g. (yes, its Lua 5.1): function override(orig, replacement)
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That looks good. Just for the list _overrides had choose a more generic way.
Good work. I leave this issue open for other users. May be some times, I or someone other will create a wiki page for this example.
Hi @neolithos, sorry for the late response. Few days ago, I’ve implemented a solution following your advice, it’s totally more clean now and everything is managed from C#, thanks again. The new implementation is:
The new ScriptBridge class:
And the new way to use this: