Advertisement
natie3

Receive aspects

Sep 13th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. modem = peripheral.wrap("top")
  2. monitor1 = peripheral.wrap("right")
  3. monitor2 = peripheral.wrap("back")
  4. monitor1.setBackgroundColor(colors.black)
  5. monitor2.setBackgroundColor(colors.black)
  6. monitor1.clear()
  7. monitor2.clear()
  8. modem.open(100)
  9. rs.setOutput("left", true)
  10.  
  11. while true do
  12.   i = 3
  13.   j = 1
  14.   monitor = monitor1
  15.   event, modemside, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  16.   aspects = textutils.unserialize(message)
  17.   local sort_func = function( a,b ) return a.name < b.name end
  18.   table.sort( aspects, sort_func )
  19.   monitor.setBackgroundColor(colors.black)
  20.   monitor.clear()
  21.   for k, v in pairs(aspects) do
  22.     monitor.setCursorPos(j,i)
  23.     monitor.setBackgroundColor(colors.black)
  24.     monitor.write(v["name"])
  25.     monitor.setBackgroundColor(2)
  26.     for a = 1, (tonumber(v["quantity"])/3) do
  27.       monitor.setCursorPos(j+12+a,i)
  28.       monitor.write(" ")
  29.     end
  30.     monitor.setCursorPos(j+14,i)
  31.     monitor.write(v["quantity"])
  32.     i = i + 2
  33.     if i > 32 and j ~= 37 then
  34.       i = 3
  35.       j = 37
  36.     elseif i > 32 and j == 37 then
  37.       i = 3
  38.       j = 1
  39.       monitor = monitor2
  40.     end
  41.   end
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement