Posted 08 August 2014 - 11:06 AM
Ok so I have been working on a program for 3 days straight and I can't quite figure it out. I am very close but not finished. My intention is making a Touch Screen Menu to turn off my machines in my mob spawner. I connected them through MFR RedNet cables.
Ok so the buttons work but then after activated it doesn't de-activate once pushed again. I need to know how to make this GUI properly work as many activates and de-activates it comes across. The other API is from DireWolf20's Button API :
http://pastebin.com/1iwuzsh8
os.loadAPI("button")
local m = peripheral.wrap("left")
local buttonColors = {}
m.clear()
function mobSpawner()
m.clear()
button.setTable("Door", door, 19,31,10,13)
button.setTable("Lights", lights, 4,16,10,13)
button.setTable("Grinder", grinder, 34,46,10,13)
button.setTable("MobSpawner", spawner, 19,31,16,19)
button.screen()
defaults()
end
function defaults()
rs.setAnalogOutput("bottom", 6)
rs.setAnalogOutput("top", 0)
button.toggleButton("Grinder")
rs.setAnalogOutput("right", 3)
button.toggleButton("Door")
rs.setAnalogOutput("back", 2)
button.toggleButton("Lights")
end
function spawner()
while true do
if rs.setAnalogOutput("bottom", 0) then
rs.setAnalogOutput("bottom", 6)
button.toggleButton("Spawner")
sleep(1)
else
rs.setAnalogOutput("bottom", 0)
button.toggleButton("Spawner")
sleep(1)
end
end
end
function grinder()
while true do
if rs.setAnalogOutput("top", 5) then
rs.setAnalogOutput("bottom", 0)
button.toggleButton("Grinder")
sleep(1)
else
rs.setAnalogOutput("bottom", 5)
button.toggleButton("Grinder")
sleep(1)
end
end
end
function door()
while true do
if rs.setAnalogOutput("right", 0) then
rs.setAnalogOutput("right", 3)
button.toggleButton("Door")
sleep(1)
else
rs.setAnalogOutput("right", 0)
button.toggleButton("Door")
sleep(1)
end
end
end
function lights()
while true do
if rs.setAnalogOutput("back", 0) then
rs.setAnalogOutput("back", 2)
button.toggleButton("Lights")
sleep(1)
else
rs.setAnalogOutput("back", 0)
button.toggleButton("Lights")
sleep(1)
end
end
end
function getClick()
local event,side,x,y = os.pullEvent()
if event=="monitor_touch" then
button.checkxy(x,y)
end
end
mobSpawner()
while true do
getClick()
end
Ok so the buttons work but then after activated it doesn't de-activate once pushed again. I need to know how to make this GUI properly work as many activates and de-activates it comes across. The other API is from DireWolf20's Button API :
http://pastebin.com/1iwuzsh8