1 /** 2 Definition.c 3 Functions generally applicable to definitions. 4 5 @author Maikel 6 */ 7 8 static GetDefinition_Loaded_Definition_List; 9 10 // Returns the definition or nil if par is a string and the definition exists. 11 // See the documentation for the case when par is an integer. 12 // documented in /docs/sdk/script/fn GetDefinition(par)13global func GetDefinition(par) 14 { 15 // Overload behavior when par is a string. 16 if (GetType(par) == C4V_String) 17 { 18 if (GetDefinition_Loaded_Definition_List == nil) 19 { 20 // Fill the static list of definitions when it has not been generated yet. 21 GetDefinition_Loaded_Definition_List = {}; 22 var i = 0, def; 23 while (def = GetDefinition(i++)) 24 GetDefinition_Loaded_Definition_List[Format("%i", def)] = def; 25 } 26 // Return the definition if in the list and nil otherwise. 27 return GetDefinition_Loaded_Definition_List[par]; 28 } 29 return _inherited(par, ...); 30 } 31