Guest User

craft

a guest
Jul 15th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. local tArgs = {...}
  2. local p = peripheral.wrap("bottom")
  3.  
  4. local product = p.getStackInSlot(1)
  5. local recipe = {product = product.display_name, schematic = {}, ingredient = {}}
  6. for i=2, 82 do
  7.   local slot = p.getStackInSlot(i)
  8.   local name = slot.display_name
  9.   if slot then
  10.     recipe.schematic[i] = name
  11.     if recipe.ingredient[name] then
  12.       recipe.ingredient[name] = recipe.ingredient[name] + slot.qty
  13.     else
  14.       recipe.ingredient[name] = slot.qty
  15.     end
  16.   end
  17. end
  18.  
  19. local c = peripheral.wrap("top")
  20. local chestSize = c.getInventorySize()
  21. local chest = {quantity={}}
  22. for i=1, chestSize do
  23.   local slot = c.getStackInSlot(i)
  24.   if slot then
  25.     local name = slot.display_name
  26.     chest[i] = name
  27.     if chest.quantity[name] then
  28.       chest.quantity[name] = chest.quantity[name] + slot.qty
  29.     else
  30.       chest.quantity[name] = slot.qty
  31.     end  
  32.   end
  33. end
  34.  
  35. for k,v in pairs(recipe.ingredient) do
  36.   local name = k
  37.   local required = v
  38.   local available = chest.quantity[k]
  39.   if available >= required then
  40.     term.setTextColor(colors.green)
  41.     print(k.." | "..available.."/"..v)
  42.   else
  43.     term.setTextColor(colors.red)
  44.     print(k.." : "..available.."/"..v)
  45.   end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment