这是我的代码。我正在玩Tekkit,想要控制水流量。在棕色电线上有红石电源,但不是黑色,但它仍然会到ERROR!
任何人都知道我的问题是什么?如果语句不工作在Lua
在Lua代码:
shell.run("clear")
brown = rs.testBundledInput("back", colors.brown)
black = rs.testBundledInput("back", colors.black)
t = true
f = nil
if brown == t and black == f then
redstone.setBundledOutput("back", restone.getBundledOutput("back") -colors.brown)
print("All water is flowing.")
sleep(3)
shell.run("2")
elseif brown == f and black == t then
redstone.setBundledOutput("back", restone.getBundledOutput("back") -colors.black)
print("All water is flowing.")
sleep(3)
shell.run("2")
elseif brown == t and black == t then
redstone.setBundledOutput("back", restone.getBundledOutput("back") -colors.brown)
redstone.setBundledOutput("back", restone.getBundledOutput("back") -colors.black)
print("All water is flowing.")
sleep(3)
shell.run("2")
elseif brown == f and black == f then
print("All water is flowing.")
sleep(3)
shell.run("2")
else
print("ERROR!")
end
正确的缩进会使你的代码*多*易于阅读。 –
对不起,那个人..但t =真,f =零?为什么?认真的原因? – starmole
同样适用于全球的“棕色”和“黑色”。他们应该可能是“本地”。参见[Lua_中的程序设计](http://www.lua.org/pil/4.2.html)。 –