6
\$\begingroup\$

Often, a game is split into engine code (i.e. C++) and scripts (i.e. Lua).

Which parts / modules of game code should typically belong to engine, and which should belong typically to script-domain code?

For example: AI for characters is typically put in scripts. What about GUI, sound, asset / resource management, levels / maps, quests etc?

\$\endgroup\$
1

3 Answers 3

2
\$\begingroup\$

Whatever's most amenable to encapsulation or is already well specified - and thus well encapsulated - in C++ classes / functions, i.e. exists behind a stable, solid interface.

Aspects that are ever-changing, and aspects that are coded at a low level and need fine control like rendering and low-level network code, are poor candidates for scripting. It depends on just how much control you need, and at just what level. Once the need for control and speed becomes too great, you'll gain little out of wrapping that logic in script, and in fact may stand to lose performance due to the overheads of making scripting calls, even with a nice fast scripting engine like LuaJIT.

Yes, all the things you list are good candidates, though again, you'll probably do some work on each front to improve your interface to the C++ that your relevant scripts will call into. Something like sound would be a nice, easy place to start. Start where your code is already most stable.

\$\endgroup\$
1
\$\begingroup\$

What about GUI, sound, asset / resource management, levels / maps, quests etc.?

These are all good candidates for scripts. Most of the game can typically be written in a scripting language. Typically the only thing that may require being written in the core language (C, C++, C#, Java, etc) is anything that is performance critical or core game algorithms. It allows for faster development as changing scripts doesnt require a rebuild of the game. This answer has a bunch more information on scripts vs core language

\$\endgroup\$
1
\$\begingroup\$

It does not matter what you handle in Lua. Almost everything in a game engine can be handled explicitly via Lua. All that matters in the end is what you want to do with the language.

For example, when desiging your game:

  • You can choose to use Lua only for scripting AI. C++ will then have a call back for events and data to be handled via Lua. (Cry Engine)
  • You can choose to have Lua directly call to low level systems in your engine. (Love2D, Polycode)
  • You can choose to literally write almost everything in Lua, with the exception of a few key systems: Rendering, threading API, etc. (The Legend of Grimrock I and II)

Just do what ever you feel is necessary, the easiest, or convenient to you.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .