Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ms = require("movescript")
- local robot = require("robot")
- local component = require("component")
- local ic = component.inventory_controller
- local function equipItemOrWait(name)
- repeat
- local success = ms.selectItem(name)
- if not success then
- print("Please add more " .. name .. ", then press enter.")
- io.read()
- end
- until success
- ic.equip()
- end
- local function goToNextSpot()
- equipItemOrWait("pickaxe")
- while robot.detect() do
- ms.exec("d_U")
- end
- ms.exec("F")
- while not robot.detectDown() do
- ms.exec("d_D")
- end
- ms.exec("d_U")
- end
- local function plantSpot(cropName)
- repeat
- equipItemOrWait("hoe")
- robot.useDown()
- equipItemOrWait(cropName)
- local success = robot.useDown()
- until success
- end
- local function plantArea(length, width, cropName)
- goToNextSpot()
- plantSpot(cropName)
- ms.exec("R")
- for row = 1, length do
- for col = 1, width - 1 do
- goToNextSpot()
- plantSpot(cropName)
- end
- if row % 2 == 1 then
- ms.exec("L")
- else
- ms.exec("R")
- end
- if row ~= length then
- goToNextSpot()
- plantSpot(cropName)
- end
- if row % 2 == 1 then
- ms.exec("L")
- else
- ms.exec("R")
- end
- print("Completed row " .. row .. " of " .. length)
- end
- end
- local args = {...}
- local length = tonumber(args[1])
- local width = tonumber(args[2])
- local cropName = args[3]
- if not length or not width or not cropName then
- error("Invalid args.")
- end
- print("Planting an area " .. length .. " by " .. width .. " with " .. cropName .. ".")
- plantArea(length, width, cropName)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement