-2
我在computercraft寫一個程序的Minecraft國防部,每當我嘗試選擇4退出程序而不做任何事情:選項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
問題是紅網控制是不工作我輸入4,程序結束時沒有做任何事情沒有清除屏幕或打印文本,我試過我知道的一切來修復它但同樣的問題不斷髮生或我得到一個錯誤信息
順便說一下,在rednet controll中,沒有一個真正的做法是因爲引發了一整套新問題
請正確格式化並縮進代碼。 –
另外簡化它,以便我們可以更快地找到問題。 – warspyking