post-runnables
This commit is contained in:
@@ -184,6 +184,21 @@ _GUI_ROOT = Document.new("core:root")
|
|||||||
_MENU = _GUI_ROOT.menu
|
_MENU = _GUI_ROOT.menu
|
||||||
menu = _MENU
|
menu = _MENU
|
||||||
|
|
||||||
|
local __post_runnables = {}
|
||||||
|
|
||||||
|
function __process_post_runnables()
|
||||||
|
if #__post_runnables then
|
||||||
|
for _, func in ipairs(__post_runnables) do
|
||||||
|
func()
|
||||||
|
end
|
||||||
|
__post_runnables = {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function time.post_runnable(runnable)
|
||||||
|
table.insert(__post_runnables, runnable)
|
||||||
|
end
|
||||||
|
|
||||||
-- Deprecated functions
|
-- Deprecated functions
|
||||||
block_index = block.index
|
block_index = block.index
|
||||||
block_name = block.name
|
block_name = block.name
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ void Engine::mainloop() {
|
|||||||
postRunnables.front()();
|
postRunnables.front()();
|
||||||
postRunnables.pop();
|
postRunnables.pop();
|
||||||
}
|
}
|
||||||
|
scripting::process_post_runnables();
|
||||||
|
|
||||||
Window::swapBuffers();
|
Window::swapBuffers();
|
||||||
Events::pollEvents();
|
Events::pollEvents();
|
||||||
|
|||||||
@@ -97,6 +97,12 @@ std::unique_ptr<Environment> scripting::create_doc_environment(int parent, const
|
|||||||
return std::make_unique<Environment>(id);
|
return std::make_unique<Environment>(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scripting::process_post_runnables() {
|
||||||
|
if (state->getglobal("__process_post_runnables")) {
|
||||||
|
state->callNoThrow(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void scripting::on_world_load(Level* level, BlocksController* blocks) {
|
void scripting::on_world_load(Level* level, BlocksController* blocks) {
|
||||||
scripting::level = level;
|
scripting::level = level;
|
||||||
scripting::content = level->content;
|
scripting::content = level->content;
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ namespace scripting {
|
|||||||
std::unique_ptr<Environment> create_pack_environment(const ContentPack& pack);
|
std::unique_ptr<Environment> create_pack_environment(const ContentPack& pack);
|
||||||
std::unique_ptr<Environment> create_doc_environment(int parent, const std::string& name);
|
std::unique_ptr<Environment> create_doc_environment(int parent, const std::string& name);
|
||||||
|
|
||||||
|
void process_post_runnables();
|
||||||
|
|
||||||
void on_world_load(Level* level, BlocksController* blocks);
|
void on_world_load(Level* level, BlocksController* blocks);
|
||||||
void on_world_tick();
|
void on_world_tick();
|
||||||
void on_world_save();
|
void on_world_save();
|
||||||
|
|||||||
Reference in New Issue
Block a user