Sign in to follow this  
Loredivine

Lua and C++ Tutorials

Recommended Posts

Alright, so I'm not saying I'm a total noob when it comes to scripting languages, but I've never used it in a game. I've played around with Perl and Python, like every programmer has. I just found Lua from a friend who asked me to make a Garry's Mod script, I of course had to tell him no, cause I didn't know how to use Lua outside of like.. Hello World? I was wondering if there's anyone of these forums with some links to some tutorials on using Lua with C++. I mean getting it for game logic and all of that stuff, setting the value of a variable in C++ with Lua, stuff like that. I've read a couple of tutorials on how to run a Lua script, but never how to set C++ variables in Lua, run functions in Lua, determine NPC logic, and what not. If you guys could post some links to tutorials for embedding Lua with C++ to do some of those things, that would be much appreciated. Also, don't call me "a total fucking noob" I'm probably one of the best programmers, if not THE best programmer at my high school. I've made a ton of games with a ton of languages, mainly C++, but I never thought to use a scripting language until as of now. Finally, YES I have google'd some tutorials on this same topic, but they're just a big huddle of incoherent code with barely to no explanation. Don't link me any Lua tutorials either please, I'm fine with the language, I have documentation if I don't get anything, I'd just like some links for tutorials which use Lua IN C++. Neither do I want "How to use Lua with C++" I don't care for using Lua as a stand-alone language anytime soon.

Share this post


Link to post
Share on other sites
You can find alot of the info your seeking here:

http://lua-users.org/wiki/LuaDistributions
http://lua-users.org/wiki/BindingCodeToLua

Specificly pick a binding library which suits your needs the best (I suggest LuaBind or MLuabind).

Here is a codeproject which uses Lua embeded in C++

http://sites.google.com/site/auraliusproject/lua-based-2d-robot-simulator

I'm sure you can learn alot from that, good luck!

-ddn

Share this post


Link to post
Share on other sites
Thanks for the reply man, very useful content you've got there. Once again, the basic Google search yields much too useful. Are there any places that might have information on how to SETUP Luabind. Luabind's files aren't put together very well for starters, and all of the good tutorials, lack any help in setting up the directories and so on.

Share this post


Link to post
Share on other sites
I have used Luabind a few times yet have not had much trouble in setting it up. It can either be built as a static library or just include the headers and source with your code. If you post the problems you are having then maybe someone will be able to offer help, the maintainer is even a member here yet I have not seen them on the board for some time.
If you can not find the help you need try the mailing lists as they are quite active
Luabind: https://lists.sourceforge.net/lists/listinfo/luabind-user
Lua: http://www.lua.org/lua-l.html

I would say that I find your last paragraph very defensive and aggressive, I actually had to ponder if I wanted to offer any advice at all.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this