Ref: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server client function}} This function will create a reference to the given argument. ==Syntax== <syntaxhighlight lang="lua"> int ref( mixed objectToReference...")
 
No edit summary
 
Line 13: Line 13:
===Returns===
===Returns===
Returns an ''int'' if the reference were successfully created. Returns ''false'' if the parameter were invalid.
Returns an ''int'' if the reference were successfully created. Returns ''false'' if the parameter were invalid.
==Remarks==
This function was originally created to prevent garbage-collection of specific Lua objects/elements which should persist even though no script would reference them. The storage of those references can be obtained by a call to the debug.getregistry function. Since at the moment MTA does not make use of advanced garbage-collector semantics, this function serves little purpose other than leak memory!


==See Also==
==See Also==
{{Utility functions}}
{{Utility functions}}

Latest revision as of 16:57, 20 October 2021

This function will create a reference to the given argument.

Syntax

int ref( mixed objectToReference )    

Required Arguments

  • objectToReference : The Lua element, which you want to reference

Returns

Returns an int if the reference were successfully created. Returns false if the parameter were invalid.

Remarks

This function was originally created to prevent garbage-collection of specific Lua objects/elements which should persist even though no script would reference them. The storage of those references can be obtained by a call to the debug.getregistry function. Since at the moment MTA does not make use of advanced garbage-collector semantics, this function serves little purpose other than leak memory!

See Also