Bolodefchoco_LUAXML

[Math] math.letter

Sep 24th, 2016
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 24/09/2016
  3. --Last update: 24/09/2016
  4. --[[ Notes:
  5.     Does:
  6.         Realiza contas a partir da posição das letras no alfabeto
  7.     Args:
  8.         e --> Conta (a + b)
  9. ]]--
  10.  
  11. math.letter = function(e)
  12.     local n1,op,n2 = e:match("(%a) *(%p) *(%a)")
  13.     local get = function(l)
  14.         local letters = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}
  15.         for k,v in next,letters do
  16.             if v:lower() == l:lower() then
  17.                 return k
  18.             end
  19.         end
  20.         return 0
  21.     end
  22.     local m
  23.     local g1,g2 = get(n1),get(n2)
  24.     if op == "+" then
  25.         m = g1 + g2
  26.     elseif op == "-" then
  27.         m = g1 - g2
  28.     elseif op == "*" then
  29.         m = g1 * g2
  30.     elseif op == "/" then
  31.         m = g1 / g2
  32.     elseif op == "^" then
  33.         m = g1 ^ g2
  34.     elseif op == "." then
  35.         m = g1 + (g2/("1"..("0"):rep(#tostring(g2))))
  36.     elseif op == "<" then
  37.         m = g1 < g2
  38.     elseif op == ">" then
  39.         m = g1 > g2
  40.     else
  41.         m = g1 .. g2
  42.     end
  43.     return m,g1,g2
  44. end
Advertisement
Add Comment
Please, Sign In to add comment