how does bootstrap.register_metatable work?
Posted: Fri Oct 07, 2022 1:49 am
I'm probably being dense but how exactly do I use this function and how does it work?
This is a terrible snippet as the npc class does a lot more than this...with the help of several other files. I've really come to dislike the one event handler per event per mod. It is making my life difficult or it another case of me being dense again...LUA is *really* not my forte. :/
How do I go about using register_metatable in this case? `register_metatable('npc',npc)`? Do I need to call it with a unique name for however many NPC I have in existence? Do I call it inside the npc:new function or elsewhere?
Lua not having dedicated class keyword (even as syntax sugar like javascript does) makes this a pain sometimes.
This is a terrible snippet as the npc class does a lot more than this...with the help of several other files. I've really come to dislike the one event handler per event per mod. It is making my life difficult or it another case of me being dense again...LUA is *really* not my forte. :/
Code: Select all
function npc:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
Lua not having dedicated class keyword (even as syntax sugar like javascript does) makes this a pain sometimes.