2016-12-16 4 views
0

그래서 내가 루아에서 평범한 해요,하지만 난 그냥이욕설 필터 루아

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 

하지만 내가 출력에 도착하여 주위를 연주 한 것은 이것이다 제로 진동 스튜디오 사용

그리고 때로는 다른 것들을 입력 할 때 전혀 작동하지 않습니다. 도움?

+2

예상되는 출력은 무엇입니까? –

답변

1
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