ดึง metatable ของค่าโดยไม่คำนึงถึงฟิลด์ __metatable ของ Value นั้นๆ
<table> getrawmetatable(<table> value)
ตัวอย่าง #1
-- ทำซ้ำโค้ดที่อยู่ภายในบล็อก while ในระหว่างรอ 1 วินาทีทุกครั้ง
while wait(1) do
-- แสดงค่าของตัวแปร workspace.Camera ในคอนโซล (Console)
print(workspace.Camera)
end
ตัวอย่าง #2
-- นำค่า metatable ของตัวแปร game มาเก็บในตัวแปร game_meta
local game_meta = getrawmetatable(game)
-- นำค่า __index ของ metatable มาเก็บในตัวแปร game_index
local game_index = game_meta.__index
-- ทำให้ metatable ของตัวแปร game เปลี่ยนแปลงค่าได้ (mutable) โดยใช้ setreadonly() โดยกำหนดให้เป็น false
setreadonly(game_meta, false) -- Required to avoid errors
-- กำหนดให้ตัวแปร game_meta เปลี่ยนแปลงค่าของ __index ใหม่โดยใช้ฟังก์ชัน (function) ที่กำหนดเอง
game_meta.__index = function(Instance, string)
-- เมื่อมีการเรียกใช้ __index ของตัวแปร game_meta ด้วยตัวอักษร string
-- ถ้า string คือ "Camera" ให้คืนค่าการเรียกใช้ __index ของ game โดยใช้ชื่อ Instance ของตัวแปร "Workspace"
if string == "Camera" then
return game_index(game, "Workspace")
end
-- หากไม่ใช่กรณีข้างต้น ให้คืนค่าการเรียกใช้ __index ของตัวแปร Instance ด้วยตัวอักษร string
return game_index(Instance, string)
end