Advertisement
Guest User

craft.lua

a guest
Aug 17th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. local component = require("component")
  2. local fs = require("filesystem")
  3. local json = require("json")
  4.  
  5. local r = component.robot
  6. local ic = component.inventory_controller
  7. local craft = component.crafting
  8.  
  9. local databaseFile = "/home/recipes.db"
  10.  
  11. local db = fs.open(databaseFile,"r")
  12. local jsonRaw = db:read(fs.size(databaseFile))
  13. local recipes = json.decode(jsonRaw)
  14.  
  15. local slots = {1,2,3,5,6,7,9,10,11}
  16.  
  17. local chestSide = 4
  18.  
  19. local recipe = {}
  20. local target = "5"
  21. for i=1,9 do
  22.   table.insert(recipe,recipes[target]["r"][i..""])
  23. end
  24.  
  25. for k,v in pairs(recipe) do
  26.   print(k..": "..v)
  27. end
  28.  
  29. for i=1,9 do
  30.   r.select(slots[i])
  31.   findItem(recipe[i])
  32. end
  33.  
  34. r.select(4)
  35. craft.craft()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement