Yuari
Documentation
Docs/Metatables/getmetafield

getmetafield

Returns a field from an object's raw metatable.

Syntax

getmetafield(object: any, key: string) -> any

Parameters

ParameterTypeDescription
objectanyThe object value used by the call.
keystringThe key or secret used by the operation.

Returns

TypeDescription
anyA field from an object's raw metatable

Description

getmetafield is part of the Metatables library. Metatable helpers operate below normal Lua protection: they read raw metatables, replace metamethods and inspect namecalls.

The call is read-only: it resolves the current value when invoked and does not change the underlying state.

Example

local object = setmetatable({}, { __index = function() return 1 end })
print(getmetafield(object, "__index") ~= nil)

Notes

  • Metatable changes are applied directly to the live object.