Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("touch")
- modem = peripheral.wrap("top")
- monitor = peripheral.wrap("left")
- monitor.clear()
- monitor.setTextScale(1)
- modem.open(1)
- local width, height = monitor.getSize()
- print(width)
- print(height)
- ItemList = {}
- t = touch.new("left")
- function Menu()
- t:add("ItemList",nil,31,10,51,16,colors.red,colors.lime)
- t:draw()
- end
- function Back()
- t:add("Back",nil,66,20,76,24,colors.red,colors.lime)
- t:draw()
- end
- function RemoveButton()
- t:remove("ItemList")
- t:remove("Back")
- t:draw()
- end
- function DisplayInfo()
- while true do
- local Status = "Receiving"
- local event, modemSide, sendFrom, replyChannel, message, sendDistacne = os.pullEvent("modem_message")
- for k,v in pairs(message) do
- ItemList[k] = v
- end
- h = 1
- w = 1
- i = 1
- monitor.clear()
- for k,v in pairs(ItemList) do
- if i < 26 then
- monitor.setCursorPos(w,i)
- monitor.write(k.." : "..v)
- i = i + 1
- else
- w = 40
- i = 1
- monitor.setCursorPos(w,i)
- monitor.write(k.." : "..v)
- i = i + 1
- end
- end
- Status = "Idle"
- local breakReceiving = false
- local myTimer = os.startTimer(0.5)
- while true do
- local e2,p2,p3,p4 = os.pullEvent()
- print(e2)
- if e2 == "monitor_touch" then
- local e1,par1 = t:handleEvents(e2,p2,p3,p4)
- if e1 == "button_click" and par1 == "Back" then
- t:flash(par1)
- RemoveButton()
- Menu()
- breakReceiving = true
- break
- end
- elseif e2 == "timer" and p2 == myTimer then
- print("Stopped")
- break
- end
- end
- if breakReceiving == true then
- break
- end
- end
- end
- Menu()
- while true do
- local event1,p1 = t:handleEvents(os.pullEvent())
- if event1 == "button_click" and p1 =="ItemList" then
- t:flash(p1)
- RemoveButton()
- DisplayInfo()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement