Hello there, hope you are doing well.
local function recursiveSearch(prompt)
local rand = math.random(#dic)
local longRand = math.random(#long)
local exRand = math.random(#expert)
local jkRand = math.random(#jklm)
local hyRand = math.random(#hyphenated)
prompt = prompt:upper()
if string.find(dic[rand], prompt) then
print(dic[rand])
return dic[rand]
elseif string.find(long[longRand], prompt) then
print(long[longRand])
return long[longRand]
else
recursiveSearch(prompt)
end
end
(I know that there is an elseif
chain, I can’t think of how to make it a table switch thing.)
The code above generates a random number, and checks in a dictionary if the chosen word contains the letters given (prompt
). Now, this does work well, and the print function print the word chosen (which does in fact have the letters given). But the thing is, when I try this:
print(recursiveSearch("FA"))
(just an example)
It prints an empty string. I tried everything I can think of and nothing worked.
If someone could help that would be amazing.
Thank you!