【发布时间】:2021-06-26 19:33:22
【问题描述】:
所以我在 lua 中制作了一个简单的程序,要求你写一个包含“ck”或“bv”之类的词,显然这些词必须在字典上,所以我有一个超过 50,000 个词的填充词在字典上,问题是当我输入文件上的单词时它说我输了,我放了一个 print(line) 进行调试,所以我可以看到发生了什么,我注意到它不会打印每个单词
例子:
文本文件
这是读取文件的代码:
local words_file = io.open("words.txt", "r")
local words = {}
local contains = {"br", "gg", "in", "et", "ck", "q", "it", "el", "st", "es", "be"}
local input
math.randomseed(os.time())
for line in words_file:lines() do
words[line] = words_file:read("*l")
print(line)
end
print("Loaded!")
这是游戏的代码:
while true do
local contain = contains[math.random(#contains)]
print("Write a word that contains \"" .. contain .."\"")
input = io.read()
if not (string.find(input, contain) and words[input:lower()]) then
print("lol u bad")
break
end
end
【问题讨论】:
-
相比显示渲染文本的图像,请更喜欢文本演示。