Thread: Lua?

  1. #1
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476

    Lua?

    A simple question guys, what do you usually use Lua (or any scripting language) are for? I'm planning to use OGRE 3D, SDL and Lua in a project. I know about the rest of the library, but not Lua. They said it would make prototyping faster. But what do I use it for? I haven't had the slightest thought.

    So I want to ask you guys (especially the ones experienced in Lua), what do you usually use Lua for?

    Thanks.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  2. #2
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    Err, sorry. Wrong place. I actually wanted to put this in the Game Programming area. Can the mod move this post there, please? Thanks.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  3. #3
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    When you create a sort of library for your program (functions, classes, etc.) and finally get around to using them. Sometimes that usage code is better to relay to a scripting language. Unless you and others plan on using it extensively it's probably not worth the effort though. It all depends (the necessity to switch (time/effort), length/importance of project, your experience with a side-by-side scripting language, chosen language (Lua), etc.) For example, I'm coding my library/programs with C++0x lambda branch, which simplifies a lot of code (syntax, libraries, lambda, auto, variadic, rvalues, etc). I can't imagine hitting the time/effort point to switch to Lua or Python in the near future. It just delays the sometimes inevitable though. If you know it's a big project that you'll be working on for years (that isn't a pure library project - ie boost/curl/etc - it has to be a project with lots of implementation), you might as well plan out some sort of scripting system and save yourself some time/effort. If the project has a simple completion date, you need not bother.

    It's just good for simplification, run-time debugging, group collaboration/distribution (editing scripts). It also helps abstract your interface incase you need to change something (you could even switch languages/libraries without having to change your Lua scripts) or there's a bug, etc.

    Examples would be configuration (for anything), game objects, game quests, player info, model info, dialog, logic (character disposition), world editors (u think GM's want to use C++? or we want them touching it), interfaces (GUI), etc. Everytime you see a code interface for anything related to the program's purpose, it *might* be quicker/easier to code that logic into a scripting language, leveraging your C++.
    Last edited by Dae; 10-03-2009 at 01:19 AM.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I've been using Lua for awhile now and it is both simple to support and simple to code in. Performance is good enough for retail games to use it as well. Lua is used in The Witcher, Neverwinter nights, etc. The Witcher is actually using a modified version of NW2 so it's no surprise it uses it.

    I've integrated Lua into my home projects with little effort. There are also some very good books available for it which may make the difference between a company accepting your proposal to use it or not accepting it. There are many good third party plugins for Lua that range from reading in XML to sharing and extending C++ classes. It is not the only solution out there though.

    Boost::Python also is fairly simple to integrate into existing C++. I do not know enough about it to give it a fair treatment but it is worth mentioning.

    Regardless of what language you use the biggest thing to remember is that bad scripts can bring good games to their knees. Be very careful how much logic you put into said scripts. As well some people approach their usage like it's C++ or an extension of the game engine or rendering engine. This is not true and will lead to big time spaghetti code. If you put all the functions you normally would have in C++ in your script you have now effectively tied the script to the engine. This is not all that bad but if the script and/or game have intimate knowledge of each other you could very well tie the engine into the script which is very bad IMO. So before you begin figure out your interfaces between C++ and your chosen script language. As you code to the interface you will find the need for new functionality, etc.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Bubba View Post
    I've been using Lua for awhile now and it is both simple to support and simple to code in. Performance is good enough for retail games to use it as well. Lua is used in The Witcher, Neverwinter nights, etc. The Witcher is actually using a modified version of NW2 so it's no surprise it uses it.
    Not to mention the largest game out there... WoW.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    @All: Thank you very much. I now have a pretty good idea of what to do. BTW, does anybody know a good online tutorial on Lua out there? Thanks again.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Is This Possible?
    By pobri19 in forum C++ Programming
    Replies: 4
    Last Post: 08-11-2009, 01:18 PM
  2. Integrating lua into C++ application
    By Swarvy in forum Game Programming
    Replies: 2
    Last Post: 07-19-2009, 01:23 PM
  3. Unresolved External Symbol
    By CornyKorn21 in forum C++ Programming
    Replies: 1
    Last Post: 01-20-2009, 02:50 PM
  4. While Loop and Delay
    By hmd in forum C Programming
    Replies: 5
    Last Post: 02-25-2008, 01:34 PM
  5. Lua and Dev-C++
    By fry in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 10-20-2002, 06:19 PM