--[[ ======================================== DIVIDE VALUES ======================================== PURPOSE: Divides each input value by a constant. FORMULA: output = input / DIVISOR EXAMPLE: DIVISOR = 2 Input: 50 → Output: 25 IMPORTANT: Division by zero is not allowed. USER ACTION: Modify DIVISOR in USER EDIT SECTION ======================================== ]] function DivideValue(input) if input == nil then return {} end local output = {} ------------------------------------------------- -- USER EDIT SECTION ------------------------------------------------- local DIVISOR = 2 -- Value to divide by ------------------------------------------------- -- Prevent division by zero if DIVISOR == 0 then return {} end for tag = 1, 10 do local key = tostring(tag) local inVec = input[key] if type(inVec) == "table" then local outVec = {} for i, v in ipairs(inVec) do local val = (v.value or 0) / DIVISOR table.insert(outVec, { value = val, quality = v.quality or 0, timestamp = v.timestamp or 0 }) end output[key] = outVec end end return output end