Advertisement
fatboychummy

smeltyboi

Nov 5th, 2018
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.87 KB | None | 0 0
  1. --[[
  2. slot 1 = smelt item slot
  3. slot 2 = fuel
  4. slot 3 = output
  5. ]]
  6.  
  7.  
  8. local chests = {}
  9. local outputChest = "quark:quark_chest_648"
  10. local bufferChest = "minecraft:chest_1283"
  11. local furnaces = {}
  12. local cache = {}
  13. local fi = 1
  14. local find, count = ...
  15. local mon = peripheral.find( "monitor" )
  16. if mon then mon.setTextScale( 0.5 ) term.redirect( mon ) end
  17.  
  18.  
  19. local function deepCopy( from, to )
  20.   if type( from ) == "table" then
  21.     for k, v in pairs( from ) do
  22.       if type( v ) == "table" then
  23.         to[ k ] = {}
  24.         deepCopy( v, to[ k ] )
  25.       else
  26.         to[ k ] = v
  27.       end
  28.     end
  29.   end
  30. end
  31.  
  32. local getChests = function()
  33.   local a = peripheral.getNames()
  34.   chests = {}
  35.   for i = 1,#a do
  36.     if a:find( "chest" ) then
  37.       if a ~= outputChest and a ~= bufferChest then
  38.         chests[ #chests + 1 ] = a[ i ]
  39.       end
  40.     end
  41.   end
  42. end
  43.  
  44. local getFurnaces = function()
  45.   local a = peripheral.getNames()
  46.   furnaces = {}
  47.   for i = 1,#a do
  48.     if a[ i ]:find( "furnace" ) then
  49.       furnaces[ #furnaces + 1 ] = a[ i ]
  50.     end
  51.   end
  52. end
  53.  
  54. local notify = function( gb, ... )
  55.   local args = { ... }
  56.   for i = 1,#args do
  57.     if gb then
  58.       print( args[ i ] )
  59.     else
  60.       printError( args[ i ] )
  61.     end
  62.   end
  63. end
  64.  
  65. local checkFurnace = function( furnace )
  66.   local furn = peripheral.wrap( furnace )
  67.   if type( furn ) == "table" then
  68.     local inv = furn.list()
  69.     return true, inv
  70.   else
  71.     notify( false, "Failed to find furnace " .. tostring( furnace ) )
  72.     return false
  73.   end
  74. end
  75.  
  76. local updateCache = function()
  77.   local buf = peripheral.wrap( bufferChest )
  78.   local inv = buf.list()
  79.   cache = {}
  80.   deepCopy( inv, cache )
  81. end
  82.  
  83. updateCache()
  84. print( textutils.serialize( cache ) )
  85. print( "---" )
  86. getFurnaces()
  87. for i = 1,#furnaces do
  88.   print( textutils.serialize( {checkFurnace( furnaces[ i ] )} ) )
  89.   print( "---" )
  90. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement