2017-08-25 142 views
2

我在LUA初學者,所以我遇到一些麻煩吧。我使用的是Minecraft mod的代碼,叫做Computercraft,但對我來說這是編程的一個很好的介紹。如何跟蹤基本的LUA錯誤?

我一直在網上搜索,找出爲什麼我的連26行代碼失敗,但我不能悲傷地找到它。

下面的代碼:

monitor = peripheral.wrap("right") 
monitor.clear() 
monitor.setCursorPos(1,1) 
monitor.setTextScale(1) 
monitor.print("Current mode:") 
monitor.setCursorPos(1,3) 
monitor.print("Dust gaat naar furnace") 
redstone.setOutput(back,false) 
print("Dust gaat automatisch naar de furnace toe") 
print("Wil je dat de dust naar de chest gaat in plaats van de furnace?") 
write() 
while input == ja 
do 
    print("Oke :)") 
    redstone.setOutput(back,true) 
    monitor.clear() 
    monitor.setCursorPos(1,1) 
    monitor.print("Current mode:") 
    monitor.setCursorPos(1,3) 
    monitor.print("Dust gaat naar chest") 
end 
else 
    print("Okeuu dan niet jongee") 
end 

我知道,我已經使用 '結束' 的2倍。這是因爲我刪除一個時出現錯誤。

,當我運行的程序是我得到的錯誤:

bios:14: [string ".temp"]:22: '<eof>' expected. 

The error I get when I remove the first 'end'.

The error I get when I remove the second 'end'.

編輯 好以及之後的一些意見,我設法擺脫錯誤的。 感謝所有回覆的人! c: 現在我得到了其他錯誤雖然哈哈。 作爲建議我做了一個新的職位看:Basic LUA problems

+2

安置自己的錯誤作爲文本。不是圖片。 –

+3

也許,你想用的,而不是「如果」的「外衣」? '如果輸入== JA然後... ...其他end' –

+0

我想說的是,新的問題是另外一個問題的問題;您應該恢復編輯,將答案標記爲已接受,併爲新問題創建一個新問題。 –

回答

2

的:22:告訴你,周圍的腳本,這是其他的22行發生錯誤。如果你看看Lua的參考指南,你會看到其他屬於如果聲明,而不是聲明。

你的代碼也許應該是如下,作爲一個同時無厘頭這裏

if input == ja 
then 
    ... code ... 
else 
    ... other code ... 
end 
+0

謝謝bucnh!會馬上嘗試C: – Ynk

+0

我得到另一個錯誤:「.temp:5:嘗試零稱之爲」 – Ynk

+0

@Ynk - 也許,'monitor.print'是'nil' –