Dimencia

Untitled

Mar 22nd, 2021
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 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.  
  13. -- Note, a working version is at pastebin.com/XwrptbCf
  14.  
  15. function fixSlot(slotNum)
  16. -- Checks the item in the selected slot...
  17. -- If it's one of the items that we track, make sure it's in the right slot...
  18. if slotNum == nil then slotNum = turtle.getSelectedSlot() end -- Just for my purposes, it would have worked in getItemDetail
  19. local data = turtle.getItemDetail(slotNum)
  20. local drop = true
  21. if data ~= nil then
  22. if items[data.name] ~= nil and items[data.name] ~= slotNum then
  23. -- It's an item we track, and it's in the wrong slot. Try to move it
  24. if turtle.transferTo(items[data.name]) then drop = false end
  25. end
  26. if drop then
  27. -- If anything is left, or isn't in our map, turn to the side and drop it
  28. turtle.turnRight()
  29. turtle.drop()
  30. turtle.turnLeft()
  31. end
  32. end
  33. end
  34.  
  35. turtle.refuel()
  36. while(true) do
  37. -- Check if there's a chest in front of it, to refuel or offload wheat
  38. success,data = turtle.inspect()
  39. if success then
  40. print("Looking for chest, name: ", data.name)
  41. for k,v in pairs(data.state) do
  42. print("data.state." .. k, v)
  43. end
  44. for k,v in pairs(data.tags) do
  45. print("data.tags." .. k,v)
  46. end
  47. if data.tags["forge:chests"] then -- quark:birchchest is mine... has to be a better way...
  48. -- Pick up whatever's in it into slot 4
  49. turtle.select(testSlot)
  50. turtle.suck()
  51. -- See what we picked up
  52. local slotdata = turtle.getItemDetail()
  53. if slotdata ~= nil then
  54. print("Slot name: ", slotdata.name)
  55. if slotdata.name == "minecraft:wheat" then
  56. -- Put it back, and put any wheat we have in there
  57. turtle.drop()
  58. turtle.select(wheatSlot)
  59. turtle.drop()
  60. elseif slotdata.name == "minecraft:coal" then
  61. if not turtle.transferTo(fuelSlot) then
  62. turtle.drop() -- Put any leftovers back
  63. end
  64. end
  65. else
  66. -- If there was nothing in the chest, put wheat and inferium in
  67. turtle.select(wheatSlot)
  68. turtle.drop()
  69. turtle.select(inferiumSlot)
  70. turtle.drop()
  71. end
  72. end
  73. end
  74. turtle.turnRight()
  75. -- Inspect the block in front of it
  76. local success, data = turtle.inspect()
  77. if success then
  78. -- data contains fields: name, tags, state
  79. print("Name: ", data.name)
  80. -- inferium_crop
  81. if data.name == "minecraft:wheat" or data.name == "mysticalagriculture:inferium_crop" then
  82. --if data.state.age == 7 then
  83. turtle.select(seedSlot)
  84. turtle.place()
  85. turtle.select(wheatSlot)
  86. turtle.suck()
  87. fixSlot()
  88. -- If this isn't wheat, try to move it to the right slot, and then drop it
  89. turtle.select(inferiumSlot)
  90. turtle.suck()
  91. fixSlot()
  92. turtle.select(seedSlot)
  93. turtle.suck()
  94. fixSlot()
  95. --end
  96. end
  97. turtle.turnLeft() -- Turn back forward
  98. end -- If there's nothing in front of it, it can just keep going that way.
  99. if not turtle.forward() then -- Do a 180
  100. turtle.turnLeft()
  101. turtle.turnLeft()
  102. end
  103.  
  104.  
  105. -- After everything, check all slots... if wheat is found, try to move to wheatslot
  106. -- etc
  107.  
  108. end
  109.  
  110. -- For wheat, an age of 7 is what we want. Name is "minecraft:wheat"
  111. -- We get that from data.state.age
  112.  
  113.  
  114.  
Add Comment
Please, Sign In to add comment