I’m making a converter app and currently trying to convert time units. My formula includes subtracting math.mins, which returned an “attempt to perform arithmetic on a nil value” error. In addition, my time units are arranged in ascending order in a table. Here’s my formula:
result.text = tostring(tonumber(textField.text)*
1000^(math.min(table.indexOf(timeUnits, Unit1), table.indexOf(timeUnits, "s")) - math.min(table.indexOf(timeUnits, Unit2), table.indexOf(timeUnits, "s")))*
60^(math.max(math.min(table.indexOf(timeUnits, Unit1), table.indexOf(timeUnits, "h")), table.indexOf(timeUnits, "s")) - math.max(math.min(table.indexOf(timeUnits, Unit2), table.indexOf(timeUnits, "h")), table.indexOf(timeUnits, "s")))*
24^(math.max(table.indexOf(timeUnits, Unit1), table.indexOf(timeUnits, "h")) - math.max(table.indexOf(timeUnits, Unit2), table.indexOf(timeUnits, "h"))))
I’m very certain that the problem lies in this part of the code.