From a1e989f2b76a150750c8fb8bfe930b4966adb668 Mon Sep 17 00:00:00 2001 From: Deyan Dobromirov Date: Wed, 18 Sep 2024 09:00:38 +0300 Subject: [PATCH] changed: Reduce wrap arguments count --- lua/trackassembly/trackasmlib.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lua/trackassembly/trackasmlib.lua b/lua/trackassembly/trackasmlib.lua index b5423ce2..d14d31fb 100644 --- a/lua/trackassembly/trackasmlib.lua +++ b/lua/trackassembly/trackasmlib.lua @@ -515,14 +515,13 @@ end * Out (R): 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 * This is an example call for the input between L=1 and H=3 * nV - Current value being wrapped - * nL - Wrapper low value - * nH - Wrapper high value + * nH - Wrapper size/count value * Returns the wrapped value mapped to the interval provided ]] -function GetWrap(nV, nL, nH) +function GetWrap(nV, nH) if(nV == 0) then return nH end - if(nV >= nL and nV <= nH) then return nV end - local nC = nV % nH + if(nV >= 1 and nV <= nH) then return nV end + local nC = nV % nH -- Get the reminder return (nC == 0) and nH or nC end @@ -2068,7 +2067,7 @@ function SwitchID(vID,vDir,oRec) local nDir = mathFloor(tonumber(vDir) or 0) local iDir = (((nDir > 0) and 1) or ((nDir < 0) and -1) or 0) if(iDir == 0) then LogInstance("Direction mismatch"); return ID end - local ID = GetWrap(ID + iDir, 1, oRec.Size) -- Move around the snap + local ID = GetWrap(ID + iDir, oRec.Size) -- Move around the snap local stPOA = LocatePOA(oRec,ID); if(not IsHere(stPOA)) then LogInstance("Offset missing "..GetReport(ID)); return 1 end return ID