1
Fork 0
This repository has been archived on 2025-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
computer-craft/makefloor
2012-04-29 20:44:31 +02:00

57 lines
1.3 KiB
Text

local args = { ... }
turnedLeft = nil
if args[1] == "rightturn" or args[1] == "leftturn" then
local turnedLeft = args[1] == "rightturn"
else
print("usage: \"makefloor [leftturn|rightturn] whatever the first turn may be")
return
end
local curContainer = 1
local function selectMatStack()
itemCount = turtle.getItemCount(curContainer)
while itemCount == 0 do
if curContainer == 10 then
return false
end
curContainer = curContainer + 1
turtle.select(curContainer)
end
return true
end
local function checkIfNextTurn()
if turnedLeft then turnAction = turtle.TurnRight else turnAction = turtle.TurnLeft end
turnAction()
retval = not turtle.detect()
if not turnedLeft then turnAction = turtle.TurnRight else turnAction = turtle.TurnLeft end
turnAction()
return retval
end
local function fillblock()
shouldTurn = turtle.detect()
if shouldTurn then
couldTurn = checkIfNextTurn()
end
turtle.up()
if not selectMatStack() then
return false
end
turtle.placeDown()
if shouldTurn then
if turnedLeft then turnAction = turtle.TurnRight else turnAction = turtle.TurnLeft end
turnAction()
turtle.forward()
turnAction()
turnedLeft = not turnedLeft
else
turtle.forward()
turtle.down()
end
end
while fillblock() do end