RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
 
Post new topic Reply to topic  
View previous topic - View next topic  
Author Message
akOOma
Wandering Minstrel


Joined: 20 Jun 2002
Posts: 113
Location: Germany

PostPosted: Wed Aug 27, 2003 7:15 am    Post subject: Set up Lua [quote]

I decided to use Lua in my current RPG engine (C++). Now I want to know if there's a precompiled version of Lua for MS VC++ 6.0.
If not, please advice me setting up Lua.
_________________
Keep on codin'
-----------------

-----------------
Just another post to increase my rank...
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Wed Aug 27, 2003 6:13 pm    Post subject: [quote]

http://lua-users.org/wiki/LuaBinaries

You'll sure to find much more usefull information there (on the Wiki) than just the links to the binary distributions. :-)
Back to top  
akOOma
Wandering Minstrel


Joined: 20 Jun 2002
Posts: 113
Location: Germany

PostPosted: Wed Aug 27, 2003 7:16 pm    Post subject: [quote]

is this the right file???

http://belnet.dl.sourceforge.net/sourceforge/doris/doris.exe
_________________
Keep on codin'
-----------------

-----------------
Just another post to increase my rank...
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Wed Aug 27, 2003 7:39 pm    Post subject: [quote]

I don't think so, I don't know what that doris thing is. You followed a link to Lua Build right? Look for a file called luabuild-5.0.tgz.

At your mirror, that would be:

http://belnet.dl.sourceforge.net/sourceforge/doris/luabuild-5.0.tgz

Or if you would like to use Lua 4 instead of 5 (though especially if you're starting to learn Lua, I recommend starting with 5):

http://belnet.dl.sourceforge.net/sourceforge/doris/luabuild-4.0.1.tgz
Back to top  
akOOma
Wandering Minstrel


Joined: 20 Jun 2002
Posts: 113
Location: Germany

PostPosted: Wed Aug 27, 2003 7:58 pm    Post subject: [quote]

Ok...I build the whole thing...what have I to do now if I want to use Lua with VC++ 6.0???
_________________
Keep on codin'
-----------------

-----------------
Just another post to increase my rank...
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Thu Aug 28, 2003 6:07 pm    Post subject: [quote]

You mean, compiling a project using Lua? You need to know how to link libs with your EXE. I'm assuming you know that. Then just make sure you link with the Lua libs (iirc, lua.lib and lualib.lib), and maybe the equivalent debug libs for the debug EXE.

Besides linking with the libs, you also need to include Lua's header file(s). Lua is a C library and when you include it in a C++ program, you have to put this around the includes:

extern "C" {
#include <lua.h>
#include <lauxlib.h> // whatever you need
...
}

The extern C is necesary because the libs are compiled in C mode, I think. You could do without if you had compiled the Lua libs in C++ mode.

I'm writing this out of memory, so there may be errors. In my opinion, the Lua documentation and Wiki were enough information to be able to use Lua, and Lua has a very active mailing list. Still, if you want to ask here, that's fine too.
Back to top  
akOOma
Wandering Minstrel


Joined: 20 Jun 2002
Posts: 113
Location: Germany

PostPosted: Thu Aug 28, 2003 6:43 pm    Post subject: [quote]

I've found out that by myself...


Sorry new question:

If I want to give variables from C++ to Lua and vice versa ("and back"), is there another way than putting them on the stack???
_________________
Keep on codin'
-----------------

-----------------
Just another post to increase my rank...
Back to top  
white_door
Icemonkey


Joined: 30 May 2002
Posts: 243
Location: New Zealand

PostPosted: Thu Aug 28, 2003 9:00 pm    Post subject: [quote]

well if you access the global table, you can directly access lua variables.

So you can access any global lua variable pretty easily, as for accessing a C variable from lua... I don't think that is possible. You could store the value of a C variable in a lua variable.. but that's about it.

these are two functions I *sometimes* use to if just want to access a lua variable quick. they are cool because they can handle complex situations like grabbing elements from with in a table and stuff.

Code:

double get_lua_number (lua_State *L, char *var) {
  double i;
  char buf[255];                         
  sprintf(buf,"_var=%s",var);
  lua_dostring(L,buf);     
  lua_getglobal(L,"_var");         
  i=lua_tonumber (L,-1);         
  lua_pop(L,1);                   
  return i;                       
}

void set_lua_number (lua_State *L, char *var, double value) {
  char buf[255];                         
  lua_pushnumber(L,value);         
  lua_setglobal(L,"_var");         
  sprintf(buf,"%s=_var;",var);
  lua_dostring(L,buf);
}
Back to top  
akOOma
Wandering Minstrel


Joined: 20 Jun 2002
Posts: 113
Location: Germany

PostPosted: Fri Aug 29, 2003 6:07 am    Post subject: [quote]

Thanks man...that's what I need.
_________________
Keep on codin'
-----------------

-----------------
Just another post to increase my rank...
Back to top  
Post new topic Reply to topic Page 1 of 1 All times are GMT
 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum