Manipulate structs from lua using userdata, these guides https://lua-users.org/wiki/UserDataExample and https://lua-users.org/wiki/UserDataWithPointerExample explains how but they are outdated. Recent versions of Lua does not have the luaL_openlib
or luaL_register
functions, consequently, you have to do it manually.
#include <stdlib.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"