Advertisement
Guest User

craftAPI

a guest
Jun 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. if recpipes == nil then recipes = {} end
  2. function find(list,item)
  3.     for k,v in pairs(list) do
  4.         if v == item then return true end
  5.         end
  6.     return false
  7. end
  8.  
  9. function add(result)
  10.     recipes[result] = {}
  11.     for i= 1, 11 do
  12.         if i ~= 4 and i ~= 8 then
  13.             local data = turtle.getItemDetail(i)
  14.             if data ~= nil then
  15.                 if recipes[result][data.name] == nil then recipes[result][data.name] = {{},'empty'} end
  16.                 table.insert(recipes[result][data.name][1],i)
  17.             end
  18.         end
  19.     end
  20.     for k,v in pairs(recipes[result]) do
  21.         local count = 0
  22.         for o in pairs(v[1]) do count = count + 1  
  23.         recipes[result][k][2] = count
  24.  
  25.     end
  26. end
  27.  
  28. function search(direction,item)
  29.     inv = peripheral.wrap(direction)
  30.     local list = inv.list()
  31.     for i=1, inv.size() do
  32.         if list[i].name == item then return i,list[i].count end
  33.     end
  34.     return false
  35. end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement