Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- replace block turtle program
- replaceTheseBlocks = {"minecraft:stripped_birch_log","minecraft:dirt",""}
- replaceBlocksWith = {"minecraft:birch_log"}
- function getName(inspectionDirection)
- local isBlock,details = inspectionDirection()
- local name = "undefined"
- if isBlock then
- name = details.name
- else
- name = ""
- end
- return name
- end
- function getNameForward()
- local name = getName(turtle.inspect)
- return name
- end
- function isNameForward(tab_names)
- local blockName = getNameForward()
- for i,v in pairs(tab_names) do
- if blockName == v then
- return true
- end
- end
- return false
- end
- function isSlotOccupied(slot)
- local cnt = turtle.getItemCount(slot)
- return cnt > 0
- end
- function getSlotItemName(slot)
- local detail = turtle.getItemDetail(slot)
- if detail ~= nil then
- return detail.name
- else
- return ""
- end
- end
- function findSlotWith(tab_names)
- for i=1,16 do
- if isSlotOccupied(i) then
- --turtle.select(i)
- local name = getSlotItemName(i)
- for i2,v in pairs(tab_names) do
- if name == v then
- return tonumber(i)
- end
- end
- end
- end
- --no match
- return "no match"
- end
- function replaceWithSlot()
- local slot = findSlotWith(replaceBlocksWith)
- --print(slot)
- if slot == "no match" then
- print("None of item found. Please add more items")
- while findSlotWith(replaceBlocksWith) == "no match" do
- sleep(1)
- write(".")
- end
- else
- return slot
- end
- --print(slot)
- --return 2
- end
- function main()
- if isNameForward(replaceTheseBlocks) then
- print("replacable block detected")
- local a,b= turtle.dig()
- if not a then
- print(tostring(a)..": "..b)
- end
- turtle.suck()
- turtle.select(replaceWithSlot())
- turtle.place()
- end
- end
- function info()
- end
- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
- info()
- while true do
- main()
- end
Add Comment
Please, Sign In to add comment