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 » Scripters
Home Search
 

what's the point of meta stuff

Previous Thread :: Next Thread 
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
12 Sep 2017 09:00 PM
Ok so I'm starting to understand how to use metatables and metamethods, but my main question is...

WHY ARE THEY USEFUL :V

I mean they must be useful in SOME way... But how? 🤔🤔🤔

How do you guys use metamethods?

discord.gg/fissy Scripters' Academy Discord (just starting up): discord.gg/VrbkYPs yeah yeah multiply that math.random by the vector3 to get the cframe and use them htmls to bypass the mainframe of the mysql yeah
Report Abuse
kennydies is online. kennydies
Joined: 15 Nov 2008
Total Posts: 825
12 Sep 2017 09:08 PM
They pretty much just make default lua tables more powerful. An example of something you could do is whenever some code tries to reference an index in a table which is nil, you can return a non-nil value. Off the top of my head this could be used in, for example, allowing a player to do a table lookup of some sort. Imagine you have a dictionary which stores different things like {apple = 5} and you're letting a player search it, if they input something which doesn't have a value you could return 'Error: no value found' within a metamethod rather than having to handle that somewhere else in the code.

There are a lot of possibilities; it's not like metatables as a concept are only good for one thing.


Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
12 Sep 2017 09:57 PM
They're only good if you know why you need them. If you don't know why you need them, you don't need them. In Roblox more especially. Outside of Roblox, they are more useful (Or so I hear), but you have very little need for them here in our environment.


Report Abuse
Quasiduck is not online. Quasiduck
Joined: 28 Sep 2008
Total Posts: 2437
12 Sep 2017 09:59 PM
Vectors & Matrices are a top use for them personally
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
12 Sep 2017 10:01 PM
Yes. For the most part, they allow better implementation of OOP in Lua. In Roblox, OOP is not needed on your part because everything Roblox does is OOP anyways (Instances, Vectors, CFrames, Colors, blah blah blah)

They're okay if you are making a Module or Plugin that someone else is going to use, to make it simpler for them. But if you're doing this for yourself, you won't need them.


Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
12 Sep 2017 10:26 PM
It is all about ease of use, and userdata.

All of roblox's type like Vector3, CFrame, Part, etc are userdatas with metatables providing their behavior.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
13 Sep 2017 11:49 PM
"are userdatas with metatables providing their behavior."
Except not really because they're not metatables, but we know what you mean.


Report Abuse
Shining_Diamando is not online. Shining_Diamando
Joined: 11 Oct 2014
Total Posts: 460
13 Sep 2017 11:55 PM
ROBLOX does use metatables backend; these are made and implemented in the C++ using the Lua C api.

As for how they are useful?
Memoization, cacheing, proper handling of data and garbage collection (weak tables), improved OOP (which can sometimes help out when you don't want 400 functions for each individual process), and last but not least, my favorite of them all, just because.

Tables are already a powerful tool as they are but this just extends their usage to far past storage.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
13 Sep 2017 11:55 PM
No, exactly what I said.

They are userdatas with metatables providing their behavior.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
14 Sep 2017 08:56 AM
No, and I agree with you fully. But I understood what you meant, I was just trying to beat Flux to the draw.
Pretend my other post doesn't exist, and we'll try again.

inb4 cntkillme says
"They aren't real 'metatables' since it's C side, but whatever."


Report Abuse
Shining_Diamando is not online. Shining_Diamando
Joined: 11 Oct 2014
Total Posts: 460
14 Sep 2017 11:01 AM
They're real metatables, just implemented in a lower level.
They are by all means the same functionally and structurally. (As proven by a couple exploits.)
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
14 Sep 2017 11:50 AM
Huh, I can't find where I thought cntkillme said that. In fact, it looks like he has a lot of posts saying otherwise. My bad then.


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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