9

I've read that Lua is often used for embedded scripting and in particular game for scripting. I find it hard to picture how it is used exactly. Can you describe why and for which features and for which audience it is used?

This questions isn't specifically addressing Lua, but rather any embedded scripting that serves a purpose similar to Lua scripting.

Is it used for end-users to make custom adjustments? Is it used for game developers to speed up creation of game logic (levels, AI, ...)? Is it used to script game framework code since scripting can be faster?

Basically I'm wondering how deep between plain configuration and framework logic such scripting usage goes. And how much scripting is done. A few configuration lines or a considerable amount?

Gere
  • 2,231

3 Answers3

11

A scripting language in a game engine is there to expose your game engine in a higher-level, interpreted manner.

Take a game like Skyrim, for example. You'll notice that there are many quests and interactions that occur, and some of these have fairly impressive logic built into them, such as a guard reacting to you getting to close to an item during some scene. These are things would be difficult to express in a pure data format, and for this reason, quests and custom behaviours are typically expressed as scripts.

There are also many practicalities to consider - the game designers who create these scripts often work at a higher level of abstraction than the game engine coders; they do not want to be worrying about memory allocation, etc. A scripting language is a good fit for them, and with LUA, they're typically calling into a nice high level facade of the engine. You also don't want to recompile your game every time you want to adjust some minute attribute in a script.

On top of all of this, they allow for easy debugging, modding, and all the other nice things you mentioned.

Daniel B
  • 6,204
  • 1
  • 24
  • 30
3

Is it used for end-users to make custom adjustments?

It can be used for a wide range of purposes from just configs to implementing the bulk of the game's high-end logic, e.g. It depends on the game, but Lua is just embedded scripting. People can use that as much or as little as they want.

2

It can be used by people other than original game programmers to modify or extend game logic. Such people can be relatively non-technical, e.g. game designers or end-users (gamers).

Scripts are usually higher-level languages and as such Lua is easier than C++. Code written in scripts can usually be modified without recompiling the main application (game engine) which is useful for game designers to tweak game scenes quickly.

PS: better ask this question on gamedev.stackexchange.com

Den
  • 4,877