Lua scripts for the computercraft mod for minecraft
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

76 lines
1.7 KiB

local args = { ... }
--[[
local function placeholder() return true end
local turtle = {}
turtle.up = placeholder
turtle.down = placeholder
turtle.digUp = placeholder
turtle.digDown = placeholder
turtle.dig = placeholder
turtle.forward = placeholder
turtle.turnLeft = placeholder
turtle.turnRight = placeholder
turtle.detect = placeholder
turtle.getItemCount = placeholder
turtle.placeDown = placeholder
]]
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)
itemCount = turtle.getItemCount(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