[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE:
- From: virgil@... (Virgil Smith)
- Date: Wed, 17 Dec 2003 11:35:38 -0600
The key here lies in better understanding what luaL_loadbuffer does.
It "loads" the code, but does not execute it (which would give it the
opportunity to set globals such as "read").
Essentially luaL_loadbuffer returns on the stack a function whose body
consists of the loaded code, you can then call this function to run it (or
store it off in some table, or whatever).
Checking the manual/sources/and the list archives for lua_dobuffer should
help you better understand this (provided it doesn't swamp you with
results). Looking directly at the source for lua_dobuffer should help.
[mailto:email@example.com]On Behalf Of Stoil Todorov
Sent: Wednesday, December 17, 2003 11:12 AM
To: Lua list
I have the problem with load/call Lua code:-(
I follow the next order:
2. lua_getglobal(m_pLuaState, "read");
3. lua_pcall( m_pLuaState, 0, 0, 0 );
but I receive "A runtime error.: attempt to call a nil
value" - t.e. function "read" is not in Global state,
but I see it is in string, which I loaded...:-(
I load string with this code:
Sorry about this "beginner" question and thank you in
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.