From 9ec81485629b3fe509bc6a0ec46d890932005a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Sun, 8 Aug 2021 20:12:01 -0700 Subject: [PATCH] don't spam logs if formula calculates 0 --- MWSE/mods/celediel/ASinkingFeeling/main.lua | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/MWSE/mods/celediel/ASinkingFeeling/main.lua b/MWSE/mods/celediel/ASinkingFeeling/main.lua index 3a3f5d8..2812d48 100644 --- a/MWSE/mods/celediel/ASinkingFeeling/main.lua +++ b/MWSE/mods/celediel/ASinkingFeeling/main.lua @@ -49,37 +49,37 @@ local function sinkInWater(e) if config.playerOnly and mobile.actorType ~= tes3.actorType.player then return end local downPull = 0 + local debugStr = "" -- calculate the down-pull with the configured formula if config.mode == common.modes.equippedArmour then local armourClass = getTotalArmourClass(actor) downPull = (config.downPullMultiplier / 10) * armourClass - if config.debug then - common.log("Pulling %s down by %s using equipped armour mode (%s total armour class)", - ref.id, downPull, armourClass) - end + debugStr = string.format("Pulling %s down by %s using equipped armour mode (%s total armour class)", + ref.id, downPull, armourClass) elseif config.mode == common.modes.allEquipment then local totalWeight = getTotalEquipmentWeight(actor) -- doubling this keeps this formula somewhat uniform with armour class @ multiplier 100 downPull = ((config.downPullMultiplier / 100) * totalWeight) * 2 - if config.debug then - common.log("Pulling %s down by %s using equipment weight mode (%s total equipment weight)", - ref.id, downPull, totalWeight) - end + debugStr = string.format("Pulling %s down by %s using equipment weight mode (%s total equipment weight)", + ref.id, downPull, totalWeight) elseif config.mode == common.modes.encumbrancePercentage then local encumbrance = mobile.encumbrance -- tripling this keeps this formula somewhat uniform with armour class @ multiplier 100 downPull = (config.downPullMultiplier * encumbrance.normalized) * 3 - if config.debug then - common.log("Pulling %s down by %s using encumbrance mode (%s/%s = %s encumbrance)", - ref.id, downPull, encumbrance.current, encumbrance.base, encumbrance.normalized) - end + debugStr = string.format("Pulling %s down by %s using encumbrance mode (%s/%s = %s encumbrance)", + ref.id, downPull, encumbrance.current, encumbrance.base, encumbrance.normalized) end -- finally add down-pull from configured formula to tes3.mobilePlayer.velocity.z to simulate being pulled down - if downPull ~= 0 then mobile.velocity.z = -downPull end + if downPull ~= 0 then + mobile.velocity.z = -downPull + if config.debug then + common.log(debugStr) + end + end end local function onInitialized()