| 1234567891011121314151617181920212223242526272829303132333435 |
- module scripts.lua.overlay;
- import system.debugwriteln;
- import system.overlay;
- import bindbc.lua;
- import core.sys.posix.sys.mman;
- import std.conv;
- import variables;
- void function() overlayInit;
- extern (C) nothrow int luaL_loadOverlay(lua_State *L) {
- try {
- code = loadOverlay(to!string(luaL_checkstring(L, 1)), &size);
- if (code is null) return 1;
- overlayInit = cast(void function())code;
- } catch (Exception e) {
- debugWriteln(e.msg);
- }
- return 0;
- }
- extern (C) nothrow int luaL_unloadOverlay(lua_State *L) {
- munmap(code, size);
- return 0;
- }
- extern (C) nothrow int luaL_runOverlay(lua_State *L) {
- try {
- overlayInit();
- } catch (Exception e) {
- debugWriteln(e.msg);
- }
- return 0;
- }
|