From 51326d6932c7d6ab5750ef919d68dd968bd1ebe8 Mon Sep 17 00:00:00 2001 From: Gate Date: Sat, 22 Jun 2024 18:13:38 -0500 Subject: [PATCH] Update LoadHUD.lua Prevent negative numbers, clamp output 0 - 100 --- LoadHUD.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/LoadHUD.lua b/LoadHUD.lua index e81241d..d647e70 100644 --- a/LoadHUD.lua +++ b/LoadHUD.lua @@ -3,12 +3,17 @@ -- Small HUD which shows current engine load in percent. The shown value is the average of the last 60 frames. -- -- Author: StingerTopGun +-- +-- Changelog: +-- Clamp the output value to prevent negative load numbers +-- +-- LoadHUD = {} LoadHUD.eventName = {} LoadHUD.ModName = g_currentModName LoadHUD.ModDirectory = g_currentModDirectory -LoadHUD.Version = "1.0.0.0" +LoadHUD.Version = "1.0.0.1" LoadHUD.loopcnt = 0 LoadHUD.average_cnt = 60 @@ -61,7 +66,8 @@ function LoadHUD.mean( t ) end end - return (sum / count) + -- Edit by Gate + return MathUtil.clamp((sum / count), 0, 100) end addModEventListener(LoadHUD) \ No newline at end of file