Advertisement
Guest User

RM

a guest
Apr 9th, 2020
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.10 KB | None | 0 0
  1. os.loadAPI("touch")
  2. modem = peripheral.wrap("top")
  3. monitor = peripheral.wrap("left")
  4. monitor.clear()
  5. monitor.setTextScale(1)
  6. modem.open(1)
  7. local width, height = monitor.getSize()
  8. print(width)
  9. print(height)
  10. ItemList = {}
  11. t = touch.new("left")
  12. function Menu()
  13.   t:add("ItemList",nil,31,10,51,16,colors.red,colors.lime)
  14.   t:draw()
  15. end
  16.  
  17. function Back()
  18.   t:add("Back",nil,66,20,76,24,colors.red,colors.lime)
  19.   t:draw()
  20. end
  21.  
  22. function RemoveButton()
  23.   t:remove("ItemList")
  24.   t:remove("Back")
  25.   t:draw()
  26. end
  27.  
  28. function DisplayInfo()
  29.   while true do
  30.     local breakReceiving = false
  31.     local myTimer = os.startTimer(0.5)
  32.     while true do
  33.       local e2,p2,p3,p4,p5,p6 = os.pullEvent()
  34.       print(e2)
  35.       if e2 == "monitor_touch" then
  36.         local e1,par1 = t:handleEvents(e2,p2,p3,p4)
  37.         if e1 == "button_click" and par1 == "Back" then
  38.           t:flash(par1)        
  39.           RemoveButton()
  40.           Menu()
  41.           breakReceiving = true
  42.           break
  43.         end
  44.       elseif e2 == "modem_message" then
  45.         local Status = "Receiving"
  46.         for k,v in pairs(p5) do
  47.           ItemList[k] = v
  48.         end
  49.         h = 1
  50.         w = 1
  51.         i = 1
  52.         RemoveButton()
  53.         monitor.clear()
  54.         Back()
  55.         for k,v in pairs(ItemList) do
  56.           if i < 26 then
  57.             monitor.setCursorPos(w,i)
  58.             monitor.setBackgroundColor(colors.black)
  59.             monitor.write(k.." : "..v)
  60.             i = i + 1
  61.           else
  62.             w = 40
  63.             i = 1
  64.             monitor.setCursorPos(w,i)
  65.             monitor.setBackgroundColor(colors.black)
  66.             monitor.write(k.." : "..v)
  67.             i = i + 1    
  68.           end
  69.         end
  70.         Status = "Idle"
  71.       elseif e2 == "timer" and p2 == myTimer then
  72.         print("Stopped")
  73.         break
  74.       end
  75.     end
  76.     if breakReceiving == true then
  77.       break
  78.     end
  79.   end
  80. end
  81.  
  82. Menu()
  83.  
  84. while true do
  85.   local event1,p1 = t:handleEvents(os.pullEvent())
  86.   if event1 == "button_click" and p1 =="ItemList" then
  87.     t:flash(p1)
  88.     RemoveButton()
  89.     DisplayInfo()
  90.   end
  91. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement