KKConfig Class Reference
Inherits from | NSObject |
Declared in | KKConfig.h |
Overview
Access to configuration values loaded from config.lua – individual branches of the configuration values tree (lua table) can be selected and traversed.
Tasks
-
+ loadConfigLua
Called once by Kobold2D at system startup to run the config.lua script. Expects a table to be returned.
-
+ dumpConfigLua
Dumps the entire config.lua table (actually, it’s Objective-C representation as a NSDictionary) to the console, for debugging purposes.
-
+ selectKeyPath:
Select the part of the Lua table given by the key respectively key path (using dot notation). Returns YES if the path exists, otherwise return NO.
-
+ selectRootPath
Selects the root of the table.
-
+ dictionaryForKey:
Get the Lua table dictionary from the currently selected key path.
-
+ stringForKey:
Get the string from the currently selected key path.
-
+ numberForKey:
Get the NSNumber from the currently selected key path.
-
+ floatForKey:
Get the float from the currently selected key path.
-
+ intForKey:
Get the int from the currently selected key path.
-
+ boolForKey:
Get the bool (as int) from the currently selected key path.
-
+ injectPropertiesFromKeyPath:target:
Directly sets the target’s matching properties from the path in the config table. Only float, int, BOOL or NSString properties are supported. All properties must match the corresponding Lua type. Does not change the selected key path.
Class Methods
boolForKey:
Get the bool (as int) from the currently selected key path.
+ (BOOL)boolForKey:(NSString *)key
Declared In
KKConfig.h
dictionaryForKey:
Get the Lua table dictionary from the currently selected key path.
+ (NSDictionary *)dictionaryForKey:(NSString *)key
Declared In
KKConfig.h
dumpConfigLua
Dumps the entire config.lua table (actually, it’s Objective-C representation as a NSDictionary) to the console, for debugging purposes.
+ (void)dumpConfigLua
Declared In
KKConfig.h
floatForKey:
Get the float from the currently selected key path.
+ (float)floatForKey:(NSString *)key
Declared In
KKConfig.h
injectPropertiesFromKeyPath:target:
Directly sets the target’s matching properties from the path in the config table. Only float, int, BOOL or NSString properties are supported. All properties must match the corresponding Lua type. Does not change the selected key path.
+ (void)injectPropertiesFromKeyPath:(const NSString *const)keyPath target:(id)target
Declared In
KKConfig.h
intForKey:
Get the int from the currently selected key path.
+ (int)intForKey:(NSString *)key
Declared In
KKConfig.h
loadConfigLua
Called once by Kobold2D at system startup to run the config.lua script. Expects a table to be returned.
+ (void)loadConfigLua
Declared In
KKConfig.h
numberForKey:
Get the NSNumber from the currently selected key path.
+ (NSNumber *)numberForKey:(NSString *)key
Declared In
KKConfig.h
selectKeyPath:
Select the part of the Lua table given by the key respectively key path (using dot notation). Returns YES if the path exists, otherwise return NO.
+ (BOOL)selectKeyPath:(const NSString *const)keyPath
Discussion
The key path can be written just like you would access a nested Lua table: @“MyParams.Player.AnimationFrames”. Once a part of the table is “selected” you can then use the “ForKey” methods to read individual entries of that part of the table by using one of the xxxForKey methods.
Declared In
KKConfig.h