Hey devs!
So what I am trying to do is generating a Code out of a string. My plan was using the Alphabet for that and for loops. The number generated as the letter is the index, the problem is, it is only inserting the first letter in my Table. In this example it would be 20 since t is the 20th letter in my table. Does anybody know why?
And sorry for my bad english, explaining in a foreign language is hard ;=)
local alphabet = {"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","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"}
function generateID(gangName)
print("recieved")
local finalProduct = {}
print("created table")
local len = string.len(gangName)
print("got len ("..len..")")
local currentChar = 0
print("got currentChar")
repeat
print("repeating")
wait()
for i, v in pairs(alphabet) do
if string.sub(gangName, currentChar, currentChar + 1) == v then
print(string.sub(gangName, currentChar, currentChar + 1))
table.insert(finalProduct, #finalProduct, i)
print("inserted "..v.." as "..i.."!")
end
end
currentChar = currentChar + 1
until currentChar == len
for i, v in pairs(finalProduct) do
print(v)
end
return finalProduct
end
local result = generateID("tankkillera10c")
print(result)