lua: hud library
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#include "libhud.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "../scripting.h"
|
||||
#include "../../../frontend/hud.h"
|
||||
|
||||
namespace scripting {
|
||||
extern Hud* hud;
|
||||
}
|
||||
|
||||
int l_hud_open_inventory(lua_State* L) {
|
||||
scripting::hud->openInventory();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l_hud_close_inventory(lua_State* L) {
|
||||
scripting::hud->closeInventory();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef LOGIC_SCRIPTING_API_LIBHUD_H_
|
||||
#define LOGIC_SCRIPTING_API_LIBHUD_H_
|
||||
|
||||
#include <lua.hpp>
|
||||
|
||||
extern int l_hud_open_inventory(lua_State* L);
|
||||
extern int l_hud_close_inventory(lua_State* L);
|
||||
|
||||
static const luaL_Reg hudlib [] = {
|
||||
{"open_inventory", l_hud_open_inventory},
|
||||
{"close_inventory", l_hud_close_inventory},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
#endif // LOGIC_SCRIPTING_API_LIBHUD_H_
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class LuaState;
|
||||
|
||||
class Engine;
|
||||
class Content;
|
||||
struct ContentPack;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "scripting_frontend.h"
|
||||
#include "scripting.h"
|
||||
|
||||
#include "api/libhud.h"
|
||||
#include "LuaState.h"
|
||||
|
||||
namespace scripting {
|
||||
extern lua::LuaState* state;
|
||||
}
|
||||
|
||||
Hud* scripting::hud = nullptr;
|
||||
|
||||
void scripting::on_frontend_init(Hud* hud) {
|
||||
scripting::hud = hud;
|
||||
scripting::state->openlib("hud", hudlib, 0);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef LOGIC_SCRIPTING_SCRIPTING_FRONTEND_H_
|
||||
#define LOGIC_SCRIPTING_SCRIPTING_FRONTEND_H_
|
||||
|
||||
class Hud;
|
||||
|
||||
namespace scripting {
|
||||
extern Hud* hud;
|
||||
|
||||
void on_frontend_init(Hud* hud);
|
||||
}
|
||||
|
||||
#endif // LOGIC_SCRIPTING_SCRIPTING_FRONTEND_H_
|
||||
Reference in New Issue
Block a user