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?

1

3 Answers 3

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.

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.

7
  • 1
    Some games allow end-users to implement their own scripts. Alongside with the public API, users can implement addons, widgets, etc, that react to the game events.
    – Laiv
    Feb 3, 2018 at 8:00
  • 1
    I was thinking in MMO rpgs :-)
    – Laiv
    Feb 3, 2018 at 8:13
  • 1
    @Laiv IMO MMORPGs are one of those things that seem so fun to implement, but similar to playing them for a long time, it turns into such a grind. The game world has to be so static typically or there has to be such an active involvement from the game moderators. I think offline games are so, so much more fun to develop because you can create a very dynamic world with a story that actually comes to an end.
    – user204677
    Feb 3, 2018 at 8:15
  • 1
    No no. Years ago I used to play Allods Online. The game had a little API for gamers to implement addons and widgets. Just wanted to expand your answer with some examples :-)
    – Laiv
    Feb 3, 2018 at 8:16
  • 1
    @Laiv Oh I see! I'm in the process of deleting my account but I edited my answer to make it shorter and sweeter. In the process I lost a little bit of information but my previous edit talked about how I used the scripting personally. Right now I'm trying to edit out all the personal information from my answers.
    – user204677
    Feb 3, 2018 at 8:17
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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