forked from Kolyah35/minecraft-pe-0.6.1
1
This commit is contained in:
@@ -20,6 +20,8 @@ public:
|
||||
|
||||
void loadPlugins();
|
||||
|
||||
sol::state& getLua() { return m_lua; }
|
||||
|
||||
// @ai @note maybe we should rewrite it...
|
||||
// problem that i dont know how to pass args in sol::function dynamically
|
||||
// so i used ai
|
||||
@@ -38,11 +40,29 @@ public:
|
||||
std::cout << err.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
int emitCommands(std::string event, Args&&... args) {
|
||||
auto it = m_luaCommands.find(event);
|
||||
|
||||
if (it == m_luaCommands.end()) return 1;
|
||||
|
||||
for (auto& callback : it->second) {
|
||||
sol::protected_function_result result = callback(std::forward<Args>(args)...);
|
||||
|
||||
if (!result.valid()) {
|
||||
sol::error err = result;
|
||||
std::cout << err.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Minecraft* getMinecraft() { return m_minecraft; }
|
||||
private:
|
||||
std::unordered_map<std::string, std::vector<sol::function>> m_callbacks;
|
||||
std::unordered_map<std::string, std::vector<sol::function>> m_luaCommands;
|
||||
|
||||
LuaServer m_srv;
|
||||
sol::state m_lua;
|
||||
|
||||
Reference in New Issue
Block a user