Archived

This topic is now archived and is closed to further replies.

maria maria maria

lua and c where canI find some examples?

Recommended Posts

Here''s a pretty simple example to get you started, call this luatest.c


#include <stdio.h>

extern "C" {
#include "lua.h"
#include "lualib.h"
}

/* the Lua interpreter */
lua_State* L;

int main ( int argc, char *argv[] )
{
/* initialize Lua */
L = lua_open(0);

/* load Lua libraries */
lua_baselibopen(L);
lua_iolibopen(L);
lua_mathlibopen(L);

/* run a script */
lua_dofile(L, "test.lua");

/* cleanup Lua */
lua_close(L);

return 0;
}


Then create a lua file and call it test.lua


-- simple test

print "Hello, World!"


Let me know what operating system you''re using and I''ll try to help you get it compiled.

Tony

Share this post


Link to post
Share on other sites