Lua or Flow: which do I use?

With Stingray, you have the choice between two primary ways of setting up interactive gameplay: Flow visual programming, and Lua scripting. You are free to choose either, or you can use both in tandem. So how do you choose?

The answer really depends on a number of factors that are specific to your project design and the team you work in. For example, the size and style of your project, the size of the team, your level of programming experience and experience working in other game engines.

This page provides some food for thought as you plan out your approach to authoring gameplay.

Flow is a great choice because:

The biggest downsides of Flow are:

Lua is a great choice because:

The biggest downsides of Lua are:

The best choice of all:

Using both Lua and Flow together in combination, you can take advantage of the strengths of both approaches.

This offers the best of both worlds. Your game designers benefit from the ability to construct interactive experiences out of building blocks without going to the deepest level of programming logic. They can also prototype creative new gameplay ideas on their own in Flow, and hand off to programmers for polishing, improvements to the algorithms or performance, or to make future maintenance easier. Meanwhile, your programmers benefit from the wider API available in Lua, the familiar scripting environment, and the possibility to use standard development tools like Visual Studio Code to debug the behavior.

See also Communicating between Flow and Lua.

What about C?

If you are an experienced programmer, you may want to use custom C or C++ code in your project. C code will typically run faster, so it can be useful for times where performance is key. Also, you may want to integrate third-party libraries or re-use existing C code.

If you can package your code into a dynamically linked library, you may be able to make Lua bindings for your functions, which you can call from your game's Lua environment. Or, you may be able to use the LuaJIT FFI library to call the C functions directly from your Lua code. For details, see Calling C code from Lua and its sub-topics.

Alternatively, you may be able to use the native plug-in APIs exposed by the Stingray engine to write your own engine-level plug-in. This currently requires access to the Stingray source repositories; contact an Autodesk representative for details. See also the Stingray Developer Help.