Jump to content
  • Advertisement
Sign in to follow this  

Grabbing output from lua script

This topic is 2930 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


I 've got the following code

extern "C"
#include "lua/lua.h"
#include "lua/lauxlib.h"
#include "luabind/luabind.hpp"
#include <iostream>
using namespace std;
void teller()
int i = 0;
cout << i << ",";

int main()
//create a lua state
lua_State* pLua = lua_open();

//open luabind

/* Register functions and classes with luabind here */
luabind::def("teller", &teller)

/* load and run the script here */

luaL_dofile(pLua, "script1.lua");

//luaL_dostring(pLua, "teller()");

//tidy up

return 0;


print("[lua]: About to call the C++ teller() function")

If I uncomment //luaL_dostring(pLua, "teller()"); , then i get the output from the teller() function in my console window,
If I use luaL_dofile(pLua, "script1.lua"); , then i dont get anything in my console window, just "process returned 0, 0x0)

Im using lua 5.1.4 & luabind 0.9.1

Anyone can tell me how to grab the output from a .lua file that was executed from inside c++?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!