3
\$\begingroup\$

What is scripting, and what is a scripting API? Is scripting the process of writing the game program, and is the scripting API (such as the Unity scripting API) the API provided by the game engine, which we use to create games?

\$\endgroup\$
2
\$\begingroup\$

Some of the answers are very convoluted, so I will make it brief.

Programming languages can be divided in two categories: compiled and interpreted.

In compiled languages (e.g. C) the source code go through a compiler and produces an executable file that can be run on a compatible machine.

In interpreted languages (e.g. Javascript) the source code go through an interpreter at runtime, executing it on the spot.

Therefore an script is the source code for an interpreted language. That means that the code needs an interpreter to be run.

In the context of games, some engines provide an API that represents the language that you write to use the functionalities of that engine.

Answering your question, usually games are written in compiled languages, limiting the scripts to very specific behavior (e.g. AI).

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

The principal difference between a script or a program is that the script is completely dependent of the API its scripting engine exposes to it.

If I code a game in C++ using a C++ game engine, I'm not doing any scripting, my resulting binaries are standalone and are not limited by the engine's API. I can use the virtual filesystem (if any) of the engine to read files, or I can completely bypass it and use calls to the operating system API.

Usually, when the game engine support scripting, I only can do what the scripting language syntax + game engine API allow.

Given that definition, If I'm coding a game engine and I want to support scripting, simply distribute a Python installer with the game engine and an API to allow the scripts to interact with the game engine may not count as scripting, as a Python program can do pretty much what a standalone program can. To adjust to my definition of scripting, a modified version of Python may be required, with many modules removed or somehow not allowed to use, then you can say the user of the engine is doing scripting, and not a full program that interact with the engine.

The javascript running in your web browser is a better example of what I have for scripting. You can do almost everything with it but I challenge you to write/read a file to the filesystem or use any of the OS APIs. It is completely restrained to what the browser engine allows It to do. It results convenient to the developer and protects the user.

There are game engines that have their own scripting language and others that implements an existing one.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

First, what are our goals? We want a lot of people to use the engine as effectively and as quickly as possible to prototype and make full blown games.

  • Ease of use -> We need to abstract complexity
  • Time needed to add and test a change -> We would like to avoid compilation
  • Debugging -> We don't want people to touch our tested code; we need them to write their code separately from ours.
  • Learning curve -> We may not want our users to need to know C++ for various reasons and prefer they'd use a simpler language.

I think a more precise metaphor would be this:

The Engine, the body, the lights of the car and all that stuff you probably should never touch (if all you want is to get somewhere) are the Engine.

The API is the keyhole in the starter, the wheel, the break pedal, the stick, the gas pedal, the clutch and little plastic handle that you use to turn on the lights and the one for the windscreen wipers and air-conditioner's knob and the radio buttons are the API.

You don't need to know anything about the Engine, air-conditioning, radio signal or the light bulb in your headlights to get the car running, playing music, air-conditioned and functioning really well enough to get yourself from point A - to point B. You also don't need to build anything new or modify any of the parts of the car itself.

So the car is like the Engine, the Scripting API is like all the controls you take for granted when you ride the car that help you forget how complex the technology behind them is, abstraction.

So in short, a scripting API is an hopefully easy way, to control a very complex system you possibly have little to no knowledge of by the use of abstraction, a preferably easy to learn interface and sparing you the need to build these services yourself.

You can however still modify things "inside" with some Engines depending on the contract between the company (creator) and the end user.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ So scripting is not a must for game programming from engine and is only an added advantage? @Zehelvion \$\endgroup\$ – Celer Cube Nov 10 '14 at 14:44
  • \$\begingroup\$ @CelerCube Lets look at Box2D, a physics simulator engine. In it's native version (C++), you could use it by writing C/C++ and compiling your code. Scripting is definitely advantageous because the less you need to know to use something proficiently, the more value you get for a smaller investment, right? Compiling is another issue, compilation could become a time consuming process; if you don't have to compile to test your changes, that is a considerable advantage. \$\endgroup\$ – AturSams Nov 10 '14 at 15:17
  • \$\begingroup\$ So Can I program in c++ in UDK? \$\endgroup\$ – Celer Cube Nov 10 '14 at 15:19
  • \$\begingroup\$ @CelerCube hmm... I don't use UDK, I am using Unreal 4 atm.. I think you could buy the Engine, and program in c++ to utilize the engine. You can do that "out of the box" with Unreal 4. Of course, some products / companies "hide" the Engine on purpose for secrecy and support reasons. Supporting an Engine where you could modify the source may become very unmanageable task and exposing code (even if it's copyrighted) might cause a company losses in the long run. Some aspects of the code are never copyright protected. Design principles, Patterns etc. \$\endgroup\$ – AturSams Nov 10 '14 at 15:21
  • \$\begingroup\$ I am not into prfoessional game programmiong atm.I am a complete beginner with lots of doubts.I did visit as much as youtube vids and pages to clear my doubts but all they said was write this code use this etc. \$\endgroup\$ – Celer Cube Nov 10 '14 at 15:24
0
\$\begingroup\$

If a game uses scripting, it means it has a system of reading in a secondary language and converting that code into something it can run. For example Legend Of Grimrock, the main engine is written in C/C++, but it uses Lua as a scripting language to manage in-game events and monsters.

The main purpose of scripting is to be able to change a game's behaviour without having to recompile the game itself. This is especially useful for things such as monsters' stats - you wouldn't want to recompile the entire game engine every time you changed a spider's attack stat.

A scripting API (application programming interface) is the way a scripting language interfaces with a game engine. The game engine exposes functions that can be called from the scripting language to do things like spawn monsters, give the player items or just display messages for the player to read.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Scripting for games can range from simple operations with home grown languages to writing the entire game in high level languages like Lua or C#.

If we take a car analogy, a game engine is like a real engine, and scripts are everything else. Scripts are the fuel, body, wheels, steering, paint job and so on. Scripts are what make the engine run, and tell it how to run. Even though a car may have the same engine, they can drive and look completely different. Which is how we can have the same game engine under the hood, but have completely different games on the outside.

Scripting APIs are the connection points with the game engine that allow us to control it. API stands for Application Programming Interface. It's the interface between the game engine and the scripting language. These APIs go both ways, they allow us to get information from the game engine and allow us to provide information/instructions to the game engine.

Some engines are flexible enough that they give you the power to create an entire game with scripts alone. Some engines are just part of the solution and are available to build upon to create a game.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Good answer; Saying "Engines are powerful enough that you can create an entire game with scripts" is incorrect, you could say built flexible enough(?) or simply written that way. Any Engine might have a lot of "power", a lot of capabilities but it doesn't mean it can be manipulated by scripts. \$\endgroup\$ – AturSams Nov 9 '14 at 5:14
  • \$\begingroup\$ @Zehelvion 'Powerful enough' can be taken to mean many things. Clearly in this sense, I'm talking about the power to create an entire game. \$\endgroup\$ – MichaelHouse Nov 9 '14 at 16:48
  • \$\begingroup\$ dictionary.reference.com/browse/powerful?s=t \$\endgroup\$ – AturSams Nov 9 '14 at 19:13
  • \$\begingroup\$ @Zehelvion I'm familiar with the meaning of the word. Since I knew what the word meant already, linking the description does not change my answer or comments. Perhaps you can learn something from it? Try applying the 4th definition to my answer. \$\endgroup\$ – MichaelHouse Nov 9 '14 at 20:54
  • \$\begingroup\$ Honestly it's like saying that some cars are powerful enough that you can operate the Engine without using the clutch. If you think it's proper English and refuse constructive criticism and then go and close a question in suspiciously high temporal proximity to the event, all the more power you you. ;) Btw I agree the question should have been closed but I suspect it wouldn't have been if I hadn't pointed out you could improve the wording of the answer. \$\endgroup\$ – AturSams Nov 10 '14 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.