| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- module scripts.lua.hbs;
- import bindbc.lua;
- import raylib;
- import variables;
- import std.conv;
- import system.debugwriteln;
- import std.file;
- import scripts.hbs;
- // please do not run this inside loop, it will break everything
- extern (C) nothrow int luaL_loadHbsScript(lua_State *L) {
- try {
- hbsExec = to!string(luaL_checkstring(L, 1));
- ubyte[] data = cast(ubyte[])read(hbsExec);
- if (std.file.exists(hbsExec~".scene")) {
- debugWriteln("hbs scene file found, loading");
- hbsSceneData = cast(ubyte[])read(hbsExec~".scene");
- }
- loader(data);
- parser(data);
- } catch (Exception e) {
- debugWriteln("error in loadhbsscript");
- }
- return 0;
- }
- extern (C) nothrow int luaL_runHbsScript(lua_State *L) {
- try {
- hbsCalled = true;
- debugWriteln("HBS executed");
- } catch (Exception e) {
- debugWriteln("error in loadhbsscript");
- }
- return 0;
- }
- extern (C) nothrow int luaL_getValueFromHbss(lua_State *L) {
- lua_pushnumber(L, scriptVariables[luaL_checkinteger(L, 1)]);
- return 1;
- }
|