2017-06-02 15:14:52 +00:00
|
|
|
/**
|
|
|
|
Definition.c
|
|
|
|
Functions generally applicable to definitions.
|
|
|
|
|
|
|
|
@author Maikel
|
|
|
|
*/
|
2016-03-20 08:15:24 +00:00
|
|
|
|
|
|
|
static GetDefinition_Loaded_Definition_List;
|
|
|
|
|
|
|
|
// Returns the definition or nil if par is a string and the definition exists.
|
|
|
|
// See the documentation for the case when par is an integer.
|
2017-10-20 22:10:42 +00:00
|
|
|
// documented in /docs/sdk/script/fn
|
2016-03-20 08:15:24 +00:00
|
|
|
global func GetDefinition(par)
|
|
|
|
{
|
|
|
|
// Overload behavior when par is a string.
|
|
|
|
if (GetType(par) == C4V_String)
|
|
|
|
{
|
|
|
|
if (GetDefinition_Loaded_Definition_List == nil)
|
|
|
|
{
|
2016-05-01 14:14:56 +00:00
|
|
|
// Fill the static list of definitions when it has not been generated yet.
|
2016-03-20 08:15:24 +00:00
|
|
|
GetDefinition_Loaded_Definition_List = {};
|
|
|
|
var i = 0, def;
|
|
|
|
while (def = GetDefinition(i++))
|
|
|
|
GetDefinition_Loaded_Definition_List[Format("%i", def)] = def;
|
|
|
|
}
|
|
|
|
// Return the definition if in the list and nil otherwise.
|
|
|
|
return GetDefinition_Loaded_Definition_List[par];
|
|
|
|
}
|
|
|
|
return _inherited(par, ...);
|
2017-10-20 22:10:42 +00:00
|
|
|
}
|