fix
This commit is contained in:
parent
9afe265094
commit
d163f12e67
@ -198,8 +198,8 @@ function __vc_start_app_script(path)
|
||||
error(err)
|
||||
end
|
||||
local script_env = setmetatable({app = app or __vc_app}, {__index=_G})
|
||||
setfenv(chunk, script_env)
|
||||
return start_coroutine(chunk, path)
|
||||
chunk = setfenv(chunk, script_env)
|
||||
return __vc_start_coroutine(chunk, path)
|
||||
end
|
||||
|
||||
gui_util = require "core:internal/gui_util"
|
||||
|
||||
@ -151,13 +151,10 @@ std::unique_ptr<IClientProjectScript> scripting::load_client_project_script(
|
||||
return std::make_unique<LuaProjectScript>(L, std::move(env));
|
||||
}
|
||||
|
||||
static std::unique_ptr<Process> start_lua_coroutine(
|
||||
const io::path& script, const std::string& method
|
||||
) {
|
||||
std::unique_ptr<Process> scripting::start_app_script(const io::path& script) {
|
||||
auto L = lua::get_main_state();
|
||||
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);
|
||||
@ -168,14 +165,6 @@ static std::unique_ptr<Process> start_lua_coroutine(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<Process> scripting::start_coroutine(const io::path& script) {
|
||||
return start_lua_coroutine(script, "__vc_start_coroutine");
|
||||
}
|
||||
|
||||
std::unique_ptr<Process> scripting::start_app_script(const io::path& script) {
|
||||
return start_lua_coroutine(script, "__vc_start_app_script");
|
||||
}
|
||||
|
||||
[[nodiscard]] scriptenv scripting::get_root_environment() {
|
||||
return std::make_shared<int>(0);
|
||||
}
|
||||
|
||||
@ -76,7 +76,6 @@ 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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user