2014-10-23 2 views
-4

루아에서 키를 누를 때 간단한 토글 스위치를 사용하려고합니다.루아 토글 스위치?

코드 :

local soundOn = true 
if keys['J'] then 
    if soundOn then 
     memory.writebyte(0x0773,04); 
     soundOn = false 
    else 
     memory.writebyte(0x0773,00); 
     soundOn = true 
    end; 
end; 

답변

1

는 키 이벤트를 얻기 위해 단지 루아 불가능합니다. 그러나 프로그램을 실행하기 위해 사용하는 기능에 따라 그 기능이있을 수 있습니다. 예를 들어, Computercraft (minecraft mod)에는 os.pullEvent()가 있습니다.

question

0

고마워 관련을 참조하십시오. 첫 번째 키 누르기 만 작동합니다.

local soundOn = true 
if keys['J'] then 

       if soundOn then 

        memory.writebyte(0x0773,04); 

         soundOn = false 
       else 

        memory.writebyte(0x0773,00); 

         soundOn = true 

       end; 

end; 
관련 문제