LuaCore, a simple Cocoa wrapper for Lua 5.1
LuaCore is an Objective-C framework for running Lua scripts. Even better than that, it includes a bridge so that you can pass in Objective-C objects, and work with them in the Lua environment. You can call functions and methods and all kinds of other crazy things.
#import <Foundation/Foundation.h>
#import <LuaCore/LuaCore.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
LCLua *lua = [LCLua readyLua];
[lua runBuffer:@"print('hello world')"];
[pool release];
return 0;
}
Yes, it's that easy.
LCLua *lua = [LCLua readyLua];
[lua pushAsLuaString:@"this is the value of s" withName:@"s"];
[lua pushDictionaryAsTable:[NSDictionary dictionary] withName:@"d"];
[lua pushGlobalObject:self withName:@"myObject"];
[lua runBuffer:@"print(s)"];
[lua runBuffer:@"print(myObject:description())"];
[lua callFunction:@"addFour" withArg:[NSNumber numberWithInt:5]]
Send them along!
gus@flyingmeat.com