Re: printing to stdout
"Nigel Atkinson" <[email protected]> Tue, 9 Aug 2011 12:44:06 +1000
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
I assume its writing out "Result: 5" but not "test"?
You need to initialise the Lua library that has the 'print'
function. If you check the result of your last luaL_dostring() you
will probably find that there was an error.
Add:
luaL_openlibs( myLuaState );
Somewhere after your lua_open().
Nigel
On Tue, August 9, 2011 11:58 am, Josh Stratton wrote:
> I'm having issues printing to stdout from lua. I could have
sworn it
> was working for earlier cases. I can read back a value from a
> function, but doing a print statement doesn't display anything.
Is
> luabind writing to some other location? I thought I had it going
to
> stdout when I first set it up...
>
> // Create a new lua state
> lua_State *myLuaState = lua_open();
>
> // Connect LuaBind to this lua state
> luabind::open(myLuaState);
>
> // Define a lua function that we can call
> luaL_dostring(myLuaState,
> "function add(first, second)\n"
> " return first + second\n"
> "end\n"
> );
>
> std::cout << "Result: " <<
luabind::call_function<int>(myLuaState,
> "add", 2, 3) << std::endl;
>
> //luaL_dostring(myLuaState, "_meshImporters = {}");
>
> // read
> luaL_dostring(myLuaState, "print('test')");
>
>
------------------------------------------------------------------------------
> uberSVN's rich system and user administration capabilities and
model
> configuration take the hassle out of deploying and managing
Subversion and
> the tools developers use with it. Learn more about uberSVN and get a
free
> download at: http://p.sf.net/sfu/wandisco-dev2dev
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model
configuration take the hassle out of deploying and managing Subversion and
the tools developers use with it. Learn more about uberSVN and get a free
download at: http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user