안녕하세요, 컴퓨터 그래픽에있는 루아 코드를 사용하여 사용자가 위에있는 모니터를 마우스 오른쪽 버튼으로 클릭하여 켜기/끄기를 할 수있게하고 싶습니다.일부 computercraft/lua 코드에 문제가 생겼습니다.
monitor = peripheral.wrap("top")
monitor.clear()
monitor.setTextColor(colors.red)
monitor.setCursorPos(1, 1)
monitor.setTextScale(1)
monitor.write("Hello")
function rubber()
monitor.setCursorPos(1, 2)
monitor.clearLine()
if rs.getOutput("right", true) then
monitor.write("Rubber farm is on")
elseif rs.getOutput("right", false) then
monitor.write("Rubber farm is off")
end
local event = { os.pullEvent() }
if event == "monitor_touch" then
if rs.getOutput("right") == true then
rs.setOutput("right", false)
else
rs.setOutput("right", true)
end
else
write("test")
end
rubber()
end
지금은 표시되는 모든 항목이 '안녕하세요'이며 어떻게 수정해야할지 모릅니다. 또한 나는 루아에서 초보자이기 때문에 꽤 간단한 실수를 저질렀을 것이다. 감사합니다
오히려 그렇게 코드 들여 쓰기를 시도 – Eric
에 연결하지 않고, 게시물에 코드를 넣어주세요 당신의 코드는 당신이 무슨 일이 일어나고 있는지 볼 수 있습니다. – user3412375
사이트에 편집이 오프 사이트 : – Eric