hbs.d 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. module scripts.lua.hbs;
  2. import bindbc.lua;
  3. import raylib;
  4. import variables;
  5. import std.conv;
  6. import system.debugwriteln;
  7. import std.file;
  8. import scripts.hbs;
  9. // please do not run this inside loop, it will break everything
  10. extern (C) nothrow int luaL_loadHbsScript(lua_State *L) {
  11. try {
  12. hbsExec = to!string(luaL_checkstring(L, 1));
  13. ubyte[] data = cast(ubyte[])read(hbsExec);
  14. if (std.file.exists(hbsExec~".scene")) {
  15. debugWriteln("hbs scene file found, loading");
  16. hbsSceneData = cast(ubyte[])read(hbsExec~".scene");
  17. }
  18. loader(data);
  19. parser(data);
  20. } catch (Exception e) {
  21. debugWriteln("error in loadhbsscript");
  22. }
  23. return 0;
  24. }
  25. extern (C) nothrow int luaL_runHbsScript(lua_State *L) {
  26. try {
  27. hbsCalled = true;
  28. debugWriteln("HBS executed");
  29. } catch (Exception e) {
  30. debugWriteln("error in loadhbsscript");
  31. }
  32. return 0;
  33. }
  34. extern (C) nothrow int luaL_getValueFromHbss(lua_State *L) {
  35. lua_pushnumber(L, scriptVariables[luaL_checkinteger(L, 1)]);
  36. return 1;
  37. }