Advertisement
Urumasi

abc API

Feb 11th, 2014
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,!?-_"
  2. caps = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"
  3.  
  4. function getChID(abcc)
  5.     return(string.find(chars, abcc))
  6. end
  7.  
  8. function getCh(abci)
  9.     return(string.sub(chars, abci, abci))
  10. end
  11.  
  12. function getIDLim()
  13.     return(#chars)
  14. end
  15.  
  16. function allCaps(abct)
  17.     abcto = ""
  18.     for abci=1, #abct do
  19.         abctemp = string.sub(abct, abci, abci)
  20.         if string.find(caps, abctemp) then
  21.             if string.find(caps, abctemp) % 2 == 1 then
  22.                 abctemp = caps[string.find(caps, abctemp)+1]
  23.             end
  24.         end
  25.         abcto = abcto..abctemp
  26.     end
  27.     return(abcto)
  28. end
  29.  
  30. function noCaps(abct)
  31.     abcto = ""
  32.     for abci=1, #abct do
  33.         abctemp = string.sub(abct, abci, abci)
  34.         if string.find(caps, abctemp) then
  35.             if string.find(caps, abctemp) % 2 == 0 then
  36.                 abctemp = caps[string.find(caps, abctemp)-1]
  37.             end
  38.         end
  39.         abcto = abcto..abctemp
  40.     end
  41.     return(abcto)
  42. end
  43.  
  44. function abcOrder(abcoin)
  45.     abcoout = {}
  46.     abctemp = abcoin[1]
  47.     if #abcoin == 1 then
  48.         abcoout[1] = abctemp
  49.     end
  50.     for i=1, #abcoin-1 do
  51.         looking = true
  52.         j = 0
  53.         while looking do
  54.             j = j+1
  55.             ex = false
  56.             for k=1, #abcoout do
  57.                 if abctemp == abcoout[k] then
  58.                     ex = true
  59.                 end
  60.             end
  61.             if not ex then
  62.                 if not getChID(string.sub(abctemp, j, j)) == getChID(string.sub(abcoin[i], j, j)) then
  63.                     looking = false
  64.                     if getChID(string.sub(abctemp, j, j)) < getChID(string.sub(abcoin[i], j, j)) then
  65.                         abctemp = abcoin[i]
  66.                     end
  67.                 end
  68.             end
  69.         end
  70.         table.insert(abcoout, abctemp)
  71.     end
  72.     return(abcoout)
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement