Advertisement

Scripting language

Started by June 08, 2003 08:53 PM
3 comments, last by DuncanBojangles 21 years, 8 months ago
What is a scripting language and how is it applied to a game? I''ve heard that these make it easier to adjust the program without changing the code. Any help would be greatly appreciated. "Donkey, if it were me, you''d be dead."
"Donkey, if it were me, you'd be dead."I cna ytpe 300 wrods pre mniute.
Let me re-ask your question, "How do you use scripting languages to improve a game engine? What are some common scripting languages?"

Answer: Scripting languages interpreters are just programs that run other programs. Instead of hard coding "here -> make donkey kick", you would tell the program to read a file, which says "here -> make donkey kick". That way, instead of changing your code, you just have to change the file, i.e., you want the donkey into a cow, so you just change one file, rather than searching your code to find all references to donkey, and change it to cow...

You may also skip compiling your entire code, since you just have to mess with the scripting language, rather than the entire program. (some scripting lanuages compile, some don''t). That will also let you test things out easier....

Common scripting languages, "Lua", "Python", "QuakeC", "Java"
~~~~~Screaming Statue Software. | OpenGL FontLibWhy does Data talk to the computer? Surely he's Wi-Fi enabled... - phaseburn
Advertisement
... Embedded virtual machines ...

Previously "Krohm"

I will try to provide a concrete case.

I''ve developed a game engine and with it, I can create a navigable game environment in a matter of minutes.
The game is described in terms of rooms, objects, and characters. A number of interactions are built-in. For example, you don''t need any programing effort to specify that a key can be picked up or that a door can be opened. The game engine automatically assumes so.

However, I soon realised that this wasn''t enough for a fair level of interaction for a decent game. If you need a computer-controlled character to talk to you when you look at him, for example, then you need to instruct the game engine with something like this:

-When this person is looked at:
> Say "Hello, why do you look at me?"

So I had to incorporate an interpreter which is able to read and understand the above instructions, provided that you used some ''standard'' coding.
This standard coding is what you call scripting language.
Then, you can make characters in the game to react to events by using the scripting language.
I used a derivative of Basic language, which is not so elegant but it''s simple to use. Here''s how the coding of the above would result:

EVENT person.onLook
ACTIONS
Speak "Hello, why do you look at me?"

You see, the meaning is straightforward, but this time I used the Basic scripting language instead of pseudo-code like above.


Hope it helps.



--Cris
http://www.dimensionex.net
The Freeware Multiplayer Game Engine
--Crishttp://www.dimensionex.netThe Open Source Multiplayer Game Engine
Check in to embedded Python. It''s free, and pretty easy to use, though I''ve never tried embedding it into C/C++ before.

This topic is closed to new replies.

Advertisement