Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local fuelSlot = 1
- local seedSlot = 2
- -- Wheat has all other slots? Or just 3, idk
- local wheatSlot = 3
- local testSlot = 4
- local inferiumSlot = 5
- local items = {}
- items["minecraft:wheat"] = 3
- items["mysticalagriculture:inferium_crop"] = 5
- items["minecraft:wheat_seeds"] = 2
- items["mysitcalagriculture:inferium_essence"] = 5
- -- Note, a working version is at pastebin.com/XwrptbCf
- function fixSlot(slotNum)
- -- Checks the item in the selected slot...
- -- If it's one of the items that we track, make sure it's in the right slot...
- if slotNum == nil then slotNum = turtle.getSelectedSlot() end -- Just for my purposes, it would have worked in getItemDetail
- local data = turtle.getItemDetail(slotNum)
- local drop = true
- if data ~= nil then
- print("Slot " .. slotNum .. " has item named ", data.name)
- if items[data.name] ~= nil and items[data.name] ~= slotNum then
- -- It's an item we track, and it's in the wrong slot. Try to move it
- print("Transferring from current to ", items[data.name])
- if turtle.transferTo(items[data.name]) then drop = false print("Transfer Succeeded") end
- elseif items[data.name] ~= nil and items[data.name] == slotNum then
- drop = false
- end
- if drop then
- -- If anything is left, or isn't in our map, turn to the side and drop it
- print("Transfer failed or item not recognized, dropping")
- turtle.turnRight()
- turtle.drop()
- turtle.turnLeft()
- end
- end
- end
- turtle.refuel()
- while(true) do
- -- Check if there's a chest in front of it, to refuel or offload wheat
- success,data = turtle.inspect()
- if success then
- print("Looking for chest, name: ", data.name)
- for k,v in pairs(data.state) do
- print("data.state." .. k, v)
- end
- for k,v in pairs(data.tags) do
- print("data.tags." .. k,v)
- end
- if data.tags["forge:chests"] then
- -- Put in everything that isn't seeds
- for k,v in pairs(items) do
- if k ~= "minecraft:wheat_seeds" then
- turtle.select(v)
- turtle.drop()
- end
- end
- end
- end
- turtle.turnRight()
- -- Inspect the block in front of it
- local success, data = turtle.inspect()
- if success then
- -- data contains fields: name, tags, state
- print("Name: ", data.name)
- -- inferium_crop
- -- if items.containsKey(data.name)
- if data.name == "minecraft:wheat" or data.name == "mysticalagriculture:inferium_crop" then
- --if data.state.age == 7 then
- turtle.select(seedSlot)
- turtle.place()
- turtle.select(items[data.name])
- turtle.suck()
- fixSlot()
- turtle.select(seedSlot)
- turtle.suck()
- fixSlot()
- --end
- end
- turtle.turnLeft() -- Turn back forward
- end -- If there's nothing in front of it, it can just keep going that way.
- if not turtle.forward() then -- Do a 180
- turtle.turnLeft()
- turtle.turnLeft()
- end
- -- After everything, check all slots... if wheat is found, try to move to wheatslot
- -- etc
- end
- -- For wheat, an age of 7 is what we want. Name is "minecraft:wheat"
- -- We get that from data.state.age
Add Comment
Please, Sign In to add comment