Game Engine Scripting Languages
Asked Answered
M

9

5

I am trying to build out a useful 3d game engine out of the Ogre3d rendering engine for mocking up some of the ideas i have come up with and have come to a bit of a crossroads. There are a number of scripting languages that are available and i was wondering if there were one or two that were vetted and had a proper following.

LUA and Squirrel seem to be the more vetted, but im open to any and all.

Optimally it would be best if there were a compiled form for the language for distribution and ease of loading.

Moonlight answered 17/9, 2008 at 21:32 Comment(1)
One advantage of squirrel is the memory management. It uses a reference counting algorithm combined with a GC. That gives a very stable realtime behaviour (CPU bursts free) See DocuIngratitude
T
5

The Python/C API manual is longer than the whole Lua manual (including the Lua/C API).

Another reason for Lua is the built-in support for coroutines (co-operative multitasking within the one OS thread). It allows one to have like 1000's of seemingly individual scripts running very fast alongside each other. Like one script per monster/weapon or so.

( Why do people write Lua in upper case so much on SO? It's "Lua" (see here). )

Turnout answered 17/9, 2008 at 22:4 Comment(0)
G
6

The syntax is a matter of taste, Lua is like Javascript but with curly braces replaced with Pascal-like keywords. It has the nice syntactic feature that semicolons are never required but whitespace is still not significant, so you can even remove all line breaks and have it still work. As someone who started with C I'd say Python is the one with esoteric syntax compared to all the other languages.

LuaJIT is also around 10 times as fast as Python and the Lua interpreter is much much smaller (150kb or around 15k lines of C which you can actually read through and understand). You can let the user script your game without having to embed a massive language. On the other hand if you rip the parser part out of Lua it becomes even smaller.

Grocer answered 17/9, 2008 at 21:52 Comment(0)
L
6

One interesting option is stackless-python. This was used in the Eve-Online game.

Laurencelaurene answered 17/9, 2008 at 21:54 Comment(0)
T
5

The Python/C API manual is longer than the whole Lua manual (including the Lua/C API).

Another reason for Lua is the built-in support for coroutines (co-operative multitasking within the one OS thread). It allows one to have like 1000's of seemingly individual scripts running very fast alongside each other. Like one script per monster/weapon or so.

( Why do people write Lua in upper case so much on SO? It's "Lua" (see here). )

Turnout answered 17/9, 2008 at 22:4 Comment(0)
N
1

One more vote for Lua. Small, fast, easy to integrate, what's important for modern consoles - you can easily control its memory operations.

Newfoundland answered 17/9, 2008 at 22:14 Comment(0)
G
0

I'd go with Lua since writing bindings is extremely easy, the license is very friendly (MIT) and existing libraries also tend to be under said license. Scheme is also nice and easy to bind which is why it was chosen for the Gimp image editor for example. But Lua is simply great. World of Warcraft uses it, as a very high profile example. LuaJIT gives you native-compiled performance. It's less than an order of magnitude from pure C.

Grocer answered 17/9, 2008 at 21:34 Comment(0)
A
0

I wouldn't recommend LUA, it has a peculiar syntax so takes some time to get used to. Depending on who will be doing the scripting, this may not be a problem, but I would try to use something fairly accessible.

I would probably choose python. It normally compiles to bytecode, so you would need to embed the interpreter. However, if you must you can use PyPy to for example translate the code to C, and then compile it.

Amblyopia answered 17/9, 2008 at 21:42 Comment(0)
M
0

Embedding the interpreter is no issue. I am more interested in features and performance at this point in time. LUA and Squirrel are both interpreted, which is nice because one of the games i am building out is to include modifiable code, which has an editor in game.

I would love to hear about python, as i have seen its use within the battlefield series i believe.

Moonlight answered 17/9, 2008 at 21:47 Comment(0)
V
0

python is also nice because it has actual OGRE bindings, just in case you need to modify something lower-level on the fly. I don't know of any equivalent bindings for Lua.

Vladi answered 26/4, 2011 at 7:1 Comment(0)
M
0

Since it's a C++ library, I would suggest either JavaScript or Squirrel, the latter being my personal favorite of the two for being even closer to C++, in particular to how it handles tables/structs and classes. It would be the easiest to get used to for a C++ coder because of all the similarities.

However, if you go with JavaScript and find an HTML5 version of Ogre3D, you should be able to port your game code directly into the web version with minimal (if any) changes necessary.

Both of these are a good choice, and both have their pros and cons, but both would definitely be the easiest to learn since you're likely already working in C++. If you're working with Java, the same may hold true, and if it's Game Maker, you wouldn't need either one unless you're trying to make an executable that people wouldn't need Game Maker itself to run, in which case, good luck finding an extension to run either of these.

Membranous answered 12/9, 2015 at 22:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.