Re: printing to stdout
Josh Stratton <[email protected]> Tue, 9 Aug 2011 07:06:24 -0700
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <CAPVmgLhfsCAqNDnDfh8zvNxr+PHe8UnK4B6-T5DvC00Ac3=byA@mail.gmail.com> |
That was it, thanks. I had to put it after my luabind::open() call to
avoid a panic at runtime.
// Create a new lua state
lua_State *myLuaState = lua_open();
// Connect LuaBind to this lua state
luabind::open(myLuaState);
luaL_openlibs(myLuaState);
On Mon, Aug 8, 2011 at 7:44 PM, Nigel Atkinson <[email protected]> wrote:
> 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
>
>
------------------------------------------------------------------------------
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