Hiranus icon

Button Sample

Hiranus | PRO | 09/29/14 08:23:37 AM UTC | 0 ⭐ | 687 👁️ | Never ⏰ | []
Lua |

2.13 KB

|

None

|

0 👍

/

0 👎

 
os.loadAPI("disk/button")
button.prepareMonitor() --this will automatically wrap first avilable monitor, but you can also call:
 
--button.findMonitor("monitor") --you can use both peripheral type and peripheral name, so both "monitor" and "Monitor_0" are ok
 
--local mon=peripheral.wrap("top")
--button.setMonitor(mon)        --this will set monitor to one passed as argument
 
--button.prepareMonitor()  -- this is needed after findMonitor or setMonitor to set font size etc.
 
button.setGlobalButtonVar(11,3,2) --x size of button, y size of button, number of columns,
 
function test1()
    print ("test1")
    error()
end
 
function test2()
    print ("test2")
end
 
function test3()
    print ("test3")
end
 
function test4()
    print ("test4")
    button.useButton("Test2")
end
 
function test5()
    button.selectGroup("B")
    button.redrawScreen()
end
 
function test6()
    button.selectGroup("A")
    button.redrawScreen()
end
 
function test7()
    button.setButtonState(true,"Test2")
end
function test14()
    button.changeButtonLock("Test2")
end
button.selectGroup("A")
button.addBasicButton("Test1",test1,button.toggle)
button.addBasicButton("Test111122211",test1,button.toggle)
button.addBasicButton("Test7",test7,button.toggle)
button.addBasicButton("Test13",test1,button.toggle)
button.addBasicButton("Test14",test14,button.toggle)
button.addBasicButton("Test2",test2,button.flash)
button.setGroupButtonBorder(1,1)
--button.setGroupMonitorBorder(0,0,0,2)
button.addBasicButton("Test4",test4,button.toggle,colors.lightGray,colors.blue)
button.addBasicButton("Test5",test5,button.no)
button.selectGroup("B")
button.addBasicButton("Test6",test6,button.flash)
button.addBasicButton("Test3",test1,button.flash)
--button.setHeading("Menu")
--button.setGroupHeading("Other Menu")
button.setGroupButtonVar(15,3,1)
--button.setGroupMonitorBorder(0,0,0,0)
button.setGroupButtonBorder(2,2)
button.addCustomCornerButton("test lb",button.empty,button.toggle,7,3,"lb")
button.addCustomCornerButton("test rb",button.empty,button.flash,7,3,"rb")
button.calculateButtons()
button.printButtonData()
button.redrawScreen()
while true do
  button.getClick()
end

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎