What are lua metatables?

preview_player
Показать описание
A quick video explaining what lua metatables are and how they work.
Рекомендации по теме
Комментарии
Автор

This video was a while ago, but I have a quick correction. Index and new index only fire if the index doesn't exist in the table already. This doesn't apply to userdatas since they don't have data anyway.

TechHog
Автор

If i had a table named “names” and it looked like “local names = {"john", "bobby", "billy"}” and i did a for i, v in pairs loop through it, how would i make it so the v value gets set to a string like “sorry, you cant index me!”, I’ve tried this: local names = {“john”, “bobby, ”billy”}

setmetatable(names, {
__index = function(a, b)
return “sorry, you cant index me!”
end
})

for i, v in pairs(names) do
print(i, v)
end

SurroundSoundscapes
Автор

good video man helped alot can you make one on hookfunction? i just dont understand it for some reason

BennettEU