summaryrefslogtreecommitdiff
path: root/src/main.c
blob: c989dbdafb87d60f8bd0ac0d8fcf783b7ff56458 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <honeysuckle.h>
#include "gl/gl.h"


int main(int argc, char **argv)
{
	lua_State *L = luaL_newstate();
	luaL_openlibs(L);

	lua_createtable(L, 0, 2);
	int honey_index = lua_gettop(L);
	setup_gl(L, honey_index);
	setup_window(L, honey_index);
	lua_setglobal(L, "honey");

	int err = luaL_loadfile(L, "honey.lua");
	if (err != 0) {
		printf("cannot open file!\n");
		lua_close(L);
		return 0;
	}
	err = hs_call(L, 0, 0);
	if (err != 0) {
		const char *err_str = lua_tostring(L, -1);
		printf("failed to run: \n%s\n", err_str);
	}
	lua_close(L);
	return 0;
}