Merge branch 'dev' into generated-pcm-stream
This commit is contained in:
@@ -32,8 +32,7 @@ void ServerMainloop::run() {
|
||||
setLevel(std::move(level));
|
||||
});
|
||||
|
||||
logger.info() << "starting test " << coreParams.scriptFile.string();
|
||||
auto process = scripting::start_coroutine(
|
||||
auto process = scripting::start_app_script(
|
||||
"script:" + coreParams.scriptFile.filename().u8string()
|
||||
);
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "graphics/ui/gui_util.hpp"
|
||||
#include "graphics/ui/markdown.hpp"
|
||||
#include "graphics/core/Font.hpp"
|
||||
#include "content/Content.hpp"
|
||||
#include "content/ContentPack.hpp"
|
||||
#include "items/Inventories.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
#include "world/Level.hpp"
|
||||
@@ -1027,13 +1029,17 @@ static int l_gui_load_document(lua::State* L) {
|
||||
io::path filename = lua::require_string(L, 1);
|
||||
auto alias = lua::require_string(L, 2);
|
||||
auto args = lua::tovalue(L, 3);
|
||||
|
||||
auto prefix = filename.entryPoint();
|
||||
|
||||
auto env = scripting::get_root_environment();
|
||||
if (content) {
|
||||
if (auto runtime = content->getPackRuntime(prefix)) {
|
||||
env = runtime->getEnvironment();
|
||||
}
|
||||
}
|
||||
|
||||
auto documentPtr = UiDocument::read(
|
||||
engine->getGUI(),
|
||||
scripting::get_root_environment(),
|
||||
alias,
|
||||
filename,
|
||||
filename.string()
|
||||
engine->getGUI(), std::move(env), alias, filename, filename.string()
|
||||
);
|
||||
auto document = documentPtr.get();
|
||||
engine->getAssets()->store(std::move(documentPtr), alias);
|
||||
|
||||
@@ -150,12 +150,10 @@ std::unique_ptr<IClientProjectScript> scripting::load_client_project_script(
|
||||
return std::make_unique<LuaProjectScript>(L, std::move(env));
|
||||
}
|
||||
|
||||
std::unique_ptr<Process> scripting::start_coroutine(const io::path& script) {
|
||||
std::unique_ptr<Process> scripting::start_app_script(const io::path& script) {
|
||||
auto L = lua::get_main_state();
|
||||
auto method = "__vc_start_coroutine";
|
||||
if (lua::getglobal(L, method)) {
|
||||
auto source = io::read_string(script);
|
||||
lua::loadbuffer(L, 0, source, script.name());
|
||||
if (lua::getglobal(L, "__vc_start_app_script")) {
|
||||
lua::pushstring(L, script.string());
|
||||
if (lua::call(L, 1)) {
|
||||
int id = lua::tointeger(L, -1);
|
||||
lua::pop(L, 1);
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace scripting {
|
||||
const io::path& script
|
||||
);
|
||||
|
||||
std::unique_ptr<Process> start_coroutine(const io::path& script);
|
||||
std::unique_ptr<Process> start_app_script(const io::path& script);
|
||||
|
||||
void on_world_load(LevelController* controller);
|
||||
void on_world_tick(int tps);
|
||||
|
||||
Reference in New Issue
Block a user