![]() |
|
How much of your game logic is done by scripting? |
BigSir
Member #6,894
February 2006
|
How much of your game logic is done by scripting? From reading the posts around here, I got the impression that most people use scripts for cut-scenes, event handling, and setting up levels etc. But most of the game logic is done in C/C++. Im asking because I bought a few books on using LUA with C/C++, one of which is Game Development with LUA. In the book, they are integrating LUA with C++, but, they do almost all of the game logic in LUA: a Lua-powred GUI, the game loop, movement, AI, collision detection, loading and saving game data, pretty much all the high level logic. In fact, they even do path finding in LUA. CPU intensive tasks are left up to the C code though. They claim this dramatically speeds up development time, and gives the scripters maximum flexibility, resulting in a better game. According to the authors, if there are any performance bottlenecks in the LUA script, then those functions are commented out in the LUA script and replaced with a call to a C/C++ LUAGlue functions. The games the authors have produced using this concept are not all that good, Frontrunner, Health and Fitness Tycoon, and another really awful Tycoon game that I cannot remember. I dont know if these game suck because they use LUA for everything or because of something else. Does using LUA (or comparable scripting language) like this seem like a good idea? |
ReyBrujo
Moderator
January 2001
![]() |
Scripting is useful once you have a good engine to back it up. Most of the times I prefer coding the different options inside the program. Lately, I am using design patterns, especially factory and composite. This way you can represent logic as a black box, which you can modify, expand or simplify without having to modify the program. Unless you already have a robust engine that surrounds LUA, don't bother applying more complexity to your program. -- |
Graham Goring
Member #2,367
May 2002
|
100% of my game logic is scripting. That said, there are a few quite high level functions available to my scripting language (ie, creating lists of entities matching a certain criteria, snapping to collision, etc). |
Steve++
Member #1,816
January 2002
|
It depends on the type of game. The word 'scripting' is a bit misleading though. Scripting languages like Lua can be used in a very simple, sequential manner (much like a script in a film), without any complexity, so that they could be written by anyone in the creative team. An example: 1. Show title screen In the above example, you have all the main components of the game written and the script simply glues them together. Scripts can also be used to control game levels. Such scripts would be driven by generic events, such as collisions. The scripts associates with the events would determine whether certain objectives have been met. Yet another usage for scripts is NPC behaviour. Typically at a regular interval, each NPC's script would be executed and it would make its next move. This is where scripts get complicated, but NPCs are a very useful place to use scripts. The good thing about scripts is that you can plug them in and change them without having to compile your whole project. Also in many cases, non-programmers can write simple scripts, so it's a good way of palming off some work. Another compelling reason to use scripting languages is that they have features that can put a dent in development times. Lua for example is really good for writing table-driven scripts. My suggestion is that you shouldn't become a slave to scripting just because it's a cool thing to do. When you use a scripting language, you must deal with the annoyances of two languages instead of just one. |
Ultio
Member #1,336
April 2001
|
If it makes any difference, I've never used any "real" scripting language in any of my games. The only thing that comes remotely close is the ending of ZD where the player moves around on his own. That's just stuffing key input into the logic routines, though. I guess it goes to show that you only really need it where you actually really need it. --- |
BigSir
Member #6,894
February 2006
|
Ive finished the book and I can tell you that the game the authors finally create is utterly horrific. Despite the fact that it is an even simpler version of asteroids and they use the latest version of DirectX, their game barely runs at all - and I have a really fast system. Their entire game is in LUA script: GUI, setup, game loop, and shutdown. The C program just has low-level functions that LUA calls. As far as their demo game sucking, I dont think it is LUA, I kind of think the issue is that the authors just write shitty games. But performance is clearly an issue - a big issue. Ive only written one game, a Pacman clone in C, so Im not speaking from experience. But, writing everything in LUA may be a good idea for very simple games, but for more complex games, Im not so sure. Anyway, thanks for the feedback and advice. Im writing another game and Im going to stick with Allegro and LUA, but Im only going to use LUA to initialize levels, respond to game events, etc. |
Steve++
Member #1,816
January 2002
|
Have a look at LuaEng. Documentation.It's made by some guy I've met once or twice. He's a professional game developer. |
Ariesnl
Member #2,902
November 2002
![]() |
I actually never used scripts... Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard) |
LordHolNapul
Member #3,619
June 2003
![]() |
My game use script some times and sometimes not. Multiplayer , now, eliminate advanced AI in a challenge between them. In other ways , low budget programs uses scripts, the others uses AI. Now, it only depends on your project. Good Night. ciao |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
A good AI could still be written in a Script. It would not make it "scripted" per see. Some very successfull games use scripting, and the devs say only good things about it... that must count for something. All Infinity Engine games (Baldurs gate 1&2, Icewind dale) and NWN use LUA for example. Half-life's aproach is some sort hybrid as far as i understand it. The engine is of course coded in C/C++ (dunno which, but since it's based on Quake 2 i would guess C), but all "game related" stuff is stuffed into what essentially is a big ol' DLL. This is scripting of sorts... It has many of the benefits of regular scripting (LUA etc), but whatever effects LUA would have on performance would be negligable with this method. Another pro for this aproach is that you dont need to learn a new language, and that "binding" will be a breeze, at least one way (Engine->Game). If i ever get to it and make that great RPG (tm), i would probably use LUA for any "game" logic, such as magic spells, scripted events (duh) and similar things - but not for the combat system itself, character creation, GUI etc.
|
A J
Member #3,025
December 2002
![]() |
None. ___________________________ |
|