Game Development Reference
In-Depth Information
There are a number of advantages to using an existing language
the most important
being the incredible amount of time you ' ll save. I integrated Lua into this engine in
about a day, with another day for writing some glue code and a bunch of testing. In a
professional game, it might take 10 times as long, but if you compare that to the
numbers above for writing your own, the savings are obvious.
Another advantage is the huge amount of testing already done. You know that Python
s
if statement and for loops work, and you can be pretty sure that their data structures
are relatively optimized. The same will never be said about your own scripting language.
The reason is sheer numbers; there are thousands upon thousands of people using
Python and Lua every day, so the developers have had a lot of users flushing out all
the bugs. Your language will have considerably fewer users. On top of that, there are a
number of resources already available for existing languages. Do you need a very fast
math module for Lua? You can probably find one with a bit of searching. There are
thousands of people who can tell you how to call a function in Lua. By contrast, there
are maybe half a dozen people in this world who could tell you how to call a function
in the custom Action System scripting language we made at Super-Ego Games.
One disadvantage of using an existing scripting language is that you
'
'
re locked into
their environment model. It
s typically harder to control things like memory alloca-
tion, garbage collection, memory footprint, execution overhead, and so on. In a cus-
tom scripting language, you have complete control over all of those things.
Unless you have a really good reason not to do so, I strongly recommend using an
existing language instead of creating your own. The advantages almost always out-
weigh the disadvantages. This is the method I have chosen for this topic.
'
Choosing a Scripting Language
The two most common general-purpose scripting languages used in game develop-
ment are Python and Lua. UnrealScript is also fairly common, but only because the
Unreal engine itself is fairly common. C# is a relatively new contender with XNA and
Unity3D entrenching themselves on the scene. They tend to be used more in inde-
pendent games rather than professional games, but that
s been changing. C# was used
on The Sims 3 as well as The Sims Medieval for scripting.
'
Python
Python is a very popular scripting language with a huge support community. It is fully
object-oriented and has tons of tools and support. Here
'
ssomesamplePythoncode:
# This is a comment in python
def process_actors(actors):
 
 
 
Search WWH ::




Custom Search