mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 01:49:44 +00:00
Merge pull request #1045 from MihailRis/update-on-world-tick
add 'tps' argument to on_world_tick event
This commit is contained in:
commit
5f86068431
3 changed files with 8 additions and 6 deletions
|
|
@ -137,10 +137,10 @@ function on_world_save()
|
|||
Called before world save.
|
||||
|
||||
```lua
|
||||
function on_world_tick()
|
||||
function on_world_tick(tps)
|
||||
```
|
||||
|
||||
Called 20 times per second
|
||||
Called *tps* times per second
|
||||
|
||||
```lua
|
||||
function on_world_quit()
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ function on_block_break_by(x: int, y: int, z: int, playerid: int)
|
|||
|
||||
Вызывается при нажатии ЛКМ на блок (в т.ч неразрушимый). Предотвращает разрушение блока, если возвращает `true`
|
||||
|
||||
## События мира
|
||||
## События мира
|
||||
|
||||
События мира для контент-пака прописываются в `scripts/world.lua`
|
||||
|
||||
|
|
@ -141,10 +141,10 @@ function on_world_save()
|
|||
Вызывается перед сохранением мира
|
||||
|
||||
```lua
|
||||
function on_world_tick()
|
||||
function on_world_tick(tps)
|
||||
```
|
||||
|
||||
Вызывается 20 раз в секунду
|
||||
Вызывается *tps* раз в секунду
|
||||
|
||||
```lua
|
||||
function on_world_quit()
|
||||
|
|
|
|||
|
|
@ -345,7 +345,9 @@ void scripting::on_world_tick(int tps) {
|
|||
lua::pop(L);
|
||||
}
|
||||
for (auto& pack : content_control->getAllContentPacks()) {
|
||||
lua::emit_event(L, pack.id + ":.worldtick");
|
||||
lua::emit_event(L, pack.id + ":.worldtick", [tps](lua::State* L) {
|
||||
return lua::pushinteger(L, tps);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue