Sign in to follow this  
KurtCPP

Good Lua tutorials or books

Recommended Posts

Hi all! I'd like to get started with real Lua scripting but I've not been able to find out a good book or tutorial that really explains how to do something useful with Lua (preferrably with LuaBind) and a C++ game. What I'm most interested in is not the language nor the binding library (I can learn how to use LuaBind by myself reading documentation) but rather the way you can link an object oriented code to your scripts and get a powerful and easy to maintain game. For instance, if you need to develop a RPG, I'd like to get some advice about how you have to bind scripts to your objects. Do you need to define a script to initialise each instance or only one script that handles the whole map and the objects it contains? I'd just like you to indicate me all the good URL's or books you know. Thanks a lot in advance!!

Share this post


Link to post
Share on other sites
There isn't a tutorial or book I know of that will tell you how to link your game to your scripts. It is something you have to determine yourself.

I handle it in a lot of different ways. I have a script function that is called when a map loads and unloads. A ScriptObject can be defined in my map format which can instantiate any Lua object (table) and call standard functions in it (Process(), Init(), UnInit(), etc).

For example, my item boxes are ScriptObjects. They manage the physical (collision) and graphical boxes on the server and client and maintain all state, logic, and communication for the gameplay item boxes.

One thing you should determine right away is if you want the game to be written entirely in Lua with some calls to C++ (DrawCircle, DrawImage, GetInput, etc) or if you want to maintain a normal C++ object hierarchy and change the state of the C++ objects from Lua.

Share this post


Link to post
Share on other sites
Hi, first thanks for your guidance.

What you answered to me is exactly what I feared most : I'll have to think by myself!!! <-O lol.

Now I guess the best way to do mostly depends upon the style of the game, so I just would like to ask one more question please : since I'm more fluent with C++ and since I think I would prefer use a majority of compiled code (ie an engine with a lot of functionalities available from Lua), do you think it's a good idea to have small scripts parts that change the state of the C++ objects from Lua in the particular case of a game that must use very numerous scripts (a RPG for instance)?

Thanks again for your help.
Cheers!

Share this post


Link to post
Share on other sites
I think that is a good way to go.

You could code enemy behaviors or spells or dialog trees with Lua and leave all the engine code in C++. I am trying to code all my gameplay in Lua and leave everything else to C++ for the most part.

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