ForeverDev

LANGUAGE

Sep 13th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.     HOW THE LANGUAGE WORKS :
  3.         This is inspired by a stupid little 'secret language' my 2nd grade teacher taught me.
  4.        
  5.         Basically, take a word and iterate through the letters.  If the letter is a vowel,
  6.             then leave it be.  If the letter is not a vowel, add "op" to the end of it.
  7.             For example, "Hi" would result in "HOPi", and "face" would result in "fopacope"
  8.            
  9.         TODO: add more characters to ignore list
  10. ]]
  11.  
  12. local vowels = {
  13.     a = true, e = true, i = true, o = true, u = true
  14. }
  15.  
  16. local ignoreList = {
  17.     ["."] = true, ["!"] = true, ["?"] = true, ["/"] = true
  18. }
  19.  
  20. local translate = {
  21.    
  22.     toEnglish = function(words)
  23.         local product = {}
  24.         for letter = 1, words:len() do
  25.             local let = words:sub(letter, letter)
  26.             if (
  27.                 words:sub(letter + 1, letter + 2):lower() == "op" or
  28.                 vowels[let:lower()] and words:sub(letter + 1, letter + 1):lower() ~= "p" or
  29.                 ignoreList[let]
  30.             ) then
  31.                 table.insert(product, let)
  32.             end
  33.         end
  34.         return table.concat(product)
  35.     end,
  36.    
  37.     toLanguage = function(words)
  38.         local product = {}
  39.         for letter = 1, words:len() do
  40.             local let = words:sub(letter, letter)
  41.             table.insert(
  42.                 product,
  43.                 let == " " and " " or
  44.                 ignoreList[let] and let or
  45.                 vowels[let:lower()] and let or
  46.                 let == let:lower() and let .. "op" or
  47.                 let .. "OP"
  48.             )
  49.         end
  50.         return table.concat(product)
  51.     end
  52.    
  53. }
  54.  
  55. local to = translate.toEnglish("hop.")
  56. print(to) --OUTPUT: MOPyop nopamope isop DOPavopidop
Advertisement
Add Comment
Please, Sign In to add comment