Metamethods
List of available metamethods:
__getindex
- When called: on sub-index/property retrieval
- Arguments: key
- Return value: any
- special value: mm_getindex_router - routes __getindex to __get_***
__setindex
- When called: on setting sub-indices/properties
- Arguments: key, value
- Return value: none
- special value: mm_setindex_router - routes __setindex to __set_***
__typeof
- When called: on type string retrieval (typeof / sgs_TypeOf)
- Arguments: none
- Return value: type string
__clone
- When called: on cloning operation (clone / sgs_Clone)
- Arguments: none
- Return value: the item to return as the cloned object
__tobool
- When called: on bool value retrieval
- Arguments: none
- Return value: bool
__tostring
- When called: on string value retrieval
- Arguments: none
- Return value: string
__negate
- When called: on negation (
-obj
) - Arguments: none
- Return value: the negated object
__add
- When called: on addition (
var1 + var2
) when one of the variables has this interface defined - Arguments: operands A and B (types are not restricted)
- Return value: the product of addition
__sub
- When called: on subtraction (
var1 - var2
) when one of the variables has this interface defined - Arguments: operands A and B (types are not restricted)
- Return value: the product of subtraction
__mul
- When called: on multiplication (
var1 * var2
) when one of the variables has this interface defined - Arguments: operands A and B (types are not restricted)
- Return value: the product of multiplication
__div
- When called: on division (
var1 / var2
) when one of the variables has this interface defined - Arguments: operands A and B (types are not restricted)
- Return value: the product of division
__mod
- When called: on modulo (
var1 % var2
) when one of the variables has this interface defined - Arguments: operands A and B (types are not restricted)
- Return value: the product of modulo
__compare
- When called: on comparison (
var1 + var2
) when one of the variables has this interface defined - Arguments: operands A and B (types are not restricted)
- Return value: the result of comparison (real value indicating < 0 if A<B, > 0 if A>B, = 0 if A=B)
__call
- When called: on function call
- Arguments: arguments from the original call
- Return value: any