Advertisement

lua and c where canI find some examples?

Started by March 07, 2003 09:12 PM
1 comment, last by maria maria maria 21 years, 11 months ago
hello I try to using lua whit c and I have some problems when I try to compile... where can I find some examples???
desocupada
The Lua API manual.

Sorry, I couldn''t find any examples though. Maybe you''ll have better luck with Google than me.

henrym
My Site
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 testprint "Hello, World!" 


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

Tony

This topic is closed to new replies.

Advertisement