Advertisement
FireDust

Minecraft CC GUI

Dec 4th, 2015
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. display  = peripheral.wrap("right")
  2.  
  3. function resetOutDevice(var_device)
  4.     var_device.setCursorPos(1, 1)
  5.     var_device.setBackgroundColor(colors.black)
  6.     var_device.setTextColor(colors.white)
  7.     var_device.clear()
  8. end
  9.  
  10. function createButton(var_xPos, var_yPos, var_bgColor, var_textColor, var_text, var_btnID, var_pointer, var_device)
  11.     var_device.setCursorPos(var_xPos, var_yPos)
  12.     var_device.setBackgroundColor(var_bgColor)
  13.     var_device.setTextColor(var_textColor)
  14.     var_device.write(var_text)
  15.  
  16.     var_buttonList[var_btnID] = {}
  17.     var_buttonList[var_btnID][0] = var_xPos
  18.     var_buttonList[var_btnID][1] = var_yPos
  19.     var_buttonList[var_btnID][2] = var_xPos + string.len(var_text) - 1
  20.     var_buttonList[var_btnID][3] = var_pointer
  21.  
  22. end
  23.  
  24. function createLabel(var_xPos, var_yPos, var_bgColor, var_textColor, var_text, var_device)
  25.     var_device.setCursorPos(var_xPos, var_yPos)
  26.     var_device.setBackgroundColor(var_bgColor)
  27.     var_device.setTextColor(var_textColor)
  28.     var_device.write(var_text)
  29. end
  30.  
  31. function createVerticalBars(var_xPos, var_yPos, var_priColor, var_secColor, var_maxValue, var_curValue, var_size, var_device)
  32.     for var_loop1 = 0, var_maxValue - 1 do
  33.         var_device.setCursorPos(var_xPos, var_yPos - var_loop1)
  34.         for var_loop2 = 0, var_size do
  35.             if var_loop1 < var_curValue then
  36.                 var_device.setBackgroundColor(var_priColor)
  37.             else
  38.                 var_device.setBackgroundColor(var_secColor)
  39.             end
  40.             var_device.write(" ")
  41.         end
  42.     end
  43. end
  44.  
  45. function mainProcess()
  46.     resetOutDevice(display)
  47.  
  48.     var_buttonList = {}
  49.     createButton(3, 1, colors.yellow, colors.black, "clear", 1, "clearPointer", display)
  50.     createButton(3, 3, colors.yellow, colors.black, "print", 2, "printPointer", display)
  51.     createButton(3, 5, colors.yellow, colors.black, "close", 3, "closePointer", display)
  52. end
  53.  
  54. function awaitTouch()
  55.     while true do
  56.         local event, side, var_x, var_y = os.pullEvent("monitor_touch")
  57.         print("TOUCH")
  58.  
  59.         for var_loop1 = 1, #var_buttonList do
  60.             if var_x > var_buttonList[var_loop1][0] and var_y == var_buttonList[var_loop1][1] and var_x < var_buttonList[var_loop1][2] then
  61.                 print(var_buttonList[var_loop1][3])
  62.             else
  63.                 print("Miss")
  64.             end
  65.         end
  66.     end
  67. end
  68.  
  69. parallel.waitForAll(awaitTouch, mainProcess)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement