- Online Community Forums » Game Design & Concepts » How much of your game logic is done by scripting?

This thread is locked; no one can reply to it. rss feed Print
How much of your game logic is done by scripting?
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++.

I’m 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 don’t 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?

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.

Mitsuko's last words, Battle Royale

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).

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
2. Wait for keyboard input
3. Start game
4. Display hiscore list
5. Wait for keyboard input
6. Go to 1.

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.

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. :) So far, I haven't found the need. I'd like to learn a thing or two about it one of these days, though.

"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/ | Zep's Dreamland | Allegro Newbie Tutorials

Member #6,894
February 2006

I’ve 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 don’t 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.

I’ve only written one game, a Pacman clone in C, so I’m not speaking from experience. But, writing everything in LUA may be a good idea for very simple games, but for more complex games, I’m not so sure.

Anyway, thanks for the feedback and advice. I’m writing another game and I’m going to stick with Allegro and LUA, but I’m only going to use LUA to initialize levels, respond to game events, etc.

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.

Member #2,902
November 2002

I actually never used scripts...
but maybe it would be a goor idea. it will at least enable others to make levels 8-)

Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard)
Current project: [Star Trek Project ] Join if you want ;-)

Member #3,619
June 2003

My game use script some times and sometimes not.
If you wanna try it the link is below.
In my opinion you should use script to synchronize events. Otherwise, when you only want to make appear some enemies, script are not required, and the enemies should move using a random movement or some sort of AI.

Multiplayer , now, eliminate advanced AI in a challenge between them.
Of course , super advanced AI erase any script.
That's the main difference , for example , between Medal of Honor (script), and FEAR (advanced AI).

In other ways , low budget programs uses scripts, the others uses AI.
Intelligent programs uses Multiplayer.
Very low budget projects uses random events and no scripts and no AI, no multyp.

Now, it only depends on your project.
In my dreams I also want to create, one day, an AI engine for a big game... it's my callenge... and I suppose yours too.

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.

Member #3,025
December 2002

Most 'scripting' is just another form of RPC.

The more you talk, the more AJ is right. - ML

Go to: