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_COUNT = 1
- local rt = 1
- local pt = 2
- local totalDistance = 0
- local PR = "minecraft:powered_rail"
- local RR = "minecraft:rail"
- local RT = "minecraft:redstone_torch"
- 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 layBlock(blockType, blockCount)
- local curSlot = nextSlot(blockType)
- for i = 1, blockCount do
- turtle.forward()
- if turtle.compareDown() == false then
- if curSlot ~= false then
- turtle.select(curSlot)
- if slotCount(curSlot) < 0 then
- turtle.placeDown(1)
- else
- curSlot = nextSlot(blockType)
- if curSlot ~= false then
- turtle.select(curSlot)
- turtle.placeDown(1)
- else
- print(blockType, " not found!")
- end
- end
- else
- print(blockType, " not found!")
- end
- else
- print(blockType, " already here")
- 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
- function redTorch()
- local retVal = false
- turtle.turnLeft()
- if layBlock(RT, RT_COUNT) == true then
- retVal = true
- end
- turtle.back()
- turtle.turnRight()
- return retVal
- end
- turtle.up()
- for i=1, totalDistance do
- if layBlock(RR, REG_TRACK_COUNT) == true then
- --print("Layed reg track set.")
- if layBlock(PR, POWER_TRACK_COUNT) == true then
- --print("Layed power track set.")
- if redTorch() == true then
- print("Layed a red stone torch.")
- else
- print("Red stone torch error.")
- end
- else
- print("Power track error.")
- end
- else
- print("Reg track error.")
- end
- end
Add Comment
Please, Sign In to add comment