townengine/apps/twnlua
2025-02-17 10:57:31 +03:00
..
data /apps/twnlua: ctx.udata preservation in reload, no export in .so, ignore /data/scripts/twnapi.lua 2025-02-15 22:19:14 +03:00
.gitignore /apps/twnlua: ctx.udata preservation in reload, no export in .so, ignore /data/scripts/twnapi.lua 2025-02-15 22:19:14 +03:00
bindgen.py /apps/twnlua: ctx.udata preservation in reload, no export in .so, ignore /data/scripts/twnapi.lua 2025-02-15 22:19:14 +03:00
CMakeLists.txt /apps/twnlua: fix for windows, parametrize newstate for alloc func 2025-02-17 10:39:10 +03:00
docgen.py disable lua server diagnostics in twnapi.lua 2025-02-14 20:43:11 +03:00
game.c minilua.h: revert changes, realized that lua_newstate is public 2025-02-17 10:57:31 +03:00
minilua.h minilua.h: revert changes, realized that lua_newstate is public 2025-02-17 10:57:31 +03:00
README.md /apps/twnlua: use minilua single source amalgam 2025-01-29 01:24:58 +03:00
state.h /apps/twnlua: fix for windows, parametrize newstate for alloc func 2025-02-17 10:39:10 +03:00

MiniLua

This is Lua contained in a single header to be bundled in C/C++ applications with ease. Lua is a powerful, efficient, lightweight, embeddable scripting language.

Example Usage

#define LUA_IMPL
#include "minilua.h"

int main() {
  lua_State *L = luaL_newstate();
  if(L == NULL)
    return -1;
  luaL_openlibs(L);
  luaL_loadstring(L, "print 'hello world'");
  lua_call(L, 0, 0);
  lua_close(L);
  return 0;
}

Usage

Copy minilua.h into your C or C++ project, include it anywhere you want to use Lua API. Then do the following in one C file to implement Lua:

#define LUA_IMPL
#include "minilua.h"

By default it detects the system platform to use, however you can explicitly define one.

Note that almost no modification was made in the Lua implementation code, thus there are some C variable names that may collide with your code, therefore it is best to declare the Lua implementation in dedicated C file.

Optionally provide the following defines:

  • LUA_MAKE_LUA - implement the Lua command line REPL

Documentation

For documentation on how to use Lua read its official manual.

Updates

  • 25-Jul-2024: Updated to Lua 5.4.7.
  • 13-Nov-2023: Updated to Lua 5.4.6.
  • 28-Jan-2022: Updated to Lua 5.4.4.
  • 31-Mar-2021: Updated to Lua 5.4.3.
  • 03-Dec-2020: Updated to Lua 5.4.2.
  • 27-Nov-2020: Library created, using Lua 5.4.2-rc1.

Notes

This library tries to keep up with latest official Lua release. The header is generated using the bash script gen.sh all modifications done is there.

License

Same license as Lua, the MIT license, see LICENSE.txt for information.