generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

wth is a metatable?

Previous Thread :: Next Thread 
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
24 Jul 2014 08:30 PM
d
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Jul 2014 08:37 PM
A metatable is a table, literally, but it is useful because of it's metamethods.
It's very powerful and in some cases, essential to use it (OOP in some cases, sandboxing, etc.).

Anyways, you can set a metatable of a table by using the setmetatable function (and yes, you can set a metatable to a metatable, since metatables are tables).
You can get a metatable of a table by using the getmetatable function (and yes, you can get a metatable of a metatable, since metatables are tables).

Commonly used metamethods include:
__index (invoked when trying to index a nil value)
__newindex (invoked when tbl[key] = value and it's nil)
__call (invoked when tbl(...))
__add, __sub, __mul, __div (invoked when tbl +, -, *, /)
__unm (invoked when -tbl)
__lt, __le (invoked when tbl <, <=)
and more.

I'll find a link on them right now.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Jul 2014 08:37 PM
http://www.lua.org/pil/13.html
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image