Can you please answer if possible as I have no Idea.
Also can you please help me understand this example?
local t = {hi = 2,lol = 2}
local meta = {hi=10}
setmetatable(t,meta)
print(getmetatable(t).hi)
Can you please answer if possible as I have no Idea.
Also can you please help me understand this example?
local t = {hi = 2,lol = 2}
local meta = {hi=10}
setmetatable(t,meta)
print(getmetatable(t).hi)
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
I can't really explain it since it's a bit broad but I can give you a video: https://www.youtube.com/watch?v=3On86eQRccc Also popular games sometimes use metatables if they want to shorten code. Take an AI zombie for an example, a zombie shooter game might want to make different themed zombies, they can still use the zombie "source code" but alter a few things like it's health, damage, speed,
intelligence. They are reusing something and altering a few things. Most of the time they don't need metatables anyway. Take an automobile for example, a car and motorcycle share the same traits (gasoline, gas pedal etc) but an automobile creates those. A motorcycle may have two wheels and no radio while a car has four wheels and a radio.
Downvoted and started moderations as you are too broad. I recommend going to https://scriptinghelpers.org/blog/posting-good-questions-and-answers-on-scripting-helpers
Popular games are usually closed source
@raid6n this question isn't even close to being too broad lol