Posted 08 November 2015 - 06:58 PM
I am working on a computer program that has an assortment of buttons that toggle on and off and I have been trying to get the state of the button to affect a certain color of a bundled cable.
This is what I have right now:
My issue is, as it stands, it will toggle the state of its respective color on, but not off. I have followed a number of posts about this but I cant seem to find my error.
Special thanks to Lyqyd for all of his coding prowess, hes gotten me this far without a whole lot of stress thanks to his posts.
Also, obligatory "y u use direwolf button API m8"
Thank you to any help you can lend me. Its wracking my brain.
This is what I have right now:
os.loadAPI("button")
m = peripheral.wrap("top")
m.clear()
function fillTable()
button.setTable("Test", Test, 2, 10, 2, 2, colors.red)
button.setTable("Test2", Test2, 2, 10, 4, 4, colors.yellow)
button.screen()
end
function getClick()
event,side,x,y = os.pullEvent("monitor_touch")
button.checkxy(x,y)
end
redstone.setBundledOutput("right", 0)
function setBundledColor(side, color, state)
if state then
if not colors.test(redstone.getBundledOutput(side), color) then
redstone.setBundledOutput(side, colors.combine(redstones.getBundledOutput(side), color))
end
else
if colors.test(redstones.getBundledOutput(side), color) then
redstone.setBundledOutput(side, colors.subtract(redstone.getBundledOutput(side), color))
end
end
end
function toggleBundledColor(side, color)
redstone.setBundledOutput(side, (colors.test(redstone.getBundledOutput(side), color) and colors.subtract(redstone.getBundledOutput(side), color) or colors.combine(redstone.getBundledOutput(side), color)))
end
function Test()
button.toggleButton("Test")
toggleBundledColor("right", colors.white)
print("Test")
end
function Test2()
button.toggleButton("Test2")
toggleBundledColor("right", colors.yellow)
print("Test2")
end
fillTable()
while true do
getClick()
end
My issue is, as it stands, it will toggle the state of its respective color on, but not off. I have followed a number of posts about this but I cant seem to find my error.
Special thanks to Lyqyd for all of his coding prowess, hes gotten me this far without a whole lot of stress thanks to his posts.
Also, obligatory "y u use direwolf button API m8"
Thank you to any help you can lend me. Its wracking my brain.