SHOW:
|
|
- or go back to the newest paste.
| 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 an ignore list with characters such as ".", "?", "!", etc. |
| 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 | - | if words:sub(letter + 1, letter + 2):lower() == "op" then |
| 22 | + | |
| 23 | local product = {}
| |
| 24 | - | elseif vowels[let:lower()] and words:sub(letter + 1, letter + 1):lower() ~= "p" then |
| 24 | + | |
| 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 | - | table.insert(product, let == " " and " " or vowels[let:lower()] and let or let == let:lower() and let .. "op" or let .. "OP") |
| 35 | + | |
| 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 | - | local to = translate.toLanguage("My name is David")
|
| 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 |