Community Forum

What do the ModName_mt things do?

Forum Overview >> Scripting

CategoryScripting
Created26.01.2017 23:33


Tim Derks (timmiej93) 26.01.2017 23:35
I noticed that custom Lua files always have three lines in them:

ModName = {}
ModName_mt = Class(ModName, ModType)
InitObjectClass(ModName, "ModName")

Now I know the first one is a table, but that's all I know. Can somebody explain to me what these three lines do, and what they are used for?

Bilbo Beutlin (BBeutlin) 28.01.2017 17:57
"mt" stands for "meta table".
It's just an auxiliary structure where some standard variables/pointers are pre-defined or initialized. This does the function "Class()".
With "InitObjectClass()" it is registered in the system for later access.


Note: Log in to post. Create a new account here.