Tuesday, 26 November 2013

Scripting

These are the notes I made during the Wednesday scripting lecture.

So what is scripting? Scripting is an interface that exposes C++. A script has functions and classes. Programs written to handle scripts use a special run-time environment that can interpret rather than compile and automate the execution of tasks which could alternatively be executed one-by-one by a programmer or scripter. What this means is that there are files that are read in by the engine to determine the game's logic. This is good because you do not have to recompile this logic every time it is modified.

Here is a list of scripting languages that we came up with in class:

Squirrel
AngelScript
Lua
Python
JavaScript
ActionScript
HeroScript
MEL
GameMonkey
ChaiScript

Quake C
UnrealScript

I left Quake and Unreal at the end because these two languages are singled out to be specifically for their own engines. These are techincally scripting languages but they are most efficient inside of their respective engines.

In class we also talked about Data Declarative types of scripting languages. For example Ogre's particle engine is a data declarative scripting style. It declares a specific type of data and how it is going to be used. Below I have an example of a data declarative scripting languages:

XML is data declarative
XML allows to creates your own language. DOM
<character Name "Joe">
<strength> 5 </strength>
</character>

<particleSystem ID = "fire">
<force>0,0,5
</force>
</particleSystem>

In this example the code is defines a character named Joe and then a particle system called fire that has a force of 5 in the z direction. This is really simple to read and write code. If you are looking for an easy Data Declarative then use XML. This allows you to load and initialize these before run time. In Doom 3 they had all of their data files as XML.

On a side not, we discussed file formats for objects that can be loaded in game. COLLADA only has about three engines use this format. I don't recommend using this and instead using fbx or obj formats. That's about all I wanted to say about the file types since I want to focus on scripting.

There's another style called Runtime. Examples of these are C and C++. It's nice because they are already compiled. Basically it takes a text file and it parses it. Then it has to convert it into some machine readable code. On typical machines they're all binary so it has to compile to assembly language. The reason for this is that assembly has a 1 to 1 for binary.

There are also interpreted languages. It has a just in time (JIT) compiler. It compiles while it runs rather than waiting for it to compile first. Here is a list of Interpreted languages.

Python
Java
and all other scripting languages listed above.

I like these interpreted languages because it minimizes the amount of initial compile time leaving more time for debugging. Java is half interpreted and half runtime.

The point of scripting is to remove the parts of C and C++ that coders don't like. Basically allows you to simply and quickly create gameplay code. A lot of the functionality of the scripting and it does not touch the engine code. The great thing about scripting is when you are tweaking small variables you don't have to recompile your engine everytime you do.

Python and LUA are most commonly used. Coders like Python the most because it's very C like. LUA is nice because it is very light weight so it doesn't take much compile time and your entire game could be written in LUA. It's free and has good licences. Every few month there are new updates coming out.

Interpreted, runtime, and Data Declared languages are the ones we need to focus on in this course since we need a runtime language for our engine and either an interpreted or data declared language for the scripting in the game.

There are other types of languages too. Here I have a small list of other language types plus some examples of these languages:

Procedural Languages

These languages are based on the concept of the unit and scope. This would have a long list such as C, Java, Perl, Python etc.

Functional Languages

LISP
F#
Haskell has a lot of multithreading capability.

Logic Based Languages

These languages specify a set of attributes that a solution must have, rather than a set of steps to obtain a solution such as ALF, Fril, Janus, and Leda.

Prolog Languages

These languages are genereal purpose logic programming languages associated with AI and computational linguistics.

GUI Programming Language

LegoLogo
Alice
.Net
Visual Basic
ShaderLang - insomniac

No comments:

Post a Comment