Profanity Filter Lua

496 views Asked by At

so i'm mediocre at lua, but i was just playing around with this

local profanitywords = {"fuck", "shit", "ass"} -- a small list
local input = io.read()

for i,v in ipairs (profanitywords) do
   if string.find(input:lower(), v) then
      print("Profanity")
   else
       print("Not Profanity")
   end
end

but what i get in the output is this:

Output Image also, i'm using zerobrane studios

and sometimes when i enter different things, it doesn't work at all. help?

1

There are 1 answers

0
Egor   Skriptunoff On BEST ANSWER
local profanity
for i,v in ipairs (profanitywords) do
   if string.find(input:lower(), v) then
      profanity = true
      break
   end
end

if profanity then
    print("Profanity")
else
    print("Not Profanity")
end