From b7308b4739a17e534eb82f1f8f1b2e48674aae46 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Wed, 8 Mar 2023 16:42:15 +0100 Subject: [PATCH] Get window info once per second --- src/fields.lua | 3 ++- src/hud.lua | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fields.lua b/src/fields.lua index 86d81dd..200e94f 100644 --- a/src/fields.lua +++ b/src/fields.lua @@ -468,7 +468,8 @@ core.register_on_player_receive_fields(function(player, formname, fields) end if tab.fields then - tab.fields(player, data, fields) + local ret = tab.fields(player, data, fields) + if ret == false then return end end end diff --git a/src/hud.lua b/src/hud.lua index 6f6841c..d74ba11 100644 --- a/src/hud.lua +++ b/src/hud.lua @@ -118,7 +118,12 @@ core.register_globalstep(function(dt) local data = i3.data[name] if not data then return end - data.window = get_window_info and get_window_info(name) or nil + data.window_timer = (data.window_timer or 0) + dt + + if data.window_timer > 1 then + data.window_timer = 0 + data.window = get_window_info and get_window_info(name) or nil + end if data.show_hud ~= nil then show_hud(player, data)