Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Torch(param)
- if math.fmod(param, 7) == 0 then
- if turtle.getItemCount(UsedSlot) > 0 then
- if UsedSlot <= TorchSlots then
- turtle.placeUp()
- end
- else
- UsedSlot = UsedSlot + 1
- if UsedSlot <= TorchSlots then
- turtle.select(UsedSlot)
- turtle.placeUp()
- else
- print("Reached max slot, no more lighting")
- end
- end
- end
- end
- tArgs = { ... }
- if #tArgs ~= 4 then
- local tHelp
- tHelp = "Usage: shaft [length of shaft] [length of nodes] [distance of 1 and 2 nodes] [slots for torchs] \nThis program will dig up shaft. Every node in that shaft that's twice splitting, which length defines in arguments \nWell, when it digged up it, it return to the centre, where node are started, and dig so much so you define in third argument \nProgram almost automaticly, but it require some special conditions \nFirst - turtle don't collect a ore, you should dig or gather it yourself \nSecond - slots for torchs means that number, which show how much stacks of torches have your turtle. You must fill turtle with torch from first slot, and futher. Very good if every slot would contain 64 torchs \nTurtle should put up a torchs every 7 blocks because torch have seven level of lighting \nLast slot MUST be contain some gravel otherwise when turtle meets gravel, than it wouldn't works normally \nby EditorRUS"
- textutils.pagedPrint(tHelp)
- return 0
- end
- ShaftLength = math.abs(tonumber(tArgs[1]))
- NodeLength = math.abs(tonumber(tArgs[2]))
- Distance = math.abs(tonumber(tArgs[3]))
- TorchSlots = math.abs(tonumber(tArgs[4]))
- UsedSlot = 1
- if TorchSlots > 15 then
- print("Too much slots for torchs")
- return 0
- end
- NeededTorchs = (NodeLength / 7 * 2) + (Distance * ShaftLength / 7)
- NeededFuel = (NodeLength * 2 + Distance) * ShaftLength
- if NeededFuel > turtle.getFuelLevel() then
- print("Not enough fuel, now value is ", tostring(turtle.getFuelLevel()), ", needed more or equal " , tostring(NeededFuel))
- return 0
- end
- local RNofTorches = 0
- for i=1, TorchSlots do
- RNofTorches = RNofTorches + turtle.getItemCount(i)
- end
- if RNofTorches < NeededTorchs then
- print("That count of torch not enough for fully lighting a shaft.")
- local answer = "n"
- while 1 do
- print("Do you want continue? Y/N")
- answer = read()
- if answer == "N" then return 0 end
- if answer == "Y" then break end
- end
- end
- for i = 1, ShaftLength do
- for j = 1, 2 do
- if j == 1 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for k=1, NodeLength do
- local old = UsedSlot
- turtle.select(16)
- while turtle.compare() do
- turtle.dig()
- end
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.select(old)
- Torch(k)
- if k == NodeLength then
- turtle.turnRight()
- turtle.turnRight()
- for a=1, NodeLength do
- turtle.forward()
- end
- if j == 1 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- end
- end
- for a=1, Distance do
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- if turtle.detectUp() then
- turtle.digUp()
- end
- Torch(a)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement