mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 14:03:26 +02:00
implement API to save lists in configs file and terminal history
This commit is contained in:
@@ -125,6 +125,9 @@ luavalue_cast(int index, std::function<Ret(Args...)>& func);
|
||||
template<typename T>
|
||||
void push_luavalue(const std::vector<T>& vec);
|
||||
|
||||
template<typename T>
|
||||
bool luavalue_cast(int index, std::vector<T>& vec);
|
||||
|
||||
// deque
|
||||
template<class T>
|
||||
void push_luavalue(const std::deque<T>& vec);
|
||||
@@ -249,6 +252,22 @@ void push_luavalue(const std::vector<T>& vec) {
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool luavalue_cast(int index, std::vector<T>& vec)
|
||||
{
|
||||
if(g_lua.isTable(index)) {
|
||||
g_lua.pushNil();
|
||||
while(g_lua.next(index < 0 ? index-1 : index)) {
|
||||
T value;
|
||||
if(luavalue_cast(-1, value))
|
||||
vec.push_back(value);
|
||||
g_lua.pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void push_luavalue(const std::deque<T>& vec) {
|
||||
g_lua.newTable();
|
||||
|
Reference in New Issue
Block a user