我正在编写一个关于computercraft minecraft mod的程序,每当我尝试选项4时,它都会退出程序而不做任何事情:
os.pullEvent = os.pullEventRaw
while true do
term.clear()
term.setCursorPos(1,1)
print ("Welcome to F-SecOS")
print ("1)initialize")
print ("2)shutdown")
print ("3)power control")
print ("4)rednet control")
input = io.read()
if input == "1" then
term.clear()
term.setCursorPos(1,1)
print ("intitializing 10%")
print ("|")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("initializing 25%")
print("/")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("initializing 50%")
print("--")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("initializing 75%")
print(".\.")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("initializing 90%")
print("|")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("initializing 100%")
print("/")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("F_sec initialized")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("F_SecOS V1.8")
break
end
if input == "2" then
os.shutdown()
end
if input == "4" then
break
end
if input == "3" then
while true do
term.clear()
term.setCursorPos(1,1)
print("1)open outer door")
print("2)close outer door")
print("3)open inner door")
print("4)close inner door")
print("5)open middle door")
print("6)close middle door")
print("q)exit")
CI = io.read()
if CI == "1" then
rs.setOutput("left",true)
end
if CI == "2" then
rs.setOutput("left",false)
end
if CI == "3" then
rs.setOutput("right",true)
end
if CI == "4" then
rs.setOutput("right",false)
end
if CI == "5" then
rs.setOutput("bottom",true)
end
if CI == "6" then
rs.setOutput("bottom",false)
end
if CI == "Q" or CI == "q" then
break
end
if input == "4" then
term.clear()
term.setCursorPos(1,1)
print ("1)open ports")
print ("2)close ports")
print ("3)send message")
print ("4)unused function")
print ("5)unused function")
print ("q)exit")
RI = io.read()
if RI == "1" then
rednet.open ("top")
end
if RI == "2" then
rednet.close ("top")
end
if RI == "q" or RI == "Q" then
end
end
end
end
end
问题是rednet控制不起作用我输入4并且程序结束而没有做任何事情不清除屏幕或打印文本我已经尝试了我知道的所有修复它但是同样的问题仍然存在或我收到一条错误消息
顺便说一下,在rednet controll中没有真正做到的原因是因为提出了一整套新的问题答案 0 :(得分:0)
你在中间有这块代码:
if input == "4" then
break
end
在输入2和3之间,所以它在这里捕获输入并在它到达代码结束之前停止,在那里你还有另一个if input == "4"
具有你想要做的实际逻辑。