Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- if not args[1] then error("Usage: <programName> <redstone output side>") end
- if not fs.exists("buttonObjAPI") then
- shell.run("pastebin","get","UwAgPsje","buttonObjAPI")
- end
- local mon
- for _,side in pairs(rs.getSides()) do
- if peripheral.getType(side) == "monitor" and term.isColor() == true then
- mon = peripheral.wrap(side)
- break
- end
- end
- if not mon then error("no monitor attached. monitor must be advanced!!!") end
- mon.setTextScale(tonumber(args[2]) or .5)
- dofile("buttonObjAPI")
- term.clear()
- term.setCursorPos(1,1)
- term.write("press enter to quit..")
- term.redirect(mon)
- local state = false
- local rsOut = tostring(args[1])
- b1 = setButton({name="On / Off",xStart=2,yStart=2,xPadding=1,yPadding=2,visible=true,})
- while true do
- b1.draw()
- local e = {os.pullEvent()}
- if e[1] == "monitor_touch" then
- if b1.isWithin(e[3],e[4]) then
- state = not state
- b1.setState(state)
- end
- elseif e[1] == "key" and e[2] == keys.enter then
- break
- end
- rs.setOutput(rsOut,state)
- end
- term.restore()
Advertisement
Add Comment
Please, Sign In to add comment