Guest User

glass

a guest
Sep 29th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. glass = peripheral.wrap("top")
  2. item = peripheral.wrap("right")
  3.  
  4. rednet.open( "back" )
  5.  
  6. -- We always reset when starting back up
  7. glass.clear()
  8.  
  9. container = glass.addBox( 10, 10, 102, 30, 0x000000, 0.3 )
  10. helpText = glass.addText( 27, 15, "Items queued: ", 0xFFFFFF )
  11. itemCount = glass.addText( 45, 25, "0", 0xFFFFFF )
  12. timeText = glass.addText( 457, 75, " ", 0xFFFFFF )
  13.  
  14. -- Various settings go here, the ones that won't change
  15. timeText.setScale( 0.6 )
  16.  
  17. -- Fancy borders
  18. borderTop = glass.addBox( 11, 45, 100, 1, 0x000000, 1 )
  19. borderLeft = glass.addBox( 10, 45, 1, 7, 0x000000, 1 )
  20. borderRight = glass.addBox( 111, 45, 1, 7, 0x000000, 1 )
  21. borderBottom = glass.addBox( 11, 51, 100, 1, 0x000000, 1 )
  22.  
  23. -- Quarry status
  24. statusQuarry = glass.addText( 40, 55, "Quarry", 0xFF0000 )
  25.  
  26. while true do
  27.   items = 0
  28.   types = 0
  29.   device = ""
  30.  
  31.   senderID, message, distance = rednet.receive()
  32.   print( senderID .. ": " .. message )
  33.  
  34.   for i in string.gmatch( message,  "%S+" ) do
  35.     if not device then
  36.       device = i
  37.     else
  38.       if i == "off" then
  39.         statusQuarry.setColor( 0x229000 )
  40.       else
  41.         statusQuarry.setColor( 0xFF0000 )
  42.       end
  43.     end
  44.   end
  45.  
  46.   rednet.broadcast( "get quarry" )
  47.  
  48.   local time = os.time()
  49.   time = textutils.formatTime( time, true )
  50.  
  51.   timeText.setText( " " .. time )
  52.    
  53.   itemList = item.list(5)
  54.  
  55.   for key,value in pairs( itemList ) do
  56.     types = types + 1
  57.     items = items + value
  58.   end
  59.  
  60.   itemCount.setText( " " .. types .. " (" .. items .. ")" )
  61.  
  62.   -- Here we calculate a percentage of the item pressure
  63.  
  64.  
  65.   -- Color code the count text
  66.   if types < 3 then
  67.     itemCount.setColor( 0x229000 )
  68.   elseif items < 7 then
  69.     itemCount.setColor( 0x00FFFF )
  70.   elseif items < 15 then
  71.     itemCount.setColor( 0xFFFF00 )
  72.   else
  73.     itemCount.setColor( 0xFF0000 )
  74.   end
  75.  
  76.   sleep(1)
  77. end
  78.  
  79. rednet.close( "back" )
Advertisement
Add Comment
Please, Sign In to add comment