mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
minor refactor
This commit is contained in:
parent
2c60e7c6ae
commit
9e8acac783
4 changed files with 8 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue