• Advertisement

Archived

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

lua and c where canI find some examples?

This topic is 5434 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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

  • Advertisement