Hi,
I hope I'll find guidance her cause I'm trying to embed lua 5.0 into a project for days - without much sucess.
I'm not at the binding process - everything i want to do is call a lua script (plain or optcode) which says "Hello world!".
I've managed to do it at a little standalone "project".
extern "C"
{
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
main(){
//do the lua stuff
{
lua_State* luaVM = lua_open();
if (luaVM != NULL)
{
luaopen_base(luaVM);
luaopen_string(luaVM);
luaopen_math(luaVM);
luaopen_io(luaVM);
lua_dofile(luaVM, "luatest.lub");
lua_close(luaVM);
}
}
It works. I'm making the same adjusments to my project (header, libs and the rest of this code). And? It doesn't work.
It compiles with a lot of warnings (192) - all the same, for example:
lua.lib(lvm.obj) : warning LNK4006: _luaV_settable already defined in lualib.lib(lvm.obj); second definition ignored
But a least it compiles - and then I'm getting runtime exceptions when trying to call
lua_dofile() - (Unhandled Exception - Access violation writing location 0x00000010). I've used the LuaBuild-5.0 files and Build my own. No significant differnce.
Then I've kept close to the GameDev Tutorial "An Introduction to Lua" and tried the dostring code exactly as said. It works partially.
The odd thing is: I can call lua-scripts as long I'm not doing anything to "interact" with the app.
For exmaple...
char* strLuaInput = "a = 1 + 1;\n";
lua_dostring(luaVM, strLuaInput);
...works. But when I'm trying to write at the console:
char* strLuaInput = "a = 1 + 1;\nprint( a);\n";
lua_dostring(luaVM, strLuaInput);
I'm getting an Exception (access violation - writing location ...)
I've guessed that the dofile/dostring functions are somewhat "old" cause the documentation of lua 5.0 says nothing about them. But I also couldn't find out how I should simply call a script and not with "lua_dofile()".
I've begun from scratch serveral times - no sucess. Has anyone an idea what am I doing wrong?
thanx
[edited by - quasty on February 16, 2004 11:53:04 AM]