Was wondering if there was anything to improve on this, also feel free to use it if you need it in any projects lol
local values = {
[1] = 128,
[2] = 64,
[3] = 32,
[4] = 16,
[5] = 8,
[6] = 4,
[7] = 2,
[8] = 1,
}
local Convert; Convert = function(expression)
expression = tostring(expression)
local overall = 0
if expression:len() ~= 8 then
return
else
for i = 1,expression:len() do
if expression:sub(i,i) == "1" then
overall = overall + values[i]
end
end
end
print(overall)
end
Convert(11000000)