Advertisement
BobMe

to superscript

Dec 2nd, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. -- superscript generator (for numbers)
  2.  
  3. function to_super(x)
  4. local function number_to_super(x)
  5. local y = tonumber(x)
  6. if y ~= nil then
  7. local tab = {"¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹"}
  8. if tab[y] ~= nil then
  9. return tab[y]
  10. else
  11. return "⁰"
  12. end
  13. end
  14. end
  15. local y = tostring(x)
  16. local str = ""
  17. for i=1,#y do
  18. str = str..number_to_super(string.sub(y,i,i))
  19. end
  20. return str
  21. end
  22.  
  23. print(to_super(81072))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement