Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Mock turtle API
- --[[
- local turtle = {
- forward = function() end,
- turnRight = function() end,
- turnLeft = function() end,
- placeDown = function() end,
- getSelectedSlot = function()
- return 0
- end,
- getItemCount = function(_)
- return 0
- end,
- }
- local math = {
- fmod = function(_, _)
- return 0
- end,
- }
- local os = {
- sleep = function(_) end,
- }
- --]]
- local function placeDown()
- while not turtle.placeDown() do
- for i = 1, 16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- break
- end
- if i == 16 then
- os.sleep(10)
- end
- end
- end
- end
- local x, y = ...
- print("Filling a rectangle with sides " .. x .. " and " .. y)
- for i = 1, y do
- turtle.forward()
- if math.fmod(i, 2) == 1 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- for _ = 1, x - 1 do
- placeDown()
- turtle.forward()
- end
- placeDown()
- if math.fmod(i, 2) == 1 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement