minor refactor

This commit is contained in:
MihailRis 2025-08-01 22:00:29 +03:00
parent 2c60e7c6ae
commit 9e8acac783
4 changed files with 8 additions and 7 deletions

View File

@ -510,8 +510,8 @@ function __vc_on_world_open()
end
end
function __vc_on_world_tick()
time.schedules.world:tick(1.0 / 20.0)
function __vc_on_world_tick(tps)
time.schedules.world:tick(1.0 / tps)
end
function __vc_on_world_save()
@ -683,4 +683,4 @@ function dofile(path)
end
end
return _dofile(path)
end
end

View File

@ -127,7 +127,7 @@ void BlocksController::update(float delta, uint padding) {
onBlocksTick(blocksTickClock.getPart(), blocksTickClock.getParts());
}
if (worldTickClock.update(delta)) {
scripting::on_world_tick();
scripting::on_world_tick(worldTickClock.getTickRate());
}
}

View File

@ -297,10 +297,11 @@ void scripting::on_world_load(LevelController* controller) {
}
}
void scripting::on_world_tick() {
void scripting::on_world_tick(int tps) {
auto L = lua::get_main_state();
if (lua::getglobal(L, "__vc_on_world_tick")) {
lua::call_nothrow(L, 0, 0);
lua::pushinteger(L, tps);
lua::call_nothrow(L, 1, 0);
}
for (auto& pack : content_control->getAllContentPacks()) {
lua::emit_event(L, pack.id + ":.worldtick");

View File

@ -70,7 +70,7 @@ namespace scripting {
);
void on_world_load(LevelController* controller);
void on_world_tick();
void on_world_tick(int tps);
void on_world_save();
void on_world_quit();
void cleanup();