add app.get_content_sources, app.set_content_sources
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
#include "io/io.hpp"
|
||||
#include "io/devices/MemoryDevice.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
#include "content/ContentControl.hpp"
|
||||
#include "logic/scripting/scripting.hpp"
|
||||
|
||||
using namespace scripting;
|
||||
|
||||
static int l_create_memory_device(lua::State* L) {
|
||||
std::string name = lua::require_string(L, 1);
|
||||
@@ -18,8 +23,25 @@ static int l_create_memory_device(lua::State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_get_content_sources(lua::State* L) {
|
||||
const auto& sources = engine->getContentControl().getContentSources();
|
||||
lua::createtable(L, static_cast<int>(sources.size()), 0);
|
||||
for (size_t i = 0; i < sources.size(); i++) {
|
||||
lua::pushlstring(L, sources[i].string());
|
||||
lua::rawseti(L, static_cast<int>(i + 1));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_set_content_sources(lua::State* L) {
|
||||
engine->getContentControl().resetContentSources();
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg applib[] = {
|
||||
{"create_memory_device", lua::wrap<l_create_memory_device>},
|
||||
{"get_content_sources", lua::wrap<l_get_content_sources>},
|
||||
{"set_content_sources", lua::wrap<l_set_content_sources>},
|
||||
// see libcore.cpp an stdlib.lua
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user