Advertisement
Guest User

display

a guest
May 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. local monitor = peripheral.wrap("right")
  2. local modem = peripheral.wrap("back")
  3. modem.open(1)
  4. local w,h = monitor.getSize()
  5. local number_of_liquids = 1
  6. local columns_per_liquid = w/number_of_liquids
  7. local timesgraphed = 0
  8. local liquids = {water}
  9. while true do
  10. for i=1,number_of_liquids,1 do
  11.   modem.transmit(i,i,"callback")
  12.   local event, modemSide, SenderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  13.   liquids[SenderChannel] = message
  14.  
  15. monitor.setBackgroundColor(colors.white)
  16.  
  17. event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  18. monitor.clear()
  19. sleep(.5)
  20. end
  21. function graphliquid(amount,max,color)
  22.   local ratio = amount/max
  23.   local pixelheight = ratio*h
  24.   local cursorstart = (timesgraphed*columns_per_liquid)+1
  25.   timesgraphed = timesgraphed + 1
  26.   for i = h,((h+1)-pixelheight),-1 do
  27.     monitor.setTextColor(colors.white)
  28.     monitor.setBackgroundColor(color)
  29.     monitor.setCursorPos(cursorstart,i)
  30.     monitor.write(string.rep(" ",columns_per_liquid))
  31.   end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement