Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local slots = {1,2,3,5,6,7,9,10,11}
- local possibleCrafts = {"ladder","chest"}
- local SlotPlank = 13
- local SlotStick = 14
- function queryOptions()
- orderItems()
- listCraftings()
- local itemToCraft = tonumber(read())
- print("Define an amount")
- local itemAmount = tonumber(read())
- for i=1, itemAmount, 1 do
- arrangeForItem(itemToCraft)
- craftItems(1)
- end
- end
- function orderItems()
- for slot=1, 16 do
- turtle.select(slot)
- local itemData = turtle.getItemDetail()
- if itemData ~= nil then
- if itemData.name == "minecraft:stick" then
- turtle.transferTo(SlotStick)
- end
- if itemData.name == "minecraft:oak_planks" then
- turtle.transferTo(SlotPlank)
- end
- end
- end
- end
- function listCraftings()
- print("Select a recipe:")
- for key,value in ipairs(possibleCrafts) do
- print(key," ",value)
- end
- end
- function arrangeForItem(item)
- if item == 1 then
- placeItem(SlotStick,slots[1])
- placeItem(SlotStick,slots[3])
- placeItem(SlotStick,slots[4])
- placeItem(SlotPlank,slots[5])
- placeItem(SlotStick,slots[6])
- placeItem(SlotStick,slots[7])
- placeItem(SlotStick,slots[9])
- end
- end
- function placeItem(from,to)
- local originalSlot = turtle.getSelectedSlot()
- turtle.select(from)
- turtle.transferTo(to,1)
- turtle.select(originalSlot)
- end
- function craftItems(amount)
- turtle.select(4)
- turtle.craft()
- end
- local MaterialStick = "minecraft:stick"
- local MaterialPlanks = "minecraft:oak_planks"
- local RecipeLadder = {
- MaterialSticks,"",MaterialSticks,
- MaterialSticks,MaterialPlanks,MaterialSticks,
- MaterialSticks,"",MaterialSticks
- }
- function findMaterial(name)
- for slot=1, 16 do
- turtle.select(slot)
- local itemData = turtle.getItemDetail()
- if itemData ~= nil and itemData.name == name then
- return slot
- else
- return nil
- end
- end
- end
- function craftFromRecipe(materialArray)
- for slot=1 , #slots do
- local usedMaterialSlot = findMaterial(materialArray[slot])
- if usedMaterialSlot ~= nil then
- placeItem(usedMaterialSlot,slot)
- end
- end
- end
- craftFromRecipe(RecipeLadder)
Add Comment
Please, Sign In to add comment