Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local com = require("component")
- local robot = require("robot")
- local exp = com.experience
- local gen = com.generator
- local magnet = com.tractor_beam
- local inv = com.inventory_controller
- local X, Y = 7, 17
- local LOGS, SAPS = 2, 1
- local DELAYNIGHT = 60
- local DELAYDAY = 10
- local EXP = exp.level()
- local function suck() end --further declaration...
- local function detect()
- _, detected = robot.detect()
- if detected == "entity" or detected == "solid" or detected == "passable" then
- robot.swing()
- end
- end
- local function forward()
- detect()
- while not robot.forward() do
- detect()
- os.sleep(0.5)
- end
- suck()
- end
- local function back()
- detect()
- while not robot.back() do
- os.sleep(0.5)
- end
- suck()
- end
- local function up()
- detect()
- while not robot.up() do
- os.sleep(0.5)
- end
- suck()
- end
- local function down()
- detect()
- while not robot.down() do
- os.sleep(0.5)
- end
- suck()
- end
- function suck()
- while not magnet.suck() == false do end
- end
- local function nextRow(start)
- local repeats = start and 1 or 4
- if not start == true then
- robot.turnLeft()
- end
- for i = 1, repeats, 1 do
- forward()
- end
- robot.turnRight()
- end
- local function checkAndFall()
- robot.select(LOGS)
- if robot.compare() == true then
- robot.swing()
- end
- os.sleep(0.25)
- if robot.detect() == false then
- robot.select(SAPS)
- robot.place()
- end
- suck()
- end
- -- === MAIN === ---
- while true do
- nextRow(true)
- for i = 1, X, 1 do
- for j = 1, Y, 1 do
- forward()
- robot.turnLeft()
- checkAndFall()
- robot.turnAround()
- checkAndFall()
- robot.turnLeft()
- if j ~= Y then
- forward()
- else
- for k = 1, Y * 2 - 1, 1 do
- back()
- end
- end
- end
- if i ~= X then
- nextRow(false)
- else
- robot.turnRight()
- for l = 1, (X - 1) * 4 + 1, 1 do
- forward()
- end
- for l = 1, robot.inventorySize(), 1 do
- robot.select(l)
- if l ~= LOGS and l ~= SAPS then
- if not exp.consume() then
- gen.insert()
- robot.drop()
- end
- end
- end
- robot.turnAround()
- end
- end
- robot.turnLeft()
- robot.select(robot.inventorySize())
- inv.equip()
- robot.drop()
- if tonumber(os.date("%H")) > 5 and tonumber(os.date("%H")) < 19 then
- DELAY = DELAYDAY
- else
- DELAY = DELAYNIGHT
- end
- for i = 1, DELAY, 1 do
- print(i.."/"..DELAY)
- print("Exp: " .. EXP .. " -> " .. exp.level() .. "L")
- os.sleep(1)
- end
- EXP = exp.level()
- inv.suckFromSlot(3, 1)
- inv.equip()
- robot.turnRight()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement