Arguments: table, method name (optional), other arguments. If you apply this, calling a table like tab() will no longer error as it reroutes your arguments to the set function. _call: This allows you to use a table as a function. Good for checking if a valid value is added. _newindex: This one gets called when you set a new value to your table. If a table is set to it, a value from that table will be returned instead. If you set a function to it, it will fire with two arguments: the original table and the index of the value you tried to get. _index: This will fire every time you try to access the table. There are multiple metamethods that can be placed into a metatable and all of them get “activated” in certain conditions. You can read the “metatable” article on the DevHub, but I’m going to make a basic run down of what each of them does. They are fairly easy to As I said above, metatables are just tables that contain values that are meant to replace a default function of tables (and userdatas, but you don’t need those in Roblox). The overhead is pretty much the only issue I see with them, though it is actually really small and only makes a difference when often accessing the They are literally just tables with functions or values that get called/returned in specific cases. It is easier to use something without actually understanding it. They are meant to stuff all the complicated code behind and abstract class.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |