I like the function you created to convert numbers to binary, very creative. However there are functions that do this quite well and (just as a tip) you would do well to learn some in order to cut down lines and add flexibility. Here is one I found that I used in a serial data transmission over redstone program a while back.
digits = {}
for i=0,9 do digits[i] = strchar(strbyte('0')+i) end
for i=10,36 do digits[i] = strchar(strbyte('A')+i-10) end
function numberstring(number, base)
local s = ""
repeat
local remainder = mod(number,base)
s = digits[remainder]..s
number = (number-remainder)/base
until number==0
return s
end
This will convert to many bases and is used like numberstring(10,2) which will output "1010" which if needed you can append the needed ammount of 0s onto the end like so
str = numberstring(10,2)
str = string.repeat("0",8-#str)..str
--this would return "00001010"
--you can also build this into the function itself like so:
return string.repeat("0",8#s)..s
You can also adapt the function to output a table but I think ill leave that to you :P/>
or you even use a loop and string.sub() with tonumber() to convert the string to the table format you used
hint:Spoiler
for i = 1,#str do
table.insert(table,tonumber(str:sub(i,i)))
end
Remember these are just suggestions and you don't have to implement them if you don't want. ;)/>
I like to learn new things so I gave you this, so have fun so please feel free to play around and edit it as you please!