Dimencia

Untitled

Mar 22nd, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. local fuelSlot = 1
  2. local seedSlot = 2
  3. -- Wheat has all other slots? Or just 3, idk
  4. local wheatSlot = 3
  5. local testSlot = 4
  6. local inferiumSlot = 5
  7.  
  8. local items = {}
  9. items["minecraft:wheat"] = 3
  10. items["mysticalagriculture:inferium_crop"] = 5
  11. items["minecraft:wheat_seeds"] = 2
  12. items["mysitcalagriculture:inferium_essence"] = 5
  13.  
  14. -- Note, a working version is at pastebin.com/XwrptbCf
  15.  
  16. function fixSlot(slotNum)
  17. -- Checks the item in the selected slot...
  18. -- If it's one of the items that we track, make sure it's in the right slot...
  19. if slotNum == nil then slotNum = turtle.getSelectedSlot() end -- Just for my purposes, it would have worked in getItemDetail
  20. local data = turtle.getItemDetail(slotNum)
  21. local drop = true
  22. if data ~= nil then
  23. print("Slot " .. slotNum .. " has item named ", data.name)
  24. if items[data.name] ~= nil and items[data.name] ~= slotNum then
  25. -- It's an item we track, and it's in the wrong slot. Try to move it
  26. print("Transferring from current to ", items[data.name])
  27. if turtle.transferTo(items[data.name]) then drop = false print("Transfer Succeeded") end
  28. elseif items[data.name] ~= nil and items[data.name] == slotNum then
  29. drop = false
  30. end
  31. if drop then
  32. -- If anything is left, or isn't in our map, turn to the side and drop it
  33. print("Transfer failed or item not recognized, dropping")
  34. turtle.turnRight()
  35. turtle.drop()
  36. turtle.turnLeft()
  37. end
  38. end
  39. end
  40.  
  41. turtle.refuel()
  42. while(true) do
  43. -- Check if there's a chest in front of it, to refuel or offload wheat
  44. success,data = turtle.inspect()
  45. if success then
  46. print("Looking for chest, name: ", data.name)
  47. for k,v in pairs(data.state) do
  48. print("data.state." .. k, v)
  49. end
  50. for k,v in pairs(data.tags) do
  51. print("data.tags." .. k,v)
  52. end
  53. if data.tags["forge:chests"] then
  54. -- Put in everything that isn't seeds
  55. for k,v in pairs(items) do
  56. if k ~= "minecraft:wheat_seeds" then
  57. turtle.select(v)
  58. turtle.drop()
  59. end
  60. end
  61. end
  62. end
  63. turtle.turnRight()
  64. -- Inspect the block in front of it
  65. local success, data = turtle.inspect()
  66. if success then
  67. -- data contains fields: name, tags, state
  68. print("Name: ", data.name)
  69. -- inferium_crop
  70. -- if items.containsKey(data.name)
  71. if data.name == "minecraft:wheat" or data.name == "mysticalagriculture:inferium_crop" then
  72. --if data.state.age == 7 then
  73. turtle.select(seedSlot)
  74. turtle.place()
  75. turtle.select(items[data.name])
  76. turtle.suck()
  77. fixSlot()
  78. turtle.select(seedSlot)
  79. turtle.suck()
  80. fixSlot()
  81. --end
  82. end
  83. turtle.turnLeft() -- Turn back forward
  84. end -- If there's nothing in front of it, it can just keep going that way.
  85. if not turtle.forward() then -- Do a 180
  86. turtle.turnLeft()
  87. turtle.turnLeft()
  88. end
  89.  
  90.  
  91. -- After everything, check all slots... if wheat is found, try to move to wheatslot
  92. -- etc
  93.  
  94. end
  95.  
  96. -- For wheat, an age of 7 is what we want. Name is "minecraft:wheat"
  97. -- We get that from data.state.age
  98.  
  99.  
  100.  
Add Comment
Please, Sign In to add comment