Skip to content

Commit

Permalink
clarify the set_interval frames counting
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed Sep 2, 2023
1 parent c3c6f8e commit 747165c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion docs/game_data/spel2.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion docs/src/includes/_globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,12 @@ end, 60)
#### [CallbackId](#Aliases) set_interval(function cb, int frames)

Returns unique id for the callback to be used in [clear_callback](#clear_callback). You can also return `false` from your function to clear the callback.
Add per level callback function to be called every `frames` engine frames. Timer is paused on pause and cleared on level transition.
Add per level callback function to be called every `frames` engine frames
Ex. frames = 100 - will call the function on 100th frame from this point. This might differ in the exact timing of first frame depending as in what part of the frame you call this function
or even be one frame off if called right before the time_level variable is updated
If you require precise timing, choose the start of your interval in one of those safe callbacks:
The [SCREEN](#SCREEN) callbacks: from [ON](#ON).LOGO to [ON](#ON).ONLINE_LOBBY or custom callbacks [ON](#ON).FRAME, [ON](#ON).[SCREEN](#SCREEN), [ON](#ON).START, [ON](#ON).LOADING, [ON](#ON).RESET, [ON](#ON).POST_UPDATE
Timer is paused on pause and cleared on level transition.

### set_on_player_instagib

Expand Down
7 changes: 6 additions & 1 deletion src/game_api/script/lua_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,12 @@ end
};

/// Returns unique id for the callback to be used in [clear_callback](#clear_callback). You can also return `false` from your function to clear the callback.
/// Add per level callback function to be called every `frames` engine frames. Timer is paused on pause and cleared on level transition.
/// Add per level callback function to be called every `frames` engine frames
/// Ex. frames = 100 - will call the function on 100th frame from this point. This might differ in the exact timing of first frame depending as in what part of the frame you call this function
/// or even be one frame off if called right before the time_level variable is updated
/// If you require precise timing, choose the start of your interval in one of those safe callbacks:
/// The SCREEN callbacks: from ON.LOGO to ON.ONLINE_LOBBY or custom callbacks ON.FRAME, ON.SCREEN, ON.START, ON.LOADING, ON.RESET, ON.POST_UPDATE
/// Timer is paused on pause and cleared on level transition.
lua["set_interval"] = [](sol::function cb, int frames) -> CallbackId
{
auto backend = LuaBackend::get_calling_backend();
Expand Down

0 comments on commit 747165c

Please sign in to comment.