Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local REG_TRACK_COUNT = 37
- local POWER_TRACK_COUNT = 1
- local rt = 1
- local pt = 2
- local totalDistance = 0
- if #arg == 1 then
- totalDistance = tonumber(arg[1])
- else
- print("Please give total count of track iterations to lay so I don't go on forever.")
- end
- function regTrack()
- local curSlot = nextSlot("minecraft:rail")
- if curSlot ~= false then
- turtle.select(curSlot)
- else
- return false
- end
- for i = 1, REG_TRACK_COUNT do
- local checkStatus = checkFront()
- print(checkStatus)
- if checkStatus ~= false then
- if checkStatus == "minecraft:wall_torch" then
- print("regTrack: Torch detected.")
- else
- print("regTrack: Block in the way")
- return false
- end
- else
- turtle.forward()
- if slotCount(curSlot) < 0 then
- turtle.placeDown(1)
- else
- curSlot = nextSlot("minecraft:rail")
- if curSlot ~= false then
- turtle.select(curSlot)
- turtle.placeDown(1)
- else
- return false
- end
- end
- end
- end
- return true
- end
- function powTrack()
- local curSlot = nextSlot("minecraft:powered_rail")
- if curSlot ~= false then
- turtle.select(curSlot)
- else
- return false
- end
- for i = 1, POWER_TRACK_COUNT do
- local checkStatus = checkFront()
- if checkStatus ~= false then
- if checkStatus == "minecraft:wall_torch" then
- print("powTrack: Torch detected.")
- else
- print("powTrack: Block in the way")
- return false
- end
- else
- turtle.forward()
- if slotCount(curSlot) < 0 then
- turtle.placeDown(1)
- else
- curSlot = nextSlot("minecraft:powered_rail")
- if curSlot ~= false then
- turtle.select(curSlot)
- turtle.placeDown(1)
- else
- return false
- end
- end
- end
- end
- return true
- end
- function slotCount(s)
- turtle.select(s)
- return turtle.getItemCount(s)
- end
- function nextSlot(t)
- print(t)
- for i = 1, 16 do
- if turtle.getItemCount(i) > 0 then
- if turtle.getItemDetail(i)["name"] == t then
- return i
- end
- end
- end
- return false
- end
- function checkFront()
- local success, data = turtle.inspect()
- if success then
- return data.name
- else
- return false
- end
- end
- turtle.up()
- for i=1, totalDistance do
- if regTrack() == true then
- --print("Layed reg track set.")
- if powTrack() == true then
- --print("Layed power track set.")
- else
- print("Power track error.")
- end
- else
- print("Reg track error.")
- end
- end
Add Comment
Please, Sign In to add comment