Skip to content

Commit

Permalink
fix set_interval
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed Aug 25, 2023
1 parent 40018a6 commit b5b39c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/game_api/script/lua_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ bool LuaBackend::pre_load_screen()
saved.mount = get_user_data(ent->overlay->uid);
should_save = true;
}
for (auto [type, powerup] : ent->powerups)
for (auto& [type, powerup] : ent->powerups)
{
if (user_datas.contains(powerup->uid))
{
Expand Down Expand Up @@ -919,7 +919,7 @@ void LuaBackend::load_user_data()
set_user_data(ent->holding_uid, saved_user_datas[slot].held.value());
if (ent->overlay && (ent->overlay->type->search_flags & 2) > 0 && saved_user_datas[slot].mount.has_value())
set_user_data(ent->overlay->uid, saved_user_datas[slot].mount.value());
for (auto [type, powerup] : ent->powerups)
for (auto& [type, powerup] : ent->powerups)
{
if (saved_user_datas[slot].powerups.contains(type))
set_user_data(powerup->uid, saved_user_datas[slot].powerups[type]);
Expand Down Expand Up @@ -1399,7 +1399,7 @@ std::vector<uint32_t> LuaBackend::post_load_journal_chapter(uint8_t chapter, con
{
new_pages.clear();
const auto table = returned_pages.as<sol::table>();
for (auto something : table)
for (auto& something : table)
{
if (something.second.get_type() == sol::type::number)
{
Expand Down
3 changes: 2 additions & 1 deletion src/game_api/script/lua_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ end
lua["set_interval"] = [](sol::function cb, int frames) -> CallbackId
{
auto backend = LuaBackend::get_calling_backend();
auto luaCb = IntervalCallback{cb, frames, -1};
auto state = State::get().ptr_main();
auto luaCb = IntervalCallback{cb, frames, (int)state->time_level};
backend->level_timers[backend->cbcount] = luaCb;
return backend->cbcount++;
};
Expand Down

0 comments on commit b5b39c3

Please sign in to comment.