Posted 13 November 2016 - 05:28 AM
So many of you will probably know what pig latin is right… If you don't click this link: http://bit.ly/2eta44Q
Basically you enter a word and it translates to pig latin, aka igpay atinlay.
Here is the pastebin link: http://pastebin.com/9hRzPF8Y
And here is the code:
I know this is pretty simple but I only just started CC hopefully you will like it.
EDIT: It is currently in BETA so it doesn't convert consonant clusters as in Br or Sw. It also can only convert one word at a time
Basically you enter a word and it translates to pig latin, aka igpay atinlay.
Here is the pastebin link: http://pastebin.com/9hRzPF8Y
And here is the code:
Spoiler
vowels = {
[1] = "a",
[2] = "e",
[3] = "i",
[4] = "o",
[5] = "u",
[6] = "A",
[7] = "E",
[8] = "I",
[9] = "O",
[10] = "U"
}
vEnd = {
[1] = "w",
[2] = "a",
[3] = "y"
}
cEnd = {
[1] = "a",
[2] = "y"
}
vStart = false
write("Type word to be converted... : ")
local text = read()
text = string.lower(text)
local result = {}
local function splitString()
for letter in text:gmatch(".") do
table.insert(result, letter)
end
end
local function checkWord()
for i = 1, #vowels do
if result[1] == vowels[i] then
vStart = true
else end
end
return vStart
end
local function convertWord()
if vStart == true then -- Starts with a vowel
for i = 1, #vEnd do
table.insert(result, #result + 1, vEnd[i])
end
else -- Does not start with a vowel
tempC = result[1]
table.remove(result, 1)
table.insert(cEnd, 1, tempC)
for i = 1, #cEnd do
table.insert(result, #result + 1, cEnd[i])
end
end
result[1] = string.upper(result[1])
end
local function printConverted()
for i = 1, #result do
term.write(result[i])
end
print("")
end
local function Initiate()
splitString()
checkWord()
convertWord()
printConverted()
end
Initiate()
I know this is pretty simple but I only just started CC hopefully you will like it.
EDIT: It is currently in BETA so it doesn't convert consonant clusters as in Br or Sw. It also can only convert one word at a time
Edited on 13 November 2016 - 04:35 AM