mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-23 19:09:45 +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.
|
Called before world save.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
function on_world_tick()
|
function on_world_tick(tps)
|
||||||
```
|
```
|
||||||
|
|
||||||
Called 20 times per second
|
Called *tps* times per second
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
function on_world_quit()
|
function on_world_quit()
|
||||||
|
|
|
||||||
|
|
@ -141,10 +141,10 @@ function on_world_save()
|
||||||
Вызывается перед сохранением мира
|
Вызывается перед сохранением мира
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
function on_world_tick()
|
function on_world_tick(tps)
|
||||||
```
|
```
|
||||||
|
|
||||||
Вызывается 20 раз в секунду
|
Вызывается *tps* раз в секунду
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
function on_world_quit()
|
function on_world_quit()
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,9 @@ void scripting::on_world_tick(int tps) {
|
||||||
lua::pop(L);
|
lua::pop(L);
|
||||||
}
|
}
|
||||||
for (auto& pack : content_control->getAllContentPacks()) {
|
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