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

[Lua] [Help] Problem using buttons and rednet

Started by robertcarr22, 03 February 2013 - 03:46 AM
robertcarr22 #1
Posted 03 February 2013 - 04:46 AM
I have a touch screen monitor set up with a button program that when a button is pressed it sends a message over rednet to turn monitors on/off.

Code: http://pastebin.com/Q6Uv88xU

The problem im having is that when i click one of the buttons it sends the rednet signal three times and varies between on and off.
e.g. when I press the middle monitor button, it sends 3 On messages (which isnt a problem) but when i press the right monitor to turn it off it sends 3 messages of On, Off, On, meaning the monitor is left on.

I cant understand why this happens so i need some help! :P/>
The button code is direwolf20's and i just added in the functions for the monitors.
Lyqyd #2
Posted 16 July 2013 - 01:44 PM
You're iterating through every button state each time you click any button, so whichever button you click, the final state of the monitor it controls will always be the state of the last button.