Game engine script languages

I am trying to create a useful 3D game engine from the Ogre3d rendering engine to mock some ideas that I came up with and moved to the crossroads. There are several scripting languages ​​that are available, and I was wondering if there was one or two that were tested and followed correctly.

LUA and Squirrel seem more proven, but they are open to everyone and everyone.

Optimally, it would be better if there was a compiled form for the language for distribution and ease of download.

+4
source share
9 answers

Syntax is a matter of taste, Lua is similar to Javascript, but with curly braces replaced by Pascal-like keywords. It has a nice syntax function in which semicolons are never required, but spaces are still not significant, so you can even delete all line breaks and still work. As someone who started with C, I would say that Python is one that has esoteric syntax compared to all other languages.

LuaJIT is also about 10 times faster than Python, and the Lua interpreter is much smaller (150kb or about 15k C lines that you can really read and understand). You can let the user script your game without inserting a massive language. On the other hand, if you pull out the parser part from Lua, it will become even smaller.

+5
source

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

+6
source

The Python / C API Guide is the longest of the Lua Guide (including the Lua / C API).

Another reason for Lua is its built-in support for coroutines (collaborative multitasking within a single OS thread). This allows you to have about 1000 seemingly individual scripts that work very quickly next to each other. Like one script per monster / weapon or so.

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

+4
source

Another vote for Lua. Small, fast, easy to integrate, which is important for modern consoles - you can easily manage your memory operations.

+1
source

I would go with Lua, since writing bindings is very simple, the license is very friendly (MIT), and existing libraries also tend to be under the specified license. The circuit is also good and easy to bind, so it was chosen, for example, for the Gimp image editor. But Lua is just great. World of Warcraft uses it as an example of a very high profile. LuaJIT gives you compiled performance. This is less than an order of magnitude from pure C.

0
source

I would not recommend LUA, it has a peculiar syntax, so it takes some time to get used to. Depending on who writes the scripts, this may not be a problem, but I would try to use something rather affordable.

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

0
source

Implementing an interpreter is not a problem. At the moment, I'm more interested in features and performance. LUA and Squirrel are interpreted, which is nice because one of the games that I compile includes modifiable code that has an editor in the game.

I would love to hear about python since I saw its use in a series of battles that I believe in.

0
source

python is also good because it has real OGRE bindings, just in case you need to change something lower on the fly. I do not know any equivalent bindings for Lua.

0
source

Since this is a C ++ library, I would suggest either JavaScript or Squirrel, the last of which was my personal favorite of the two, to be even closer to C ++, in particular, to how it handles tables / structures and classes. This would be easiest to use for a C ++ encoder due to all the similarities.

However, if you navigate using JavaScript and find the Ogre3D version for HTML5, you will need to transfer your game code directly to the web version with minimal (if any) changes.

Both of them are a good choice, and both have their pros and cons, but both will certainly be the easiest to master, since you are probably already working in C ++. If you work with Java, then this may be true, and if it is Game Maker, you will not need one if you do not try to make an executable file so that people can not run Game Maker, in which case, good luck finding an extension to run any of them.

0
source

Source: https://habr.com/ru/post/1276829/


All Articles