This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
BHTAelitepwn's profile picture

[OpenPeripherals] a minor mistake i can't fix

Started by BHTAelitepwn, 01 April 2014 - 05:45 PM
BHTAelitepwn #1
Posted 01 April 2014 - 07:45 PM
Hello CC forum!!

I am making a small program with touch-screen monitors (this is the first time i actually use them), and i ran into a small error:
i have to click the monitor twice for it to run.

the idea is that i have a monitor (1x1) with the words "water" on row 1, and "cooling" on row 2.
underneath it (row 4) i have a button that changes between 'on' and 'off'. whenever it sends a redstone signal(back), a simple piston mechanism allows water to flood a certain room. as said previously, it works fine, but i have to press both the 'on' and 'off' button twice for it to work.

link to my paste: http://pastebin.com/MALsDewf

(I am using noob code, and i am aware of the fact that it could be written a lot more efficiently)

thanks for your time!!

~BHTA

edit: on the first click, the button interface changes, as it shoulds. the second click makes the computer execute the redstone signal.
Edited on 01 April 2014 - 06:05 PM
Bomb Bloke #2
Posted 02 April 2014 - 08:08 AM
  repeat
  	checkOff()
  until
  	checkOff() == "aan"

This calls "checkOff()", ignores the result, then calls it again to see if it should continue the loop. Hence it only pays attention to every second mouse click.

You could just use:

  repeat until checkOff() == "aan"