Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- display = peripheral.wrap("right")
- function resetOutDevice(var_device)
- var_device.setCursorPos(1, 1)
- var_device.setBackgroundColor(colors.black)
- var_device.setTextColor(colors.white)
- var_device.clear()
- end
- function createButton(var_xPos, var_yPos, var_bgColor, var_textColor, var_text, var_btnID, var_pointer, var_device)
- var_device.setCursorPos(var_xPos, var_yPos)
- var_device.setBackgroundColor(var_bgColor)
- var_device.setTextColor(var_textColor)
- var_device.write(var_text)
- var_buttonList[var_btnID] = {}
- var_buttonList[var_btnID][0] = var_xPos
- var_buttonList[var_btnID][1] = var_yPos
- var_buttonList[var_btnID][2] = var_xPos + string.len(var_text) - 1
- var_buttonList[var_btnID][3] = var_pointer
- end
- function createLabel(var_xPos, var_yPos, var_bgColor, var_textColor, var_text, var_device)
- var_device.setCursorPos(var_xPos, var_yPos)
- var_device.setBackgroundColor(var_bgColor)
- var_device.setTextColor(var_textColor)
- var_device.write(var_text)
- end
- function createVerticalBars(var_xPos, var_yPos, var_priColor, var_secColor, var_maxValue, var_curValue, var_size, var_device)
- for var_loop1 = 0, var_maxValue - 1 do
- var_device.setCursorPos(var_xPos, var_yPos - var_loop1)
- for var_loop2 = 0, var_size do
- if var_loop1 < var_curValue then
- var_device.setBackgroundColor(var_priColor)
- else
- var_device.setBackgroundColor(var_secColor)
- end
- var_device.write(" ")
- end
- end
- end
- function mainProcess()
- resetOutDevice(display)
- var_buttonList = {}
- createButton(3, 1, colors.yellow, colors.black, "clear", 1, "clearPointer", display)
- createButton(3, 3, colors.yellow, colors.black, "print", 2, "printPointer", display)
- createButton(3, 5, colors.yellow, colors.black, "close", 3, "closePointer", display)
- end
- function awaitTouch()
- while true do
- local event, side, var_x, var_y = os.pullEvent("monitor_touch")
- print("TOUCH")
- for var_loop1 = 1, #var_buttonList do
- 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
- print(var_buttonList[var_loop1][3])
- else
- print("Miss")
- end
- end
- end
- end
- parallel.waitForAll(awaitTouch, mainProcess)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement