Chapter 12. Scripting

A script language for a game engine is a programming language that can be used to write script programs that do not need to be compiled. A script program can be edited after a game has been compiled, thus changing the properties and functionality of the game. High-level scripting languages allow for rapid development, content creation, and interactive events, and they drive many of today’s most powerful game engines and tools. Used for both game logic and automation tools, scripting language has become a mainstay in game production.

When a game is “scripted,” it means the game supports a script language. We can use a script language in many ways. The simplest use of a script is to define basic properties for a game (such as screen dimensions, full-screen mode, and color depth). We call such properties script globals. Script programs can also contain functions. These functions can accept parameters, perform calculations, and return results to the calling program (that is, your game). On the converse, a script program can call on C++ functions in your game. When a game has been scripted, by adding support for a script language and providing facilities within the game to support it, then the game takes on a whole new dimension for the game designer. No longer forced to go through programmers for gameplay changes, a game’s designer can make changes to scripts to modify the game’s look, feel, and other aspects.

Advice

This chapter does not teach the Lua language beyond a quick overview, as our main concern is enhancing the game engine with scripting support. The online Lua manual is an excellent resource at www.lua.org/manual/5.1/. Several books have been written about Lua, including Alex Varanese’s Game Scripting Mastery (Course Technology PTR, 2002) and Tom Gutschmidt’s Game Programming with Python, Lua, and Ruby (Course Technology PTR, 2003).


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset