#what are metatables?

1 messages · Page 1 of 1 (latest)

upbeat dock
#

can't understand metatables

spare hillBOT
#

studio** You are now Level 5! **studio

woeful rose
#

Tables but with meta as a prefix

dreamy thicket
dreamy thicket
hearty forum
glacial tide
#

hope this helps 🙏

mellow umbra
#

ggs

upbeat dock
mellow umbra
#

pre-fired it

hearty forum
glacial tide
#

hope this hgelps…..

mellow umbra
#

💔

#

pretty sure this all goes into the methods of a module

#

. and : i think so

#

i forgot

#

its 5 am

#

😂 ✌️

mellow umbra
upbeat dock
#

oh guys i have a commision for admin commands so how do you get access to the chat like if you said !kick in chat it'd kick the player

mellow umbra
#

this is how you would usually see it meaning that if you use self these would show up as an option

upbeat dock
mellow umbra
#

or something

#

idk

mellow umbra
#

lol

upbeat dock
upbeat dock
upbeat dock
mellow umbra
upbeat dock
mellow umbra
#

im sleepy as fuck

#

dont mind me

gloomy garden
#

metatable is a table on a table

upbeat dock
mellow umbra
gloomy garden
#

basically when you perform certain actions on a table it checks for a metatable on the table and for the metamethod

mellow umbra
#

you just have to understand it

#

and actually know when to use it

#

from my experience

gloomy garden
#

so if you try to use division symbol on a table itd check for the __div metamethod

upbeat dock
mellow umbra
mellow umbra
bright pebble
#

Or how to know them

upbeat dock
bright pebble
bright pebble
#

The knight and healer are both characters

upbeat dock
bright pebble
#

So you create a class named character , and you apply common traits like health, speed , etc..

bright pebble
#

After that you specify things depending on your needs, for example you want your knight to have more health then the healer, so you create another class (sub-class) named knight, then you inherit the characteristics of the character class (like health) and you override it with what you want

bright pebble
upbeat dock
bright pebble
#

It can differ depending on programming languages, but the core concept stays the same

proven forge
#

HI guys, anyone here familiar with text filtering ?

glacial tide
bright pebble
bright pebble
gloomy garden
glacial tide
bright pebble
#

I explained the concept used in programming languages

spare hillBOT
#

studio** You are now Level 3! **studio

bright pebble
#

Well that’s how I learned them

glacial tide
bright pebble
#

That’s why I gave a specific example that probably don’t align with its real functionality

glacial tide
#

what

bright pebble
bright pebble
glacial tide
#

the example you gave doesn’t have anything to do with metatables

bright pebble
#

I could’ve gone into details, but he wanted a simple example for its use

glacial tide
bright pebble
glacial tide
bright pebble
glacial tide
#

ohhhhh its ragebait

#

you got me for a bit...

bright pebble
#

You can make classes with metatables

glacial tide
#

you can indeed, which is not what you did

bright pebble
#

In the example I said that

glacial tide
#

what you said previously, that "metatables are classes" is simply not true.

#

you should probably look over OOP fundementals and what exactly a class means again

bright pebble
glacial tide
#

you can create classes without metatables.

#

the reason we use metatables in luau is to avoid allocating storage to duplicate methods

#

which do not exist in the example you provided, since it's a basic table of class stats

bright pebble
#

I mainly use metatables for that feature

glacial tide
#

I feel as though you're just ignoring everything I'm saying, so im just gonna go overdose on cocaine

bright pebble
#

Thats a use for metatables too

bright pebble
glacial tide
#

your example contains no methods, and thus, has no need for a metatable - a table of metamethods

bright pebble
#

Like I said I didn’t go over the details I just gave a general use for metatables

#

Such has using them to implement OOP

glacial tide
#

so you gave an example of metatables... while using no methods

#

I see.

bright pebble
glacial tide
#

what

bright pebble
glacial tide
#

you explained neither, as I've said many times before

#

your example contained no methods, and thus, had no need for a metatable

bright pebble
spare hillBOT
#

studio** You are now Level 4! **studio

bright pebble
#

But indirectly

glacial tide
glacial tide
#

this has nothing to do with OOP or metatables

#

this is just basic data

bright pebble
glacial tide
#

no

#

OOP is a paradigm

bright pebble
glacial tide
#

simply using objects, or features of objects, does not automatically make your code "OOP"

bright pebble
#

So I guess my teacher is wrong

#

Let me go tell him that

glacial tide
#

more likely you weren't paying attention in class

bright pebble
#

Attributes are a fundamental concept in OOP

glacial tide
#

correct

gloomy garden
bright pebble
gloomy garden
gloomy garden
#

This guy is just not a master debater

bright pebble
gloomy garden
spare hillBOT
#

studio** You are now Level 5! **studio

bright pebble
gloomy garden
wintry daggerBOT
#
Critical error:

You must attach a code-block containing code to your message or reply to a message that has one.

bright pebble
#

That should work

bright pebble
wintry daggerBOT
#
Critical error:

You must attach a code-block containing code to your message or reply to a message that has one.

gloomy garden
#

@bright pebble ok I'm gonna ask you two questions ok

#

Your two responses are "yes" and "no", you can only use each response a single time

#

Does that sound good

#

@bright pebble

bright pebble
#

Go ahead

gloomy garden
bright pebble
#

Hmm

gloomy garden
bright pebble
gloomy garden
bright pebble
gloomy garden
#

Your only option is "yes"

bright pebble
gloomy garden
#

Remember

glacial tide
#

that's true

bright pebble