C Board  

Go Back   C Board > General Programming Boards > Game Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-03-2009, 12:29 AM   #1
In the Land of Diddly-Doo
 
g4j31a5's Avatar
 
Join Date: Jul 2006
Posts: 373
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.
g4j31a5 is offline   Reply With Quote
Old 10-03-2009, 12:31 AM   #2
In the Land of Diddly-Doo
 
g4j31a5's Avatar
 
Join Date: Jul 2006
Posts: 373
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.
g4j31a5 is offline   Reply With Quote
Old 10-03-2009, 01:09 AM   #3
Dae
Deprecated
 
Dae's Avatar
 
Join Date: Oct 2004
Location: Canada
Posts: 944
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++.
__________________
Warning: Have doubt in anything I post.

GCC 4.5.0 (lambda branch), Boost 1.40.0, Code::Blocks 8.02, Ubuntu 9.04 010001000110000101100101

Last edited by Dae; 10-03-2009 at 01:19 AM.
Dae is offline   Reply With Quote
Old 10-03-2009, 08:53 AM   #4
Super Moderator
 
Bubba's Avatar
 
Join Date: Aug 2001
Posts: 7,470
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.
__________________
If you aim at everything you will hit something but you won't know what it is.
Bubba is offline   Reply With Quote
Old 10-03-2009, 09:04 AM   #5
+++ OK NO CARRIER
 
quzah's Avatar
 
Join Date: Oct 2001
Posts: 10,260
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.
__________________
Hundreds of thousands of dipshits can't be wrong.


Are you up for the suck?
quzah is offline   Reply With Quote
Old 10-08-2009, 08:53 PM   #6
In the Land of Diddly-Doo
 
g4j31a5's Avatar
 
Join Date: Jul 2006
Posts: 373
@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.
g4j31a5 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 03:08 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22