Inherits from NSObject
Declared in KKLua.h

Overview

Static class containing various Lua related helper methods.

Tasks

  • + doFile:

    Runs the Lua script file. File is a filename with or without path to the file, and with extension. Returns YES if the execution was successful and NO if it failed. Note that this is different from Lua, where a return value of 0 indicates success and 1 or higher indicates an error. But YES == success is more natural for Objective-C programmers.

  • + doFile:prefixCode:suffixCode:

    Like doFile but allows to add some Lua code dynamically either before or after the contents of the file, or both.

  • + doString:

    Runs the Lua code passed in as string. Returns YES if the execution was successful and NO if it failed. Note that this is different from Lua, where a return value of 0 indicates success and 1 or higher indicates an error. But YES == success is more natural for Objective-C programmers.

  • + loadLuaTableFromFile:

    Runs the given Lua script file and expects it to return a table. The returned table is then parsed into a hierarchy of NSMutableDictionary objects. The hierarchy of dictionaries now allows you to navigate the Lua table using regular Objective-C syntax. The returned NSMutableDictionary is set to autorelease.

  • + logLuaError

    Logs the most recent Lua error by getting the error message string from the stack index -1 and displaying it.

  • + logLuaErrorWithMessage:

    Logs a Lua error with a custom message.

Class Methods

doFile:

Runs the Lua script file. File is a filename with or without path to the file, and with extension. Returns YES if the execution was successful and NO if it failed. Note that this is different from Lua, where a return value of 0 indicates success and 1 or higher indicates an error. But YES == success is more natural for Objective-C programmers.

+ (id)doFile:(NSString *)aFile

Declared In

KKLua.h

doFile:prefixCode:suffixCode:

Like doFile but allows to add some Lua code dynamically either before or after the contents of the file, or both.

+ (id)doFile:(NSString *)aFile prefixCode:(NSString *)aPrefix suffixCode:(NSString *)aSuffix

Declared In

KKLua.h

doString:

Runs the Lua code passed in as string. Returns YES if the execution was successful and NO if it failed. Note that this is different from Lua, where a return value of 0 indicates success and 1 or higher indicates an error. But YES == success is more natural for Objective-C programmers.

+ (id)doString:(NSString *)aString

Declared In

KKLua.h

loadLuaTableFromFile:

Runs the given Lua script file and expects it to return a table. The returned table is then parsed into a hierarchy of NSMutableDictionary objects. The hierarchy of dictionaries now allows you to navigate the Lua table using regular Objective-C syntax. The returned NSMutableDictionary is set to autorelease.

+ (NSDictionary *)loadLuaTableFromFile:(NSString *)aFile

Declared In

KKLua.h

logLuaError

Logs the most recent Lua error by getting the error message string from the stack index -1 and displaying it.

+ (void)logLuaError

Declared In

KKLua.h

logLuaErrorWithMessage:

Logs a Lua error with a custom message.

+ (void)logLuaErrorWithMessage:(NSString *)aMessage

Declared In

KKLua.h