Difference between revisions of "Setmetatable"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Sets the ''metatable'' for the given table.
 
Sets the ''metatable'' for the given table.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(table) = setmetatable(table,metatable)
 
(table) = setmetatable(table,metatable)
 
</source>
 
</source>

Revision as of 15:30, 13 July 2023

Available since: Gideros 2011.6
Class: (global)

Description

Sets the metatable for the given table. <syntaxhighlight lang="lua"> (table) = setmetatable(table,metatable) </source>

You cannot change the metatable of other types from Lua, only from C.

If metatable is nil, removes the metatable of the given table.

If the original metatable has a "__metatable" field, raises an error.

This function returns a table.

Parameters

table: (table) table to set metatable to
metatable: (varies) value to use as metatable

Return values

Returns (table) provided table