Using Lua scripts with C++

This page summarizes the projects mentioned and recommended in the original post on /r/gamedev

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • wesnoth

    An open source, turn-based strategy game with a high fantasy theme.

  • In my game I made a Singleton Lua VM class, made a wrapper class (for AI). So when an object is created its component (the AI class) preloads its special script for the object. I exported C/C++ functions to lua VM (such as getPosition, getPlayerPosition, checkCollideTile, ... ) So those functions can be called from the script. Implemented AI::getActions (a C++ function), which "asks" LuaVM to run an update function (from the preload script) for the object. I hope it all make sense. P.S. Keep in mind you can significantly improve your productivity if you use a game engine. Also You can look at FOSS games which use Lua for scripting (i.e, wesnoth: https://github.com/wesnoth/wesnoth )

  • LuaJIT

    Mirror of the LuaJIT git repository

  • Lua is perfectly capable for providing scripting support, both to support mods, or to write gameplay logic. Because of that, it's used in plenty many places. The core engine code can be C/C++, and this is what something like Love2D does, for example. For performance, you can use LuaJIT, if vanilla lua doesn't do it for you.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts