Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap("right")
- local modem = peripheral.wrap("back")
- modem.open(1)
- local w,h = monitor.getSize()
- local number_of_liquids = 1
- local columns_per_liquid = w/number_of_liquids
- local timesgraphed = 0
- local liquids = {water}
- while true do
- for i=1,number_of_liquids,1 do
- modem.transmit(i,i,"callback")
- local event, modemSide, SenderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- liquids[SenderChannel] = message
- monitor.setBackgroundColor(colors.white)
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- monitor.clear()
- sleep(.5)
- end
- function graphliquid(amount,max,color)
- local ratio = amount/max
- local pixelheight = ratio*h
- local cursorstart = (timesgraphed*columns_per_liquid)+1
- timesgraphed = timesgraphed + 1
- for i = h,((h+1)-pixelheight),-1 do
- monitor.setTextColor(colors.white)
- monitor.setBackgroundColor(color)
- monitor.setCursorPos(cursorstart,i)
- monitor.write(string.rep(" ",columns_per_liquid))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement