Advertisement
MoparDan

demo

Sep 2nd, 2014
6,659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. API = require("buttonAPI")
  2. local event = require("event")
  3. local computer = require("computer")
  4. local term = require("term")
  5. local component = require("component")
  6. local gpu = component.gpu
  7.  
  8. local rs = component.redstone
  9. local colors = require("colors")
  10. local side = require("sides")
  11.  
  12. function API.fillTable()
  13.   API.setTable("Flash", test1, 10,20,3,5)  
  14.   API.setTable("Toggle", test2, 22,32,3,5)
  15.   API.setTable("Free Ram", test3, 10,20,8,10)
  16.   API.setTable("Reboot", test4, 22,32,8,10)
  17.   API.screen()
  18. end
  19.  
  20. function getClick()
  21.   local _, _, x, y = event.pull(1,touch)
  22.   if x == nil or y == nil then
  23.     local h, w = gpu.getResolution()
  24.     gpu.set(h, w, ".")
  25.     gpu.set(h, w, " ")
  26.   else
  27.     API.checkxy(x,y)
  28.   end
  29. end
  30.  
  31. function test1()
  32.   API.flash("Flash",0.01)
  33. end
  34.  
  35. function test2()
  36.   API.toggleButton("Toggle")
  37.   if buttonStatus == true then
  38.     -- # If the button is on (green) do something.
  39.   else
  40.     -- # If the button is off (red) do this instead.
  41.   end
  42. end
  43.  
  44. function test3()
  45.   term.setCursor(1,25)
  46.   term.write("Free Memory: "..computer.freeMemory().." bytes")
  47. end
  48.  
  49. function test4()
  50.   computer.shutdown(true)
  51. end
  52.  
  53. term.setCursorBlink(false)
  54. gpu.setResolution(80, 25)
  55. API.clear()
  56. API.fillTable()
  57. API.heading("Button API Demo! Created in CC by DW20, ported to OC by MoparDan!")
  58. API.label(1,24,"A sample Label.")
  59.  
  60. while true do
  61.   getClick()
  62. end
  63.  
  64.  
  65.  
  66. --eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement