Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PlaceTorch()
- for a = 1, 16 do
- turtle.select(a)
- c = turtle.getItemCount(a)
- if c == 0 then
- else
- s = turtle.getItemDetail(a)
- if s.name == "minecraft:torch" then
- turtle.placeDown()
- return
- end
- end
- end
- end
- local tArgs = {...}
- if #tArgs ~= 3 then
- print("Requires length, width & height!")
- return
- end
- local x = tonumber(tArgs[1]) - 1
- local y = tonumber(tArgs[2])
- local z = tonumber(tArgs[3])
- local x2 = 0
- local y2 = 0
- local startingtorch = false
- local distance = 0
- local countdown = false
- if x == nil or y == nil or z == nil then
- print("Invalid dimensions!")
- return
- end
- if x < 0 or y < 0 or z < 0 then
- print("Invalid (negative) dimensions!")
- return
- end
- local fuel = turtle.getFuelLevel()
- local roomSize = x * y * z
- while fuel < roomSize do
- if not turtle.refuel(1) then
- print("Not enough fuel!")
- return
- end
- end
- local xTimes = x + 1
- local yTimes = y
- local xTorches = 0
- local yTorches = 0
- local t = true
- local tt = true
- while t == true do
- if xTimes >= 4 then
- xTimes = xTimes - 4
- xTorches = xTorches + 1
- elseif xTimes < 4 and xTimes > 0 then
- xTorches = xTorches + 1
- t = false
- elseif xTimes == 1 then
- xTorches = xTorches + 1
- t = false
- else
- t = false
- if xTimes == 0 then
- xTimes = 4
- end
- end
- end
- while tt == true do
- if yTimes >= 4 then
- yTimes = yTimes - 4
- yTorches = yTorches + 1
- elseif yTimes < 4 and yTimes > 0 then
- yTorches = yTorches + 1
- tt = false
- elseif yTimes == 1 then
- yTorches = yTorches + 1
- tt = false
- else
- tt = false
- if yTimes == 0 then
- yTimes = 4
- end
- end
- end
- local RequiredTorches = xTorches * yTorches
- local Torches = 0
- for a = 1, 16 do
- turtle.select(a)
- c = turtle.getItemCount(a)
- if c == 0 then
- else
- s = turtle.getItemDetail(a)
- if s.name == "minecraft:torch" then
- Torches = Torches + c
- end
- end
- end
- if RequiredTorches > Torches and z > 1 then
- print("Not enough Torches! You require a total of " .. RequiredTorches .. " Torches!")
- return
- else
- print("Good to go!")
- end
- local direction = true
- for i = 1, z do
- for j = 1, y do
- for k = 1, x do
- if i == 2 and j == yTimes and k == xTimes then
- PlaceTorch()
- startingtorch = true
- end
- if turtle.forward() == false then
- repeat
- turtle.dig()
- sleep(0.25)
- until turtle.forward() == true
- end
- if i == 2 and startingtorch == true then
- if countdown == false then
- x2 = x2 + 1
- if x2 == 4 then
- PlaceTorch()
- x2 = 0
- end
- elseif countdown == true then
- distance = distance + 1
- if xTimes == 1 then
- if distance == (x + 1) * 3 + 1 then
- distance = 0
- PlaceTorch()
- countdown = false
- end
- elseif xTimes == 2 then
- if distance == (x + 1) * 3 + 2 then
- distance = 0
- PlaceTorch()
- countdown = false
- end
- elseif xTimes == 3 then
- if distance == (x + 1) * 3 + 3 then
- distance = 0
- PlaceTorch()
- countdown = false
- end
- elseif xTimes == 4 then
- if distance == (x + 1) * 3 + 4 then
- distance = 0
- PlaceTorch()
- countdown = false
- end
- end
- end
- end
- end
- if j < y then
- if direction then
- if i == 2 and countdown == false and startingtorch == true then
- countdown = true
- end
- turtle.turnRight()
- if turtle.forward() == false then
- repeat
- turtle.dig()
- sleep(0.25)
- until turtle.forward() == true
- end
- if i == 2 and startingtorch == true and countdown == true then
- distance = distance + 1
- end
- turtle.turnRight()
- direction = false
- else
- turtle.turnLeft()
- if turtle.forward() == false then
- repeat
- turtle.dig()
- sleep(0.25)
- until turtle.forward() == true
- end
- if i == 2 and startingtorch == true and countdown == true then
- distance = distance + 1
- if xTimes == 1 then
- if distance == (x + 1) * 3 + 1 then
- distance = 0
- PlaceTorch()
- countdown = false
- end
- elseif xTimes == 2 then
- if distance == (x + 1) * 3 + 2 then
- distance = 0
- PlaceTorch()
- countdown = false
- end
- elseif xTimes == 3 then
- if distance == (x + 1) * 3 + 3 then
- distance = 0
- PlaceTorch()
- countdown = false
- end
- elseif xTimes == 4 then
- if distance == (x + 1) * 3 + 4 then
- distance = 0
- PlaceTorch()
- countdown = false
- end
- end
- end
- turtle.turnLeft()
- direction = true
- end
- end
- end
- if i < z then
- turtle.digUp()
- turtle.up()
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- if y % 2 == 0 then
- turtle.turnRight()
- for i = 1, y do
- turtle.forward()
- end
- turtle.turnRight()
- else
- turtle.turnLeft()
- for i = 1, y do
- turtle.forward()
- end
- turtle.turnLeft()
- for i = 1, x do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.turnRight()
- end
- for i = 1, z do
- turtle.down()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement