Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- I'm using visual studio, for this.
- */
- /* Test.h: */
- #ifndef __LUA_INC_H__
- #define __LUA_INC_H__
- extern "C"
- {
- #include "lualib/lua.h"
- #include "lualib/lauxlib.h"
- #include "lualib/lualib.h"
- }
- #endif // __LUA_INC_H__
- ////////////////////////////////////////////////////////////
- // Site I was following:
- // (http://www.codeproject.com/Articles/11508/Integrating-Lua-into-C)
- ////////////////////////////////////////////////////////////
- /* QuickTests.cpp: */
- #include "stdafx.h"
- #include "test.h"
- int main()
- {
- int iErr = 0;
- lua_State *lua = lua_open (); // Open Lua
- luaopen_io (lua); // Load io library
- if ((iErr = luaL_loadfile (lua, "test.lua")) == 0)
- {
- // Call main...
- if ((iErr = lua_pcall (lua, 0, LUA_MULTRET, 0)) == 0)
- {
- // Push the function name onto the stack
- lua_pushstring (lua, "helloWorld");
- // Function is located in the Global Table
- lua_gettable (lua, LUA_GLOBALSINDEX);
- lua_pcall (lua, 0, 0, 0);
- }
- }
- lua_close (lua);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement