Advertisement
iPeer

Untitled

May 26th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. state = {
  2.   lastMessage = nil,
  3.   target = 4   -- change this to your monitor computer's id
  4. }
  5.  
  6. util = {
  7.   send = function(msg, force)
  8.     if msg ~= nil and state.lastMessage ~= msg or force then
  9.       print("Sending message: "..msg)
  10.       rednet.send(state.target, msg)
  11.       state.lastMessage = msg
  12.     end
  13.   end,
  14.   sendSerialized = function(msg, force)
  15.     if msg ~= nil then
  16.       util.send(textutils.serialize(msg), force)
  17.     end
  18.   end,
  19.   hasItems = function()
  20.     for i = 1, 16 do
  21.       if turtle.getItemCount(i) > 0 then
  22.         return true
  23.       end
  24.     end
  25.    
  26.     return false
  27.   end,
  28.   dropItems = function()
  29.     for i = 1, 16 do
  30.       if turtle.getItemCount(i) > 0 then
  31.         turtle.select(i)
  32.         turtle.dropDown()
  33.         sleep(.5)
  34.       end
  35.     end
  36.     turtle.select(1)
  37.   end
  38. }
  39.  
  40. local scanner = peripheral.wrap("left")
  41. rednet.open("right")
  42.  
  43. while true do
  44. --  print("Checking aspects")
  45.   local aspects = scanner.getAspectsDown()  
  46.   -- print the aspects
  47.   for k,v in pairs(aspects) do
  48.     print(k..": "..v)
  49.   end
  50.  
  51.   if next(aspects) == nil then
  52.     util.send("none")
  53.   else
  54.     util.sendSerialized(aspects)
  55.   end
  56.  
  57.   if util.hasItems() then
  58.     print("Dropping items in to crucible.")
  59.     util.dropItems()
  60.   end
  61.  
  62.   sleep(1)
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement