Sometimes you want more power of your game engine. You decide to add new using the code available in the game engine and some ingenuity. But, how will you make it easy on you and your other team members or yourself to easily use that functionality without diving into the code? You use a language as a scripting language.
Scripting Language – What It Is?
A scripting language is a language used within a game engine to perform certain behaviors in-game. The difference between this and the programming language is that it doesn’t add new functionality to the game engine. It’s the concatenation of functionality into usable mechanics in your game. Now, how can we make our own scripting language? I’ll be using RMMV as the base for this concept; let’s explain the concept.
Creating The Language
RMMV has its own scripting language; the scripting language uses event commands to drive behaviors in-game. Each event command maps to certain game functionalities to create the effect you want. So, to make our own language we need to do things: create commands that use the game engine’s functionality a bridge between the functionality, and a way to read each command. Let’s break that down into usable parts.
Creating A Command
A command is just text; for people who use a command line, this is the way exact same idea. The command is a name for a set of instructions, that take some parameters. Here’s an example:
showText "Hello World"
The command is showText and the parameter is “Hello World.” Our command is now done. The important thing to note is what we want our command to do. Now let’s talk functionality.
Functionality – Behind The Command
Now that we have our command, let’s design the functionality behind that command. Our command shows text, thus, our code should take that text, then display it on the game screen. That’s all our design should do; the implementation is up to the programmer. For example, they may have to create a window to display text in, then create the functionality to display it on the screen properly. Now, the last step also falls to the programmer, which is the interpreter.
The interpreter is the key to your scripting language. It interprets your commands and executes the underlying functionality, your programmer designed for you. What the interpreter does is go line by line, read each instruction and executes the code. The advantage is the abstraction away from the code base, making it easier for the artists and level designers to work with. In the context of the showText command and the interpreter would read showText first, then take each parameter separated by a space as a parameter on that line. By using this effectively, you can create your own scripting language.
A combination of creating commands with sufficient rules and parameters, detailing how they should work. Then getting a programmer to create the functionality, and an interpreter to read and execute your language. These three parts are the core of building your own language.